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K,AAAA,CAAA,EAAA,GAAA,WAAU,AAAV,EAAY,IAAI,CAAC,GAAO,IAAI,CAAC,EAAW,WAEnD,GAAI,oBAAqB,EAA8B,CAIrD,IAAM,EAAa,AAHF,CAAA,MACf,EACA,eAAe,CAAC,EAFlB,EAG4B,SAAS,GAAG,QAAQ,CAAC,UAEjD,OADA,QAAQ,GAAG,CAAC,CAAC,WAAW,EAAE,EAAA,CAAY,EAC/B,CACT,CAEA,MAAM,AAAI,MACR,CAAC,OAAO,EAAE,EAA6B,IAAI,CAAC,sCAAsC,CAAC,CAEvF,CACF","sources":["","node_modules/@parcel/runtime-js/lib/helpers/bundle-manifest.js","node_modules/buffer/index.js","node_modules/base64-js/index.js","node_modules/ieee754/index.js","node_modules/@solana/web3.js/lib/index.browser.esm.js","node_modules/@solana/web3.js/src/utils/ed25519.ts","node_modules/@solana/web3.js/src/utils/to-buffer.ts","node_modules/@solana/web3.js/src/utils/borsh-schema.ts","node_modules/@solana/web3.js/src/publickey.ts","node_modules/@solana/web3.js/src/account.ts","node_modules/@solana/web3.js/src/bpf-loader-deprecated.ts","node_modules/@solana/web3.js/src/transaction/constants.ts","node_modules/@solana/web3.js/src/transaction/expiry-custom-errors.ts","node_modules/@solana/web3.js/src/message/account-keys.ts","node_modules/@solana/web3.js/src/layout.ts","node_modules/@solana/web3.js/src/utils/shortvec-encoding.ts","node_modules/@solana/web3.js/src/utils/assert.ts","node_modules/@solana/web3.js/src/message/compiled-keys.ts","node_modules/@solana/web3.js/src/utils/guarded-array-utils.ts","node_modules/@solana/web3.js/src/message/legacy.ts","node_modules/@solana/web3.js/src/message/v0.ts","node_modules/@solana/web3.js/src/message/versioned.ts","node_modules/@solana/web3.js/src/transaction/legacy.ts","node_modules/@solana/web3.js/src/transaction/message.ts","node_modules/@solana/web3.js/src/transaction/versioned.ts","node_modules/@solana/web3.js/src/timing.ts","node_modules/@solana/web3.js/src/sysvar.ts","node_modules/@solana/web3.js/src/errors.ts","node_modules/@solana/web3.js/src/utils/send-and-confirm-transaction.ts","node_modules/@solana/web3.js/src/utils/sleep.ts","node_modules/@solana/web3.js/src/instruction.ts","node_modules/@solana/web3.js/src/fee-calculator.ts","node_modules/@solana/web3.js/src/nonce-account.ts","node_modules/@solana/web3.js/src/utils/bigint.ts","node_modules/@solana/web3.js/src/programs/system.ts","node_modules/@solana/web3.js/src/loader.ts","node_modules/@solana/web3.js/src/bpf-loader.ts","node_modules/@solana/web3.js/node_modules/.pnpm/fast-stable-stringify@1.0.0/node_modules/fast-stable-stringify/index.js","node_modules/@solana/web3.js/src/epoch-schedule.ts","node_modules/@solana/web3.js/src/__forks__/browser/fetch-impl.ts","node_modules/@solana/web3.js/src/rpc-websocket.ts","node_modules/@solana/web3.js/src/account-data.ts","node_modules/@solana/web3.js/src/programs/address-lookup-table/state.ts","node_modules/@solana/web3.js/src/utils/makeWebsocketUrl.ts","node_modules/@solana/web3.js/src/connection.ts","node_modules/@solana/web3.js/src/keypair.ts","node_modules/@solana/web3.js/src/programs/address-lookup-table/index.ts","node_modules/@solana/web3.js/src/programs/compute-budget.ts","node_modules/@solana/web3.js/src/programs/ed25519.ts","node_modules/@solana/web3.js/src/utils/secp256k1.ts","node_modules/@solana/web3.js/src/programs/secp256k1.ts","node_modules/@solana/web3.js/src/programs/stake.ts","node_modules/@solana/web3.js/src/programs/vote.ts","node_modules/@solana/web3.js/src/validator-info.ts","node_modules/@solana/web3.js/src/vote-account.ts","node_modules/@solana/web3.js/src/utils/cluster.ts","node_modules/@solana/web3.js/src/utils/send-and-confirm-raw-transaction.ts","node_modules/@solana/web3.js/src/index.ts","node_modules/@noble/curves/ed25519.js","node_modules/@noble/curves/src/ed25519.ts","node_modules/@noble/hashes/sha512.js","node_modules/@noble/hashes/src/sha512.ts","node_modules/@noble/hashes/_md.js","node_modules/@noble/hashes/src/_md.ts","node_modules/@noble/hashes/_assert.js","node_modules/@noble/hashes/src/_assert.ts","node_modules/@noble/hashes/utils.js","node_modules/@noble/hashes/src/utils.ts","node_modules/@noble/hashes/crypto.js","node_modules/@noble/hashes/src/crypto.ts","node_modules/@noble/hashes/_u64.js","node_modules/@noble/hashes/src/_u64.ts","node_modules/@noble/curves/abstract/curve.js","node_modules/@noble/curves/src/abstract/curve.ts","node_modules/@noble/curves/abstract/modular.js","node_modules/@noble/curves/src/abstract/modular.ts","node_modules/@noble/curves/abstract/utils.js","node_modules/@noble/curves/src/abstract/utils.ts","node_modules/@noble/curves/abstract/edwards.js","node_modules/@noble/curves/src/abstract/edwards.ts","node_modules/@noble/curves/abstract/hash-to-curve.js","node_modules/@noble/curves/src/abstract/hash-to-curve.ts","node_modules/@noble/curves/abstract/montgomery.js","node_modules/@noble/curves/src/abstract/montgomery.ts","node_modules/bn.js/lib/bn.js","node_modules/@parcel/node-resolver-core/lib/_empty.js","node_modules/bs58/index.js","node_modules/base-x/src/index.js","node_modules/safe-buffer/index.js","node_modules/@noble/hashes/sha256.js","node_modules/@noble/hashes/src/sha256.ts","node_modules/borsh/lib/index.js","node_modules/text-encoding-utf-8/lib/encoding.lib.js","node_modules/@solana/buffer-layout/lib/Layout.js","node_modules/@solana/buffer-layout/src/Layout.ts","node_modules/bigint-buffer/dist/browser.js","node_modules/superstruct/dist/index.mjs","node_modules/superstruct/src/error.ts","node_modules/superstruct/src/utils.ts","node_modules/superstruct/src/struct.ts","node_modules/superstruct/src/structs/utilities.ts","node_modules/superstruct/src/structs/types.ts","node_modules/superstruct/src/structs/coercions.ts","node_modules/superstruct/src/structs/refinements.ts","node_modules/jayson/lib/client/browser/index.js","node_modules/jayson/node_modules/uuid/dist/esm-browser/v4.js","node_modules/jayson/node_modules/uuid/dist/esm-browser/rng.js","node_modules/jayson/node_modules/uuid/dist/esm-browser/stringify.js","node_modules/jayson/node_modules/uuid/dist/esm-browser/validate.js","node_modules/jayson/node_modules/uuid/dist/esm-browser/regex.js","node_modules/jayson/lib/generateRequest.js","node_modules/rpc-websockets/dist/index.browser.mjs","node_modules/rpc-websockets/node_modules/esbuild-plugin-polyfill-node/polyfills/buffer.js","node_modules/rpc-websockets/src/lib/client/websocket.browser.ts","node_modules/rpc-websockets/src/lib/client.ts","node_modules/rpc-websockets/src/lib/utils.ts","node_modules/rpc-websockets/src/index.browser.ts","node_modules/rpc-websockets/node_modules/eventemitter3/index.js","node_modules/@noble/hashes/sha3.js","node_modules/@noble/hashes/src/sha3.ts","node_modules/@noble/curves/secp256k1.js","node_modules/@noble/curves/src/secp256k1.ts","node_modules/@noble/curves/_shortw_utils.js","node_modules/@noble/curves/src/_shortw_utils.ts","node_modules/@noble/hashes/hmac.js","node_modules/@noble/hashes/src/hmac.ts","node_modules/@noble/curves/abstract/weierstrass.js","node_modules/@noble/curves/src/abstract/weierstrass.ts","node_modules/@solana/wallet-standard-features/lib/esm/signAndSendTransaction.js","node_modules/@solana/wallet-standard-features/src/signAndSendTransaction.ts","node_modules/@solana/wallet-standard-features/lib/esm/signMessage.js","node_modules/@solana/wallet-standard-features/src/signMessage.ts","node_modules/@solana/wallet-standard-features/lib/esm/signTransaction.js","node_modules/@solana/wallet-standard-features/src/signTransaction.ts","node_modules/@parcel/runtime-js/lib/runtime-0541ef0ea54c4805.js","node_modules/@parcel/runtime-js/lib/helpers/browser/esm-js-loader.js","node_modules/@parcel/runtime-js/lib/runtime-d1ec55e2d3c8f0e3.js","node_modules/@parcel/runtime-js/lib/runtime-a16c1f1fdbdd3f8b.js","index.ts","node_modules/@solana/wallet-adapter-backpack/lib/esm/adapter.js","node_modules/@solana/wallet-adapter-backpack/src/adapter.ts","node_modules/@solana/wallet-adapter-base/lib/esm/signer.js","node_modules/@solana/wallet-adapter-base/src/signer.ts","node_modules/@solana/wallet-adapter-base/lib/esm/adapter.js","node_modules/@solana/wallet-adapter-base/src/adapter.ts","node_modules/eventemitter3/index.js","node_modules/@solana/wallet-adapter-base/lib/esm/errors.js","node_modules/@solana/wallet-adapter-base/src/errors.ts","node_modules/@solana/wallet-adapter-base/lib/esm/transaction.js","node_modules/@solana/wallet-adapter-base/src/transaction.ts","node_modules/@solana/wallet-adapter-phantom/lib/esm/adapter.js","node_modules/@solana/wallet-adapter-phantom/src/adapter.ts","node_modules/@solana/wallet-adapter-solflare/lib/esm/adapter.js","node_modules/@solana/wallet-adapter-solflare/src/adapter.ts","node_modules/@solana/wallet-adapter-solflare/lib/esm/metamask/detect.js","node_modules/@solana/wallet-adapter-solflare/src/metamask/detect.ts","node_modules/@wallet-standard/wallet/lib/esm/register.js","node_modules/@wallet-standard/wallet/src/register.ts","node_modules/@solana/wallet-adapter-solflare/lib/esm/metamask/wallet.js","node_modules/@solana/wallet-adapter-solflare/src/metamask/wallet.ts","node_modules/@solana/wallet-standard-chains/lib/esm/index.js","node_modules/@solana/wallet-standard-chains/src/index.ts","node_modules/@wallet-standard/features/lib/esm/connect.js","node_modules/@wallet-standard/features/src/connect.ts","node_modules/@wallet-standard/features/lib/esm/disconnect.js","node_modules/@wallet-standard/features/src/disconnect.ts","node_modules/@wallet-standard/features/lib/esm/events.js","node_modules/@wallet-standard/features/src/events.ts","node_modules/@solana/wallet-adapter-solflare/lib/esm/metamask/icon.js","node_modules/@solana/wallet-adapter-solflare/src/metamask/icon.ts","node_modules/@solana/wallet-adapter-base/lib/esm/types.js","node_modules/@solana/wallet-adapter-base/src/types.ts"],"sourcesContent":["\nfunction $parcel$export(e, n, v, s) {\n Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});\n}\n\nfunction $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\n var $parcel$global = globalThis;\n \nvar $parcel$modules = {};\nvar $parcel$inits = {};\n\nvar parcelRequire = $parcel$global[\"parcelRequire94c2\"];\n\nif (parcelRequire == null) {\n parcelRequire = function(id) {\n if (id in $parcel$modules) {\n return $parcel$modules[id].exports;\n }\n if (id in $parcel$inits) {\n var init = $parcel$inits[id];\n delete $parcel$inits[id];\n var module = {id: id, exports: {}};\n $parcel$modules[id] = module;\n init.call(module.exports, module, module.exports);\n return module.exports;\n }\n var err = new Error(\"Cannot find module '\" + id + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n };\n\n parcelRequire.register = function register(id, init) {\n $parcel$inits[id] = init;\n };\n\n $parcel$global[\"parcelRequire94c2\"] = parcelRequire;\n}\n\nvar parcelRegister = parcelRequire.register;\nparcelRegister(\"27Lyk\", function(module, exports) {\n\n$parcel$export(module.exports, \"register\", () => $18c11f3350a906ea$export$6503ec6e8aabbaf, (v) => $18c11f3350a906ea$export$6503ec6e8aabbaf = v);\n$parcel$export(module.exports, \"resolve\", () => $18c11f3350a906ea$export$f7ad0328861e2f03, (v) => $18c11f3350a906ea$export$f7ad0328861e2f03 = v);\nvar $18c11f3350a906ea$export$6503ec6e8aabbaf;\nvar $18c11f3350a906ea$export$f7ad0328861e2f03;\n\"use strict\";\nvar $18c11f3350a906ea$var$mapping = new Map();\nfunction $18c11f3350a906ea$var$register(baseUrl, manifest) {\n for(var i = 0; i < manifest.length - 1; i += 2)$18c11f3350a906ea$var$mapping.set(manifest[i], {\n baseUrl: baseUrl,\n path: manifest[i + 1]\n });\n}\nfunction $18c11f3350a906ea$var$resolve(id) {\n var resolved = $18c11f3350a906ea$var$mapping.get(id);\n if (resolved == null) throw new Error('Could not resolve bundle with id ' + id);\n return new URL(resolved.path, resolved.baseUrl).toString();\n}\n$18c11f3350a906ea$export$6503ec6e8aabbaf = $18c11f3350a906ea$var$register;\n$18c11f3350a906ea$export$f7ad0328861e2f03 = $18c11f3350a906ea$var$resolve;\n\n});\n\nparcelRegister(\"6ZWSX\", function(module, exports) {\n\n$parcel$export(module.exports, \"Buffer\", () => $51861dfc7ca9d588$export$a143d493d941bafc, (v) => $51861dfc7ca9d588$export$a143d493d941bafc = v);\n$parcel$export(module.exports, \"SlowBuffer\", () => $51861dfc7ca9d588$export$e4cf37d7f6fb9e0a, (v) => $51861dfc7ca9d588$export$e4cf37d7f6fb9e0a = v);\n$parcel$export(module.exports, \"INSPECT_MAX_BYTES\", () => $51861dfc7ca9d588$export$f99ded8fe4b79145, (v) => $51861dfc7ca9d588$export$f99ded8fe4b79145 = v);\n$parcel$export(module.exports, \"kMaxLength\", () => $51861dfc7ca9d588$export$599f31c3813fae4d, (v) => $51861dfc7ca9d588$export$599f31c3813fae4d = v);\n/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */ /* eslint-disable no-proto */ var $51861dfc7ca9d588$export$a143d493d941bafc;\nvar $51861dfc7ca9d588$export$e4cf37d7f6fb9e0a;\nvar $51861dfc7ca9d588$export$f99ded8fe4b79145;\nvar $51861dfc7ca9d588$export$599f31c3813fae4d;\n'use strict';\n\nvar $kuxul = parcelRequire(\"kuxul\");\n\nvar $9NvM5 = parcelRequire(\"9NvM5\");\nconst $51861dfc7ca9d588$var$customInspectSymbol = typeof Symbol === 'function' && typeof Symbol['for'] === 'function' // eslint-disable-line dot-notation\n ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation\n : null;\n$51861dfc7ca9d588$export$a143d493d941bafc = $51861dfc7ca9d588$var$Buffer;\n$51861dfc7ca9d588$export$e4cf37d7f6fb9e0a = $51861dfc7ca9d588$var$SlowBuffer;\n$51861dfc7ca9d588$export$f99ded8fe4b79145 = 50;\nconst $51861dfc7ca9d588$var$K_MAX_LENGTH = 0x7fffffff;\n$51861dfc7ca9d588$export$599f31c3813fae4d = $51861dfc7ca9d588$var$K_MAX_LENGTH;\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Print warning and recommend using `buffer` v4.x which has an Object\n * implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * We report that the browser does not support typed arrays if the are not subclassable\n * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`\n * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support\n * for __proto__ and has a buggy typed array implementation.\n */ $51861dfc7ca9d588$var$Buffer.TYPED_ARRAY_SUPPORT = $51861dfc7ca9d588$var$typedArraySupport();\nif (!$51861dfc7ca9d588$var$Buffer.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.\");\nfunction $51861dfc7ca9d588$var$typedArraySupport() {\n // Can typed array instances can be augmented?\n try {\n const arr = new Uint8Array(1);\n const proto = {\n foo: function() {\n return 42;\n }\n };\n Object.setPrototypeOf(proto, Uint8Array.prototype);\n Object.setPrototypeOf(arr, proto);\n return arr.foo() === 42;\n } catch (e) {\n return false;\n }\n}\nObject.defineProperty($51861dfc7ca9d588$var$Buffer.prototype, 'parent', {\n enumerable: true,\n get: function() {\n if (!$51861dfc7ca9d588$var$Buffer.isBuffer(this)) return undefined;\n return this.buffer;\n }\n});\nObject.defineProperty($51861dfc7ca9d588$var$Buffer.prototype, 'offset', {\n enumerable: true,\n get: function() {\n if (!$51861dfc7ca9d588$var$Buffer.isBuffer(this)) return undefined;\n return this.byteOffset;\n }\n});\nfunction $51861dfc7ca9d588$var$createBuffer(length) {\n if (length > $51861dfc7ca9d588$var$K_MAX_LENGTH) throw new RangeError('The value \"' + length + '\" is invalid for option \"size\"');\n // Return an augmented `Uint8Array` instance\n const buf = new Uint8Array(length);\n Object.setPrototypeOf(buf, $51861dfc7ca9d588$var$Buffer.prototype);\n return buf;\n}\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */ function $51861dfc7ca9d588$var$Buffer(arg, encodingOrOffset, length) {\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') throw new TypeError('The \"string\" argument must be of type string. Received type number');\n return $51861dfc7ca9d588$var$allocUnsafe(arg);\n }\n return $51861dfc7ca9d588$var$from(arg, encodingOrOffset, length);\n}\n$51861dfc7ca9d588$var$Buffer.poolSize = 8192 // not used by this implementation\n;\nfunction $51861dfc7ca9d588$var$from(value, encodingOrOffset, length) {\n if (typeof value === 'string') return $51861dfc7ca9d588$var$fromString(value, encodingOrOffset);\n if (ArrayBuffer.isView(value)) return $51861dfc7ca9d588$var$fromArrayView(value);\n 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);\n if ($51861dfc7ca9d588$var$isInstance(value, ArrayBuffer) || value && $51861dfc7ca9d588$var$isInstance(value.buffer, ArrayBuffer)) return $51861dfc7ca9d588$var$fromArrayBuffer(value, encodingOrOffset, length);\n if (typeof SharedArrayBuffer !== 'undefined' && ($51861dfc7ca9d588$var$isInstance(value, SharedArrayBuffer) || value && $51861dfc7ca9d588$var$isInstance(value.buffer, SharedArrayBuffer))) return $51861dfc7ca9d588$var$fromArrayBuffer(value, encodingOrOffset, length);\n if (typeof value === 'number') throw new TypeError('The \"value\" argument must not be of type number. Received type number');\n const valueOf = value.valueOf && value.valueOf();\n if (valueOf != null && valueOf !== value) return $51861dfc7ca9d588$var$Buffer.from(valueOf, encodingOrOffset, length);\n const b = $51861dfc7ca9d588$var$fromObject(value);\n if (b) return b;\n if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === 'function') return $51861dfc7ca9d588$var$Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length);\n throw new TypeError(\"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type \" + typeof value);\n}\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/ $51861dfc7ca9d588$var$Buffer.from = function(value, encodingOrOffset, length) {\n return $51861dfc7ca9d588$var$from(value, encodingOrOffset, length);\n};\n// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:\n// https://github.com/feross/buffer/pull/148\nObject.setPrototypeOf($51861dfc7ca9d588$var$Buffer.prototype, Uint8Array.prototype);\nObject.setPrototypeOf($51861dfc7ca9d588$var$Buffer, Uint8Array);\nfunction $51861dfc7ca9d588$var$assertSize(size) {\n if (typeof size !== 'number') throw new TypeError('\"size\" argument must be of type number');\n else if (size < 0) throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"');\n}\nfunction $51861dfc7ca9d588$var$alloc(size, fill, encoding) {\n $51861dfc7ca9d588$var$assertSize(size);\n if (size <= 0) return $51861dfc7ca9d588$var$createBuffer(size);\n if (fill !== undefined) // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpreted as a start offset.\n return typeof encoding === 'string' ? $51861dfc7ca9d588$var$createBuffer(size).fill(fill, encoding) : $51861dfc7ca9d588$var$createBuffer(size).fill(fill);\n return $51861dfc7ca9d588$var$createBuffer(size);\n}\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/ $51861dfc7ca9d588$var$Buffer.alloc = function(size, fill, encoding) {\n return $51861dfc7ca9d588$var$alloc(size, fill, encoding);\n};\nfunction $51861dfc7ca9d588$var$allocUnsafe(size) {\n $51861dfc7ca9d588$var$assertSize(size);\n return $51861dfc7ca9d588$var$createBuffer(size < 0 ? 0 : $51861dfc7ca9d588$var$checked(size) | 0);\n}\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */ $51861dfc7ca9d588$var$Buffer.allocUnsafe = function(size) {\n return $51861dfc7ca9d588$var$allocUnsafe(size);\n};\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */ $51861dfc7ca9d588$var$Buffer.allocUnsafeSlow = function(size) {\n return $51861dfc7ca9d588$var$allocUnsafe(size);\n};\nfunction $51861dfc7ca9d588$var$fromString(string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') encoding = 'utf8';\n if (!$51861dfc7ca9d588$var$Buffer.isEncoding(encoding)) throw new TypeError('Unknown encoding: ' + encoding);\n const length = $51861dfc7ca9d588$var$byteLength(string, encoding) | 0;\n let buf = $51861dfc7ca9d588$var$createBuffer(length);\n const actual = buf.write(string, encoding);\n if (actual !== length) // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n buf = buf.slice(0, actual);\n return buf;\n}\nfunction $51861dfc7ca9d588$var$fromArrayLike(array) {\n const length = array.length < 0 ? 0 : $51861dfc7ca9d588$var$checked(array.length) | 0;\n const buf = $51861dfc7ca9d588$var$createBuffer(length);\n for(let i = 0; i < length; i += 1)buf[i] = array[i] & 255;\n return buf;\n}\nfunction $51861dfc7ca9d588$var$fromArrayView(arrayView) {\n if ($51861dfc7ca9d588$var$isInstance(arrayView, Uint8Array)) {\n const copy = new Uint8Array(arrayView);\n return $51861dfc7ca9d588$var$fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);\n }\n return $51861dfc7ca9d588$var$fromArrayLike(arrayView);\n}\nfunction $51861dfc7ca9d588$var$fromArrayBuffer(array, byteOffset, length) {\n if (byteOffset < 0 || array.byteLength < byteOffset) throw new RangeError('\"offset\" is outside of buffer bounds');\n if (array.byteLength < byteOffset + (length || 0)) throw new RangeError('\"length\" is outside of buffer bounds');\n let buf;\n if (byteOffset === undefined && length === undefined) buf = new Uint8Array(array);\n else if (length === undefined) buf = new Uint8Array(array, byteOffset);\n else buf = new Uint8Array(array, byteOffset, length);\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(buf, $51861dfc7ca9d588$var$Buffer.prototype);\n return buf;\n}\nfunction $51861dfc7ca9d588$var$fromObject(obj) {\n if ($51861dfc7ca9d588$var$Buffer.isBuffer(obj)) {\n const len = $51861dfc7ca9d588$var$checked(obj.length) | 0;\n const buf = $51861dfc7ca9d588$var$createBuffer(len);\n if (buf.length === 0) return buf;\n obj.copy(buf, 0, 0, len);\n return buf;\n }\n if (obj.length !== undefined) {\n if (typeof obj.length !== 'number' || $51861dfc7ca9d588$var$numberIsNaN(obj.length)) return $51861dfc7ca9d588$var$createBuffer(0);\n return $51861dfc7ca9d588$var$fromArrayLike(obj);\n }\n if (obj.type === 'Buffer' && Array.isArray(obj.data)) return $51861dfc7ca9d588$var$fromArrayLike(obj.data);\n}\nfunction $51861dfc7ca9d588$var$checked(length) {\n // Note: cannot use `length < K_MAX_LENGTH` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= $51861dfc7ca9d588$var$K_MAX_LENGTH) throw new RangeError(\"Attempt to allocate Buffer larger than maximum size: 0x\" + $51861dfc7ca9d588$var$K_MAX_LENGTH.toString(16) + ' bytes');\n return length | 0;\n}\nfunction $51861dfc7ca9d588$var$SlowBuffer(length) {\n if (+length != length) length = 0;\n return $51861dfc7ca9d588$var$Buffer.alloc(+length);\n}\n$51861dfc7ca9d588$var$Buffer.isBuffer = function isBuffer(b) {\n return b != null && b._isBuffer === true && b !== $51861dfc7ca9d588$var$Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false\n ;\n};\n$51861dfc7ca9d588$var$Buffer.compare = function compare(a, b) {\n if ($51861dfc7ca9d588$var$isInstance(a, Uint8Array)) a = $51861dfc7ca9d588$var$Buffer.from(a, a.offset, a.byteLength);\n if ($51861dfc7ca9d588$var$isInstance(b, Uint8Array)) b = $51861dfc7ca9d588$var$Buffer.from(b, b.offset, b.byteLength);\n if (!$51861dfc7ca9d588$var$Buffer.isBuffer(a) || !$51861dfc7ca9d588$var$Buffer.isBuffer(b)) throw new TypeError('The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array');\n if (a === b) return 0;\n let x = a.length;\n let y = b.length;\n for(let i = 0, len = Math.min(x, y); i < len; ++i)if (a[i] !== b[i]) {\n x = a[i];\n y = b[i];\n break;\n }\n if (x < y) return -1;\n if (y < x) return 1;\n return 0;\n};\n$51861dfc7ca9d588$var$Buffer.isEncoding = function isEncoding(encoding) {\n switch(String(encoding).toLowerCase()){\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true;\n default:\n return false;\n }\n};\n$51861dfc7ca9d588$var$Buffer.concat = function concat(list, length) {\n if (!Array.isArray(list)) throw new TypeError('\"list\" argument must be an Array of Buffers');\n if (list.length === 0) return $51861dfc7ca9d588$var$Buffer.alloc(0);\n let i;\n if (length === undefined) {\n length = 0;\n for(i = 0; i < list.length; ++i)length += list[i].length;\n }\n const buffer = $51861dfc7ca9d588$var$Buffer.allocUnsafe(length);\n let pos = 0;\n for(i = 0; i < list.length; ++i){\n let buf = list[i];\n if ($51861dfc7ca9d588$var$isInstance(buf, Uint8Array)) {\n if (pos + buf.length > buffer.length) {\n if (!$51861dfc7ca9d588$var$Buffer.isBuffer(buf)) buf = $51861dfc7ca9d588$var$Buffer.from(buf);\n buf.copy(buffer, pos);\n } else Uint8Array.prototype.set.call(buffer, buf, pos);\n } else if (!$51861dfc7ca9d588$var$Buffer.isBuffer(buf)) throw new TypeError('\"list\" argument must be an Array of Buffers');\n else buf.copy(buffer, pos);\n pos += buf.length;\n }\n return buffer;\n};\nfunction $51861dfc7ca9d588$var$byteLength(string, encoding) {\n if ($51861dfc7ca9d588$var$Buffer.isBuffer(string)) return string.length;\n if (ArrayBuffer.isView(string) || $51861dfc7ca9d588$var$isInstance(string, ArrayBuffer)) return string.byteLength;\n if (typeof string !== 'string') throw new TypeError('The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string);\n const len = string.length;\n const mustMatch = arguments.length > 2 && arguments[2] === true;\n if (!mustMatch && len === 0) return 0;\n // Use a for loop to avoid recursion\n let loweredCase = false;\n for(;;)switch(encoding){\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len;\n case 'utf8':\n case 'utf-8':\n return $51861dfc7ca9d588$var$utf8ToBytes(string).length;\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2;\n case 'hex':\n return len >>> 1;\n case 'base64':\n return $51861dfc7ca9d588$var$base64ToBytes(string).length;\n default:\n if (loweredCase) return mustMatch ? -1 : $51861dfc7ca9d588$var$utf8ToBytes(string).length // assume utf8\n ;\n encoding = ('' + encoding).toLowerCase();\n loweredCase = true;\n }\n}\n$51861dfc7ca9d588$var$Buffer.byteLength = $51861dfc7ca9d588$var$byteLength;\nfunction $51861dfc7ca9d588$var$slowToString(encoding, start, end) {\n let loweredCase = false;\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) start = 0;\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) return '';\n if (end === undefined || end > this.length) end = this.length;\n if (end <= 0) return '';\n // Force coercion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0;\n start >>>= 0;\n if (end <= start) return '';\n if (!encoding) encoding = 'utf8';\n while(true)switch(encoding){\n case 'hex':\n return $51861dfc7ca9d588$var$hexSlice(this, start, end);\n case 'utf8':\n case 'utf-8':\n return $51861dfc7ca9d588$var$utf8Slice(this, start, end);\n case 'ascii':\n return $51861dfc7ca9d588$var$asciiSlice(this, start, end);\n case 'latin1':\n case 'binary':\n return $51861dfc7ca9d588$var$latin1Slice(this, start, end);\n case 'base64':\n return $51861dfc7ca9d588$var$base64Slice(this, start, end);\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return $51861dfc7ca9d588$var$utf16leSlice(this, start, end);\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding);\n encoding = (encoding + '').toLowerCase();\n loweredCase = true;\n }\n}\n// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)\n// to detect a Buffer instance. It's not possible to use `instanceof Buffer`\n// reliably in a browserify context because there could be multiple different\n// copies of the 'buffer' package in use. This method works even for Buffer\n// instances that were created from another copy of the `buffer` package.\n// See: https://github.com/feross/buffer/issues/154\n$51861dfc7ca9d588$var$Buffer.prototype._isBuffer = true;\nfunction $51861dfc7ca9d588$var$swap(b, n, m) {\n const i = b[n];\n b[n] = b[m];\n b[m] = i;\n}\n$51861dfc7ca9d588$var$Buffer.prototype.swap16 = function swap16() {\n const len = this.length;\n if (len % 2 !== 0) throw new RangeError('Buffer size must be a multiple of 16-bits');\n for(let i = 0; i < len; i += 2)$51861dfc7ca9d588$var$swap(this, i, i + 1);\n return this;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.swap32 = function swap32() {\n const len = this.length;\n if (len % 4 !== 0) throw new RangeError('Buffer size must be a multiple of 32-bits');\n for(let i = 0; i < len; i += 4){\n $51861dfc7ca9d588$var$swap(this, i, i + 3);\n $51861dfc7ca9d588$var$swap(this, i + 1, i + 2);\n }\n return this;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.swap64 = function swap64() {\n const len = this.length;\n if (len % 8 !== 0) throw new RangeError('Buffer size must be a multiple of 64-bits');\n for(let i = 0; i < len; i += 8){\n $51861dfc7ca9d588$var$swap(this, i, i + 7);\n $51861dfc7ca9d588$var$swap(this, i + 1, i + 6);\n $51861dfc7ca9d588$var$swap(this, i + 2, i + 5);\n $51861dfc7ca9d588$var$swap(this, i + 3, i + 4);\n }\n return this;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.toString = function toString() {\n const length = this.length;\n if (length === 0) return '';\n if (arguments.length === 0) return $51861dfc7ca9d588$var$utf8Slice(this, 0, length);\n return $51861dfc7ca9d588$var$slowToString.apply(this, arguments);\n};\n$51861dfc7ca9d588$var$Buffer.prototype.toLocaleString = $51861dfc7ca9d588$var$Buffer.prototype.toString;\n$51861dfc7ca9d588$var$Buffer.prototype.equals = function equals(b) {\n if (!$51861dfc7ca9d588$var$Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer');\n if (this === b) return true;\n return $51861dfc7ca9d588$var$Buffer.compare(this, b) === 0;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.inspect = function inspect() {\n let str = '';\n const max = $51861dfc7ca9d588$export$f99ded8fe4b79145;\n str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();\n if (this.length > max) str += ' ... ';\n return '';\n};\nif ($51861dfc7ca9d588$var$customInspectSymbol) $51861dfc7ca9d588$var$Buffer.prototype[$51861dfc7ca9d588$var$customInspectSymbol] = $51861dfc7ca9d588$var$Buffer.prototype.inspect;\n$51861dfc7ca9d588$var$Buffer.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {\n if ($51861dfc7ca9d588$var$isInstance(target, Uint8Array)) target = $51861dfc7ca9d588$var$Buffer.from(target, target.offset, target.byteLength);\n if (!$51861dfc7ca9d588$var$Buffer.isBuffer(target)) throw new TypeError('The \"target\" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target);\n if (start === undefined) start = 0;\n if (end === undefined) end = target ? target.length : 0;\n if (thisStart === undefined) thisStart = 0;\n if (thisEnd === undefined) thisEnd = this.length;\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) throw new RangeError('out of range index');\n if (thisStart >= thisEnd && start >= end) return 0;\n if (thisStart >= thisEnd) return -1;\n if (start >= end) return 1;\n start >>>= 0;\n end >>>= 0;\n thisStart >>>= 0;\n thisEnd >>>= 0;\n if (this === target) return 0;\n let x = thisEnd - thisStart;\n let y = end - start;\n const len = Math.min(x, y);\n const thisCopy = this.slice(thisStart, thisEnd);\n const targetCopy = target.slice(start, end);\n for(let i = 0; i < len; ++i)if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i];\n y = targetCopy[i];\n break;\n }\n if (x < y) return -1;\n if (y < x) return 1;\n return 0;\n};\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction $51861dfc7ca9d588$var$bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1;\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset;\n byteOffset = 0;\n } else if (byteOffset > 0x7fffffff) byteOffset = 0x7fffffff;\n else if (byteOffset < -2147483648) byteOffset = -2147483648;\n byteOffset = +byteOffset // Coerce to Number.\n ;\n if ($51861dfc7ca9d588$var$numberIsNaN(byteOffset)) // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : buffer.length - 1;\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset;\n if (byteOffset >= buffer.length) {\n if (dir) return -1;\n else byteOffset = buffer.length - 1;\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0;\n else return -1;\n }\n // Normalize val\n if (typeof val === 'string') val = $51861dfc7ca9d588$var$Buffer.from(val, encoding);\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if ($51861dfc7ca9d588$var$Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) return -1;\n return $51861dfc7ca9d588$var$arrayIndexOf(buffer, val, byteOffset, encoding, dir);\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n ;\n if (typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);\n else return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);\n }\n return $51861dfc7ca9d588$var$arrayIndexOf(buffer, [\n val\n ], byteOffset, encoding, dir);\n }\n throw new TypeError('val must be string, number or Buffer');\n}\nfunction $51861dfc7ca9d588$var$arrayIndexOf(arr, val, byteOffset, encoding, dir) {\n let indexSize = 1;\n let arrLength = arr.length;\n let valLength = val.length;\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase();\n if (encoding === 'ucs2' || encoding === 'ucs-2' || encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) return -1;\n indexSize = 2;\n arrLength /= 2;\n valLength /= 2;\n byteOffset /= 2;\n }\n }\n function read(buf, i) {\n if (indexSize === 1) return buf[i];\n else return buf.readUInt16BE(i * indexSize);\n }\n let i;\n if (dir) {\n let foundIndex = -1;\n for(i = byteOffset; i < arrLength; i++)if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i;\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;\n } else {\n if (foundIndex !== -1) i -= i - foundIndex;\n foundIndex = -1;\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;\n for(i = byteOffset; i >= 0; i--){\n let found = true;\n for(let j = 0; j < valLength; j++)if (read(arr, i + j) !== read(val, j)) {\n found = false;\n break;\n }\n if (found) return i;\n }\n }\n return -1;\n}\n$51861dfc7ca9d588$var$Buffer.prototype.includes = function includes(val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.indexOf = function indexOf(val, byteOffset, encoding) {\n return $51861dfc7ca9d588$var$bidirectionalIndexOf(this, val, byteOffset, encoding, true);\n};\n$51861dfc7ca9d588$var$Buffer.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {\n return $51861dfc7ca9d588$var$bidirectionalIndexOf(this, val, byteOffset, encoding, false);\n};\nfunction $51861dfc7ca9d588$var$hexWrite(buf, string, offset, length) {\n offset = Number(offset) || 0;\n const remaining = buf.length - offset;\n if (!length) length = remaining;\n else {\n length = Number(length);\n if (length > remaining) length = remaining;\n }\n const strLen = string.length;\n if (length > strLen / 2) length = strLen / 2;\n let i;\n for(i = 0; i < length; ++i){\n const parsed = parseInt(string.substr(i * 2, 2), 16);\n if ($51861dfc7ca9d588$var$numberIsNaN(parsed)) return i;\n buf[offset + i] = parsed;\n }\n return i;\n}\nfunction $51861dfc7ca9d588$var$utf8Write(buf, string, offset, length) {\n return $51861dfc7ca9d588$var$blitBuffer($51861dfc7ca9d588$var$utf8ToBytes(string, buf.length - offset), buf, offset, length);\n}\nfunction $51861dfc7ca9d588$var$asciiWrite(buf, string, offset, length) {\n return $51861dfc7ca9d588$var$blitBuffer($51861dfc7ca9d588$var$asciiToBytes(string), buf, offset, length);\n}\nfunction $51861dfc7ca9d588$var$base64Write(buf, string, offset, length) {\n return $51861dfc7ca9d588$var$blitBuffer($51861dfc7ca9d588$var$base64ToBytes(string), buf, offset, length);\n}\nfunction $51861dfc7ca9d588$var$ucs2Write(buf, string, offset, length) {\n return $51861dfc7ca9d588$var$blitBuffer($51861dfc7ca9d588$var$utf16leToBytes(string, buf.length - offset), buf, offset, length);\n}\n$51861dfc7ca9d588$var$Buffer.prototype.write = function write(string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8';\n length = this.length;\n offset = 0;\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset;\n length = this.length;\n offset = 0;\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset >>> 0;\n if (isFinite(length)) {\n length = length >>> 0;\n if (encoding === undefined) encoding = 'utf8';\n } else {\n encoding = length;\n length = undefined;\n }\n } else throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');\n const remaining = this.length - offset;\n if (length === undefined || length > remaining) length = remaining;\n if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) throw new RangeError('Attempt to write outside buffer bounds');\n if (!encoding) encoding = 'utf8';\n let loweredCase = false;\n for(;;)switch(encoding){\n case 'hex':\n return $51861dfc7ca9d588$var$hexWrite(this, string, offset, length);\n case 'utf8':\n case 'utf-8':\n return $51861dfc7ca9d588$var$utf8Write(this, string, offset, length);\n case 'ascii':\n case 'latin1':\n case 'binary':\n return $51861dfc7ca9d588$var$asciiWrite(this, string, offset, length);\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return $51861dfc7ca9d588$var$base64Write(this, string, offset, length);\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return $51861dfc7ca9d588$var$ucs2Write(this, string, offset, length);\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding);\n encoding = ('' + encoding).toLowerCase();\n loweredCase = true;\n }\n};\n$51861dfc7ca9d588$var$Buffer.prototype.toJSON = function toJSON() {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n };\n};\nfunction $51861dfc7ca9d588$var$base64Slice(buf, start, end) {\n if (start === 0 && end === buf.length) return $kuxul.fromByteArray(buf);\n else return $kuxul.fromByteArray(buf.slice(start, end));\n}\nfunction $51861dfc7ca9d588$var$utf8Slice(buf, start, end) {\n end = Math.min(buf.length, end);\n const res = [];\n let i = start;\n while(i < end){\n const firstByte = buf[i];\n let codePoint = null;\n let bytesPerSequence = firstByte > 0xEF ? 4 : firstByte > 0xDF ? 3 : firstByte > 0xBF ? 2 : 1;\n if (i + bytesPerSequence <= end) {\n let secondByte, thirdByte, fourthByte, tempCodePoint;\n switch(bytesPerSequence){\n case 1:\n if (firstByte < 0x80) codePoint = firstByte;\n break;\n case 2:\n secondByte = buf[i + 1];\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | secondByte & 0x3F;\n if (tempCodePoint > 0x7F) codePoint = tempCodePoint;\n }\n break;\n case 3:\n secondByte = buf[i + 1];\n thirdByte = buf[i + 2];\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | thirdByte & 0x3F;\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) codePoint = tempCodePoint;\n }\n break;\n case 4:\n secondByte = buf[i + 1];\n thirdByte = buf[i + 2];\n fourthByte = buf[i + 3];\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | fourthByte & 0x3F;\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) codePoint = tempCodePoint;\n }\n }\n }\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD;\n bytesPerSequence = 1;\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000;\n res.push(codePoint >>> 10 & 0x3FF | 0xD800);\n codePoint = 0xDC00 | codePoint & 0x3FF;\n }\n res.push(codePoint);\n i += bytesPerSequence;\n }\n return $51861dfc7ca9d588$var$decodeCodePointsArray(res);\n}\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nconst $51861dfc7ca9d588$var$MAX_ARGUMENTS_LENGTH = 0x1000;\nfunction $51861dfc7ca9d588$var$decodeCodePointsArray(codePoints) {\n const len = codePoints.length;\n if (len <= $51861dfc7ca9d588$var$MAX_ARGUMENTS_LENGTH) return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n ;\n // Decode in chunks to avoid \"call stack size exceeded\".\n let res = '';\n let i = 0;\n while(i < len)res += String.fromCharCode.apply(String, codePoints.slice(i, i += $51861dfc7ca9d588$var$MAX_ARGUMENTS_LENGTH));\n return res;\n}\nfunction $51861dfc7ca9d588$var$asciiSlice(buf, start, end) {\n let ret = '';\n end = Math.min(buf.length, end);\n for(let i = start; i < end; ++i)ret += String.fromCharCode(buf[i] & 0x7F);\n return ret;\n}\nfunction $51861dfc7ca9d588$var$latin1Slice(buf, start, end) {\n let ret = '';\n end = Math.min(buf.length, end);\n for(let i = start; i < end; ++i)ret += String.fromCharCode(buf[i]);\n return ret;\n}\nfunction $51861dfc7ca9d588$var$hexSlice(buf, start, end) {\n const len = buf.length;\n if (!start || start < 0) start = 0;\n if (!end || end < 0 || end > len) end = len;\n let out = '';\n for(let i = start; i < end; ++i)out += $51861dfc7ca9d588$var$hexSliceLookupTable[buf[i]];\n return out;\n}\nfunction $51861dfc7ca9d588$var$utf16leSlice(buf, start, end) {\n const bytes = buf.slice(start, end);\n let res = '';\n // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)\n for(let i = 0; i < bytes.length - 1; i += 2)res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);\n return res;\n}\n$51861dfc7ca9d588$var$Buffer.prototype.slice = function slice(start, end) {\n const len = this.length;\n start = ~~start;\n end = end === undefined ? len : ~~end;\n if (start < 0) {\n start += len;\n if (start < 0) start = 0;\n } else if (start > len) start = len;\n if (end < 0) {\n end += len;\n if (end < 0) end = 0;\n } else if (end > len) end = len;\n if (end < start) end = start;\n const newBuf = this.subarray(start, end);\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(newBuf, $51861dfc7ca9d588$var$Buffer.prototype);\n return newBuf;\n};\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */ function $51861dfc7ca9d588$var$checkOffset(offset, ext, length) {\n if (offset % 1 !== 0 || offset < 0) throw new RangeError('offset is not uint');\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length');\n}\n$51861dfc7ca9d588$var$Buffer.prototype.readUintLE = $51861dfc7ca9d588$var$Buffer.prototype.readUIntLE = function readUIntLE(offset, byteLength, noAssert) {\n offset = offset >>> 0;\n byteLength = byteLength >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, byteLength, this.length);\n let val = this[offset];\n let mul = 1;\n let i = 0;\n while(++i < byteLength && (mul *= 0x100))val += this[offset + i] * mul;\n return val;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readUintBE = $51861dfc7ca9d588$var$Buffer.prototype.readUIntBE = function readUIntBE(offset, byteLength, noAssert) {\n offset = offset >>> 0;\n byteLength = byteLength >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, byteLength, this.length);\n let val = this[offset + --byteLength];\n let mul = 1;\n while(byteLength > 0 && (mul *= 0x100))val += this[offset + --byteLength] * mul;\n return val;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readUint8 = $51861dfc7ca9d588$var$Buffer.prototype.readUInt8 = function readUInt8(offset, noAssert) {\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, 1, this.length);\n return this[offset];\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readUint16LE = $51861dfc7ca9d588$var$Buffer.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, 2, this.length);\n return this[offset] | this[offset + 1] << 8;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readUint16BE = $51861dfc7ca9d588$var$Buffer.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, 2, this.length);\n return this[offset] << 8 | this[offset + 1];\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readUint32LE = $51861dfc7ca9d588$var$Buffer.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, 4, this.length);\n return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 0x1000000;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readUint32BE = $51861dfc7ca9d588$var$Buffer.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, 4, this.length);\n return this[offset] * 0x1000000 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readBigUInt64LE = $51861dfc7ca9d588$var$defineBigIntMethod(function readBigUInt64LE(offset) {\n offset = offset >>> 0;\n $51861dfc7ca9d588$var$validateNumber(offset, 'offset');\n const first = this[offset];\n const last = this[offset + 7];\n if (first === undefined || last === undefined) $51861dfc7ca9d588$var$boundsError(offset, this.length - 8);\n const lo = first + this[++offset] * 256 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;\n const hi = this[++offset] + this[++offset] * 256 + this[++offset] * 2 ** 16 + last * 2 ** 24;\n return BigInt(lo) + (BigInt(hi) << BigInt(32));\n});\n$51861dfc7ca9d588$var$Buffer.prototype.readBigUInt64BE = $51861dfc7ca9d588$var$defineBigIntMethod(function readBigUInt64BE(offset) {\n offset = offset >>> 0;\n $51861dfc7ca9d588$var$validateNumber(offset, 'offset');\n const first = this[offset];\n const last = this[offset + 7];\n if (first === undefined || last === undefined) $51861dfc7ca9d588$var$boundsError(offset, this.length - 8);\n const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 256 + this[++offset];\n const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 256 + last;\n return (BigInt(hi) << BigInt(32)) + BigInt(lo);\n});\n$51861dfc7ca9d588$var$Buffer.prototype.readIntLE = function readIntLE(offset, byteLength, noAssert) {\n offset = offset >>> 0;\n byteLength = byteLength >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, byteLength, this.length);\n let val = this[offset];\n let mul = 1;\n let i = 0;\n while(++i < byteLength && (mul *= 0x100))val += this[offset + i] * mul;\n mul *= 0x80;\n if (val >= mul) val -= Math.pow(2, 8 * byteLength);\n return val;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readIntBE = function readIntBE(offset, byteLength, noAssert) {\n offset = offset >>> 0;\n byteLength = byteLength >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, byteLength, this.length);\n let i = byteLength;\n let mul = 1;\n let val = this[offset + --i];\n while(i > 0 && (mul *= 0x100))val += this[offset + --i] * mul;\n mul *= 0x80;\n if (val >= mul) val -= Math.pow(2, 8 * byteLength);\n return val;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readInt8 = function readInt8(offset, noAssert) {\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, 1, this.length);\n if (!(this[offset] & 0x80)) return this[offset];\n return (0xff - this[offset] + 1) * -1;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readInt16LE = function readInt16LE(offset, noAssert) {\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, 2, this.length);\n const val = this[offset] | this[offset + 1] << 8;\n return val & 0x8000 ? val | 0xFFFF0000 : val;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readInt16BE = function readInt16BE(offset, noAssert) {\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, 2, this.length);\n const val = this[offset + 1] | this[offset] << 8;\n return val & 0x8000 ? val | 0xFFFF0000 : val;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readInt32LE = function readInt32LE(offset, noAssert) {\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, 4, this.length);\n return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readInt32BE = function readInt32BE(offset, noAssert) {\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, 4, this.length);\n return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readBigInt64LE = $51861dfc7ca9d588$var$defineBigIntMethod(function readBigInt64LE(offset) {\n offset = offset >>> 0;\n $51861dfc7ca9d588$var$validateNumber(offset, 'offset');\n const first = this[offset];\n const last = this[offset + 7];\n if (first === undefined || last === undefined) $51861dfc7ca9d588$var$boundsError(offset, this.length - 8);\n const val = this[offset + 4] + this[offset + 5] * 256 + this[offset + 6] * 2 ** 16 + (last << 24 // Overflow\n );\n return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 256 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);\n});\n$51861dfc7ca9d588$var$Buffer.prototype.readBigInt64BE = $51861dfc7ca9d588$var$defineBigIntMethod(function readBigInt64BE(offset) {\n offset = offset >>> 0;\n $51861dfc7ca9d588$var$validateNumber(offset, 'offset');\n const first = this[offset];\n const last = this[offset + 7];\n if (first === undefined || last === undefined) $51861dfc7ca9d588$var$boundsError(offset, this.length - 8);\n const val = (first << 24) + // Overflow\n this[++offset] * 2 ** 16 + this[++offset] * 256 + this[++offset];\n return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 256 + last);\n});\n$51861dfc7ca9d588$var$Buffer.prototype.readFloatLE = function readFloatLE(offset, noAssert) {\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, 4, this.length);\n return $9NvM5.read(this, offset, true, 23, 4);\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readFloatBE = function readFloatBE(offset, noAssert) {\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, 4, this.length);\n return $9NvM5.read(this, offset, false, 23, 4);\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, 8, this.length);\n return $9NvM5.read(this, offset, true, 52, 8);\n};\n$51861dfc7ca9d588$var$Buffer.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkOffset(offset, 8, this.length);\n return $9NvM5.read(this, offset, false, 52, 8);\n};\nfunction $51861dfc7ca9d588$var$checkInt(buf, value, offset, ext, max, min) {\n if (!$51861dfc7ca9d588$var$Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance');\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds');\n if (offset + ext > buf.length) throw new RangeError('Index out of range');\n}\n$51861dfc7ca9d588$var$Buffer.prototype.writeUintLE = $51861dfc7ca9d588$var$Buffer.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength, noAssert) {\n value = +value;\n offset = offset >>> 0;\n byteLength = byteLength >>> 0;\n if (!noAssert) {\n const maxBytes = Math.pow(2, 8 * byteLength) - 1;\n $51861dfc7ca9d588$var$checkInt(this, value, offset, byteLength, maxBytes, 0);\n }\n let mul = 1;\n let i = 0;\n this[offset] = value & 0xFF;\n while(++i < byteLength && (mul *= 0x100))this[offset + i] = value / mul & 0xFF;\n return offset + byteLength;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.writeUintBE = $51861dfc7ca9d588$var$Buffer.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength, noAssert) {\n value = +value;\n offset = offset >>> 0;\n byteLength = byteLength >>> 0;\n if (!noAssert) {\n const maxBytes = Math.pow(2, 8 * byteLength) - 1;\n $51861dfc7ca9d588$var$checkInt(this, value, offset, byteLength, maxBytes, 0);\n }\n let i = byteLength - 1;\n let mul = 1;\n this[offset + i] = value & 0xFF;\n while(--i >= 0 && (mul *= 0x100))this[offset + i] = value / mul & 0xFF;\n return offset + byteLength;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.writeUint8 = $51861dfc7ca9d588$var$Buffer.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {\n value = +value;\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkInt(this, value, offset, 1, 0xff, 0);\n this[offset] = value & 0xff;\n return offset + 1;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.writeUint16LE = $51861dfc7ca9d588$var$Buffer.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {\n value = +value;\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkInt(this, value, offset, 2, 0xffff, 0);\n this[offset] = value & 0xff;\n this[offset + 1] = value >>> 8;\n return offset + 2;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.writeUint16BE = $51861dfc7ca9d588$var$Buffer.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {\n value = +value;\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkInt(this, value, offset, 2, 0xffff, 0);\n this[offset] = value >>> 8;\n this[offset + 1] = value & 0xff;\n return offset + 2;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.writeUint32LE = $51861dfc7ca9d588$var$Buffer.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {\n value = +value;\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkInt(this, value, offset, 4, 0xffffffff, 0);\n this[offset + 3] = value >>> 24;\n this[offset + 2] = value >>> 16;\n this[offset + 1] = value >>> 8;\n this[offset] = value & 0xff;\n return offset + 4;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.writeUint32BE = $51861dfc7ca9d588$var$Buffer.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {\n value = +value;\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkInt(this, value, offset, 4, 0xffffffff, 0);\n this[offset] = value >>> 24;\n this[offset + 1] = value >>> 16;\n this[offset + 2] = value >>> 8;\n this[offset + 3] = value & 0xff;\n return offset + 4;\n};\nfunction $51861dfc7ca9d588$var$wrtBigUInt64LE(buf, value, offset, min, max) {\n $51861dfc7ca9d588$var$checkIntBI(value, min, max, buf, offset, 7);\n let lo = Number(value & BigInt(0xffffffff));\n buf[offset++] = lo;\n lo = lo >> 8;\n buf[offset++] = lo;\n lo = lo >> 8;\n buf[offset++] = lo;\n lo = lo >> 8;\n buf[offset++] = lo;\n let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));\n buf[offset++] = hi;\n hi = hi >> 8;\n buf[offset++] = hi;\n hi = hi >> 8;\n buf[offset++] = hi;\n hi = hi >> 8;\n buf[offset++] = hi;\n return offset;\n}\nfunction $51861dfc7ca9d588$var$wrtBigUInt64BE(buf, value, offset, min, max) {\n $51861dfc7ca9d588$var$checkIntBI(value, min, max, buf, offset, 7);\n let lo = Number(value & BigInt(0xffffffff));\n buf[offset + 7] = lo;\n lo = lo >> 8;\n buf[offset + 6] = lo;\n lo = lo >> 8;\n buf[offset + 5] = lo;\n lo = lo >> 8;\n buf[offset + 4] = lo;\n let hi = Number(value >> BigInt(32) & BigInt(0xffffffff));\n buf[offset + 3] = hi;\n hi = hi >> 8;\n buf[offset + 2] = hi;\n hi = hi >> 8;\n buf[offset + 1] = hi;\n hi = hi >> 8;\n buf[offset] = hi;\n return offset + 8;\n}\n$51861dfc7ca9d588$var$Buffer.prototype.writeBigUInt64LE = $51861dfc7ca9d588$var$defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {\n return $51861dfc7ca9d588$var$wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'));\n});\n$51861dfc7ca9d588$var$Buffer.prototype.writeBigUInt64BE = $51861dfc7ca9d588$var$defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {\n return $51861dfc7ca9d588$var$wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'));\n});\n$51861dfc7ca9d588$var$Buffer.prototype.writeIntLE = function writeIntLE(value, offset, byteLength, noAssert) {\n value = +value;\n offset = offset >>> 0;\n if (!noAssert) {\n const limit = Math.pow(2, 8 * byteLength - 1);\n $51861dfc7ca9d588$var$checkInt(this, value, offset, byteLength, limit - 1, -limit);\n }\n let i = 0;\n let mul = 1;\n let sub = 0;\n this[offset] = value & 0xFF;\n while(++i < byteLength && (mul *= 0x100)){\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) sub = 1;\n this[offset + i] = (value / mul >> 0) - sub & 0xFF;\n }\n return offset + byteLength;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.writeIntBE = function writeIntBE(value, offset, byteLength, noAssert) {\n value = +value;\n offset = offset >>> 0;\n if (!noAssert) {\n const limit = Math.pow(2, 8 * byteLength - 1);\n $51861dfc7ca9d588$var$checkInt(this, value, offset, byteLength, limit - 1, -limit);\n }\n let i = byteLength - 1;\n let mul = 1;\n let sub = 0;\n this[offset + i] = value & 0xFF;\n while(--i >= 0 && (mul *= 0x100)){\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) sub = 1;\n this[offset + i] = (value / mul >> 0) - sub & 0xFF;\n }\n return offset + byteLength;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {\n value = +value;\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkInt(this, value, offset, 1, 0x7f, -128);\n if (value < 0) value = 0xff + value + 1;\n this[offset] = value & 0xff;\n return offset + 1;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {\n value = +value;\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkInt(this, value, offset, 2, 0x7fff, -32768);\n this[offset] = value & 0xff;\n this[offset + 1] = value >>> 8;\n return offset + 2;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {\n value = +value;\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkInt(this, value, offset, 2, 0x7fff, -32768);\n this[offset] = value >>> 8;\n this[offset + 1] = value & 0xff;\n return offset + 2;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {\n value = +value;\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);\n this[offset] = value & 0xff;\n this[offset + 1] = value >>> 8;\n this[offset + 2] = value >>> 16;\n this[offset + 3] = value >>> 24;\n return offset + 4;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {\n value = +value;\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkInt(this, value, offset, 4, 0x7fffffff, -2147483648);\n if (value < 0) value = 0xffffffff + value + 1;\n this[offset] = value >>> 24;\n this[offset + 1] = value >>> 16;\n this[offset + 2] = value >>> 8;\n this[offset + 3] = value & 0xff;\n return offset + 4;\n};\n$51861dfc7ca9d588$var$Buffer.prototype.writeBigInt64LE = $51861dfc7ca9d588$var$defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {\n return $51861dfc7ca9d588$var$wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'));\n});\n$51861dfc7ca9d588$var$Buffer.prototype.writeBigInt64BE = $51861dfc7ca9d588$var$defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {\n return $51861dfc7ca9d588$var$wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'));\n});\nfunction $51861dfc7ca9d588$var$checkIEEE754(buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range');\n if (offset < 0) throw new RangeError('Index out of range');\n}\nfunction $51861dfc7ca9d588$var$writeFloat(buf, value, offset, littleEndian, noAssert) {\n value = +value;\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -340282346638528860000000000000000000000);\n $9NvM5.write(buf, value, offset, littleEndian, 23, 4);\n return offset + 4;\n}\n$51861dfc7ca9d588$var$Buffer.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {\n return $51861dfc7ca9d588$var$writeFloat(this, value, offset, true, noAssert);\n};\n$51861dfc7ca9d588$var$Buffer.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {\n return $51861dfc7ca9d588$var$writeFloat(this, value, offset, false, noAssert);\n};\nfunction $51861dfc7ca9d588$var$writeDouble(buf, value, offset, littleEndian, noAssert) {\n value = +value;\n offset = offset >>> 0;\n if (!noAssert) $51861dfc7ca9d588$var$checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000);\n $9NvM5.write(buf, value, offset, littleEndian, 52, 8);\n return offset + 8;\n}\n$51861dfc7ca9d588$var$Buffer.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {\n return $51861dfc7ca9d588$var$writeDouble(this, value, offset, true, noAssert);\n};\n$51861dfc7ca9d588$var$Buffer.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {\n return $51861dfc7ca9d588$var$writeDouble(this, value, offset, false, noAssert);\n};\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\n$51861dfc7ca9d588$var$Buffer.prototype.copy = function copy(target, targetStart, start, end) {\n if (!$51861dfc7ca9d588$var$Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer');\n if (!start) start = 0;\n if (!end && end !== 0) end = this.length;\n if (targetStart >= target.length) targetStart = target.length;\n if (!targetStart) targetStart = 0;\n if (end > 0 && end < start) end = start;\n // Copy 0 bytes; we're done\n if (end === start) return 0;\n if (target.length === 0 || this.length === 0) return 0;\n // Fatal error conditions\n if (targetStart < 0) throw new RangeError('targetStart out of bounds');\n if (start < 0 || start >= this.length) throw new RangeError('Index out of range');\n if (end < 0) throw new RangeError('sourceEnd out of bounds');\n // Are we oob?\n if (end > this.length) end = this.length;\n if (target.length - targetStart < end - start) end = target.length - targetStart + start;\n const len = end - start;\n if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') // Use built-in when available, missing from IE11\n this.copyWithin(targetStart, start, end);\n else Uint8Array.prototype.set.call(target, this.subarray(start, end), targetStart);\n return len;\n};\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\n$51861dfc7ca9d588$var$Buffer.prototype.fill = function fill(val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start;\n start = 0;\n end = this.length;\n } else if (typeof end === 'string') {\n encoding = end;\n end = this.length;\n }\n if (encoding !== undefined && typeof encoding !== 'string') throw new TypeError('encoding must be a string');\n if (typeof encoding === 'string' && !$51861dfc7ca9d588$var$Buffer.isEncoding(encoding)) throw new TypeError('Unknown encoding: ' + encoding);\n if (val.length === 1) {\n const code = val.charCodeAt(0);\n if (encoding === 'utf8' && code < 128 || encoding === 'latin1') // Fast path: If `val` fits into a single byte, use that numeric value.\n val = code;\n }\n } else if (typeof val === 'number') val = val & 255;\n else if (typeof val === 'boolean') val = Number(val);\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) throw new RangeError('Out of range index');\n if (end <= start) return this;\n start = start >>> 0;\n end = end === undefined ? this.length : end >>> 0;\n if (!val) val = 0;\n let i;\n if (typeof val === 'number') for(i = start; i < end; ++i)this[i] = val;\n else {\n const bytes = $51861dfc7ca9d588$var$Buffer.isBuffer(val) ? val : $51861dfc7ca9d588$var$Buffer.from(val, encoding);\n const len = bytes.length;\n if (len === 0) throw new TypeError('The value \"' + val + '\" is invalid for argument \"value\"');\n for(i = 0; i < end - start; ++i)this[i + start] = bytes[i % len];\n }\n return this;\n};\n// CUSTOM ERRORS\n// =============\n// Simplified versions from Node, changed for Buffer-only usage\nconst $51861dfc7ca9d588$var$errors = {};\nfunction $51861dfc7ca9d588$var$E(sym, getMessage, Base) {\n $51861dfc7ca9d588$var$errors[sym] = class NodeError extends Base {\n constructor(){\n super();\n Object.defineProperty(this, 'message', {\n value: getMessage.apply(this, arguments),\n writable: true,\n configurable: true\n });\n // Add the error code to the name to include it in the stack trace.\n this.name = `${this.name} [${sym}]`;\n // Access the stack to generate the error message including the error code\n // from the name.\n this.stack // eslint-disable-line no-unused-expressions\n ;\n // Reset the name to the actual name.\n delete this.name;\n }\n get code() {\n return sym;\n }\n set code(value) {\n Object.defineProperty(this, 'code', {\n configurable: true,\n enumerable: true,\n value: value,\n writable: true\n });\n }\n toString() {\n return `${this.name} [${sym}]: ${this.message}`;\n }\n };\n}\n$51861dfc7ca9d588$var$E('ERR_BUFFER_OUT_OF_BOUNDS', function(name) {\n if (name) return `${name} is outside of buffer bounds`;\n return 'Attempt to access memory outside buffer bounds';\n}, RangeError);\n$51861dfc7ca9d588$var$E('ERR_INVALID_ARG_TYPE', function(name, actual) {\n return `The \"${name}\" argument must be of type number. Received type ${typeof actual}`;\n}, TypeError);\n$51861dfc7ca9d588$var$E('ERR_OUT_OF_RANGE', function(str, range, input) {\n let msg = `The value of \"${str}\" is out of range.`;\n let received = input;\n if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) received = $51861dfc7ca9d588$var$addNumericalSeparator(String(input));\n else if (typeof input === 'bigint') {\n received = String(input);\n if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) received = $51861dfc7ca9d588$var$addNumericalSeparator(received);\n received += 'n';\n }\n msg += ` It must be ${range}. Received ${received}`;\n return msg;\n}, RangeError);\nfunction $51861dfc7ca9d588$var$addNumericalSeparator(val) {\n let res = '';\n let i = val.length;\n const start = val[0] === '-' ? 1 : 0;\n for(; i >= start + 4; i -= 3)res = `_${val.slice(i - 3, i)}${res}`;\n return `${val.slice(0, i)}${res}`;\n}\n// CHECK FUNCTIONS\n// ===============\nfunction $51861dfc7ca9d588$var$checkBounds(buf, offset, byteLength) {\n $51861dfc7ca9d588$var$validateNumber(offset, 'offset');\n if (buf[offset] === undefined || buf[offset + byteLength] === undefined) $51861dfc7ca9d588$var$boundsError(offset, buf.length - (byteLength + 1));\n}\nfunction $51861dfc7ca9d588$var$checkIntBI(value, min, max, buf, offset, byteLength) {\n if (value > max || value < min) {\n const n = typeof min === 'bigint' ? 'n' : '';\n let range;\n if (byteLength > 3) {\n if (min === 0 || min === BigInt(0)) range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`;\n else range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` + `${(byteLength + 1) * 8 - 1}${n}`;\n } else range = `>= ${min}${n} and <= ${max}${n}`;\n throw new $51861dfc7ca9d588$var$errors.ERR_OUT_OF_RANGE('value', range, value);\n }\n $51861dfc7ca9d588$var$checkBounds(buf, offset, byteLength);\n}\nfunction $51861dfc7ca9d588$var$validateNumber(value, name) {\n if (typeof value !== 'number') throw new $51861dfc7ca9d588$var$errors.ERR_INVALID_ARG_TYPE(name, 'number', value);\n}\nfunction $51861dfc7ca9d588$var$boundsError(value, length, type) {\n if (Math.floor(value) !== value) {\n $51861dfc7ca9d588$var$validateNumber(value, type);\n throw new $51861dfc7ca9d588$var$errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value);\n }\n if (length < 0) throw new $51861dfc7ca9d588$var$errors.ERR_BUFFER_OUT_OF_BOUNDS();\n throw new $51861dfc7ca9d588$var$errors.ERR_OUT_OF_RANGE(type || 'offset', `>= ${type ? 1 : 0} and <= ${length}`, value);\n}\n// HELPER FUNCTIONS\n// ================\nconst $51861dfc7ca9d588$var$INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;\nfunction $51861dfc7ca9d588$var$base64clean(str) {\n // Node takes equal signs as end of the Base64 encoding\n str = str.split('=')[0];\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = str.trim().replace($51861dfc7ca9d588$var$INVALID_BASE64_RE, '');\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return '';\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while(str.length % 4 !== 0)str = str + '=';\n return str;\n}\nfunction $51861dfc7ca9d588$var$utf8ToBytes(string, units) {\n units = units || Infinity;\n let codePoint;\n const length = string.length;\n let leadSurrogate = null;\n const bytes = [];\n for(let i = 0; i < length; ++i){\n codePoint = string.charCodeAt(i);\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);\n continue;\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);\n continue;\n }\n // valid lead\n leadSurrogate = codePoint;\n continue;\n }\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);\n leadSurrogate = codePoint;\n continue;\n }\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;\n } else if (leadSurrogate) // valid bmp char, but last char was a lead\n {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD);\n }\n leadSurrogate = null;\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break;\n bytes.push(codePoint);\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break;\n bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80);\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break;\n bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break;\n bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);\n } else throw new Error('Invalid code point');\n }\n return bytes;\n}\nfunction $51861dfc7ca9d588$var$asciiToBytes(str) {\n const byteArray = [];\n for(let i = 0; i < str.length; ++i)// Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF);\n return byteArray;\n}\nfunction $51861dfc7ca9d588$var$utf16leToBytes(str, units) {\n let c, hi, lo;\n const byteArray = [];\n for(let i = 0; i < str.length; ++i){\n if ((units -= 2) < 0) break;\n c = str.charCodeAt(i);\n hi = c >> 8;\n lo = c % 256;\n byteArray.push(lo);\n byteArray.push(hi);\n }\n return byteArray;\n}\nfunction $51861dfc7ca9d588$var$base64ToBytes(str) {\n return $kuxul.toByteArray($51861dfc7ca9d588$var$base64clean(str));\n}\nfunction $51861dfc7ca9d588$var$blitBuffer(src, dst, offset, length) {\n let i;\n for(i = 0; i < length; ++i){\n if (i + offset >= dst.length || i >= src.length) break;\n dst[i + offset] = src[i];\n }\n return i;\n}\n// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass\n// the `instanceof` check but they should be treated as of that type.\n// See: https://github.com/feross/buffer/issues/166\nfunction $51861dfc7ca9d588$var$isInstance(obj, type) {\n return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;\n}\nfunction $51861dfc7ca9d588$var$numberIsNaN(obj) {\n // For IE11 support\n return obj !== obj // eslint-disable-line no-self-compare\n ;\n}\n// Create lookup table for `toString('hex')`\n// See: https://github.com/feross/buffer/issues/219\nconst $51861dfc7ca9d588$var$hexSliceLookupTable = function() {\n const alphabet = '0123456789abcdef';\n const table = new Array(256);\n for(let i = 0; i < 16; ++i){\n const i16 = i * 16;\n for(let j = 0; j < 16; ++j)table[i16 + j] = alphabet[i] + alphabet[j];\n }\n return table;\n}();\n// Return not function with Error if BigInt not supported\nfunction $51861dfc7ca9d588$var$defineBigIntMethod(fn) {\n return typeof BigInt === 'undefined' ? $51861dfc7ca9d588$var$BufferBigIntNotDefined : fn;\n}\nfunction $51861dfc7ca9d588$var$BufferBigIntNotDefined() {\n throw new Error('BigInt not supported');\n}\n\n});\nparcelRegister(\"kuxul\", function(module, exports) {\n\n$parcel$export(module.exports, \"toByteArray\", () => $eeb0961446aae8e3$export$d622b2ad8d90c771, (v) => $eeb0961446aae8e3$export$d622b2ad8d90c771 = v);\n$parcel$export(module.exports, \"fromByteArray\", () => $eeb0961446aae8e3$export$6100ba28696e12de, (v) => $eeb0961446aae8e3$export$6100ba28696e12de = v);\nvar $eeb0961446aae8e3$export$a48f0734ac7c2329;\nvar $eeb0961446aae8e3$export$d622b2ad8d90c771;\nvar $eeb0961446aae8e3$export$6100ba28696e12de;\n'use strict';\n$eeb0961446aae8e3$export$a48f0734ac7c2329 = $eeb0961446aae8e3$var$byteLength;\n$eeb0961446aae8e3$export$d622b2ad8d90c771 = $eeb0961446aae8e3$var$toByteArray;\n$eeb0961446aae8e3$export$6100ba28696e12de = $eeb0961446aae8e3$var$fromByteArray;\nvar $eeb0961446aae8e3$var$lookup = [];\nvar $eeb0961446aae8e3$var$revLookup = [];\nvar $eeb0961446aae8e3$var$Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array;\nvar $eeb0961446aae8e3$var$code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nfor(var $eeb0961446aae8e3$var$i = 0, $eeb0961446aae8e3$var$len = $eeb0961446aae8e3$var$code.length; $eeb0961446aae8e3$var$i < $eeb0961446aae8e3$var$len; ++$eeb0961446aae8e3$var$i){\n $eeb0961446aae8e3$var$lookup[$eeb0961446aae8e3$var$i] = $eeb0961446aae8e3$var$code[$eeb0961446aae8e3$var$i];\n $eeb0961446aae8e3$var$revLookup[$eeb0961446aae8e3$var$code.charCodeAt($eeb0961446aae8e3$var$i)] = $eeb0961446aae8e3$var$i;\n}\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\n$eeb0961446aae8e3$var$revLookup['-'.charCodeAt(0)] = 62;\n$eeb0961446aae8e3$var$revLookup['_'.charCodeAt(0)] = 63;\nfunction $eeb0961446aae8e3$var$getLens(b64) {\n var len = b64.length;\n if (len % 4 > 0) throw new Error('Invalid string. Length must be a multiple of 4');\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=');\n if (validLen === -1) validLen = len;\n var placeHoldersLen = validLen === len ? 0 : 4 - validLen % 4;\n return [\n validLen,\n placeHoldersLen\n ];\n}\n// base64 is 4/3 + up to two characters of the original data\nfunction $eeb0961446aae8e3$var$byteLength(b64) {\n var lens = $eeb0961446aae8e3$var$getLens(b64);\n var validLen = lens[0];\n var placeHoldersLen = lens[1];\n return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;\n}\nfunction $eeb0961446aae8e3$var$_byteLength(b64, validLen, placeHoldersLen) {\n return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;\n}\nfunction $eeb0961446aae8e3$var$toByteArray(b64) {\n var tmp;\n var lens = $eeb0961446aae8e3$var$getLens(b64);\n var validLen = lens[0];\n var placeHoldersLen = lens[1];\n var arr = new $eeb0961446aae8e3$var$Arr($eeb0961446aae8e3$var$_byteLength(b64, validLen, placeHoldersLen));\n var curByte = 0;\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0 ? validLen - 4 : validLen;\n var i;\n for(i = 0; i < len; i += 4){\n tmp = $eeb0961446aae8e3$var$revLookup[b64.charCodeAt(i)] << 18 | $eeb0961446aae8e3$var$revLookup[b64.charCodeAt(i + 1)] << 12 | $eeb0961446aae8e3$var$revLookup[b64.charCodeAt(i + 2)] << 6 | $eeb0961446aae8e3$var$revLookup[b64.charCodeAt(i + 3)];\n arr[curByte++] = tmp >> 16 & 0xFF;\n arr[curByte++] = tmp >> 8 & 0xFF;\n arr[curByte++] = tmp & 0xFF;\n }\n if (placeHoldersLen === 2) {\n tmp = $eeb0961446aae8e3$var$revLookup[b64.charCodeAt(i)] << 2 | $eeb0961446aae8e3$var$revLookup[b64.charCodeAt(i + 1)] >> 4;\n arr[curByte++] = tmp & 0xFF;\n }\n if (placeHoldersLen === 1) {\n tmp = $eeb0961446aae8e3$var$revLookup[b64.charCodeAt(i)] << 10 | $eeb0961446aae8e3$var$revLookup[b64.charCodeAt(i + 1)] << 4 | $eeb0961446aae8e3$var$revLookup[b64.charCodeAt(i + 2)] >> 2;\n arr[curByte++] = tmp >> 8 & 0xFF;\n arr[curByte++] = tmp & 0xFF;\n }\n return arr;\n}\nfunction $eeb0961446aae8e3$var$tripletToBase64(num) {\n return $eeb0961446aae8e3$var$lookup[num >> 18 & 0x3F] + $eeb0961446aae8e3$var$lookup[num >> 12 & 0x3F] + $eeb0961446aae8e3$var$lookup[num >> 6 & 0x3F] + $eeb0961446aae8e3$var$lookup[num & 0x3F];\n}\nfunction $eeb0961446aae8e3$var$encodeChunk(uint8, start, end) {\n var tmp;\n var output = [];\n for(var i = start; i < end; i += 3){\n tmp = (uint8[i] << 16 & 0xFF0000) + (uint8[i + 1] << 8 & 0xFF00) + (uint8[i + 2] & 0xFF);\n output.push($eeb0961446aae8e3$var$tripletToBase64(tmp));\n }\n return output.join('');\n}\nfunction $eeb0961446aae8e3$var$fromByteArray(uint8) {\n var tmp;\n var len = uint8.length;\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n ;\n var parts = [];\n var maxChunkLength = 16383 // must be multiple of 3\n ;\n // go through the array every three bytes, we'll deal with trailing stuff later\n for(var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength)parts.push($eeb0961446aae8e3$var$encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1];\n parts.push($eeb0961446aae8e3$var$lookup[tmp >> 2] + $eeb0961446aae8e3$var$lookup[tmp << 4 & 0x3F] + '==');\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1];\n parts.push($eeb0961446aae8e3$var$lookup[tmp >> 10] + $eeb0961446aae8e3$var$lookup[tmp >> 4 & 0x3F] + $eeb0961446aae8e3$var$lookup[tmp << 2 & 0x3F] + '=');\n }\n return parts.join('');\n}\n\n});\n\nparcelRegister(\"9NvM5\", function(module, exports) {\n\n$parcel$export(module.exports, \"read\", () => $7221566bd4d49f44$export$aafa59e2e03f2942, (v) => $7221566bd4d49f44$export$aafa59e2e03f2942 = v);\n$parcel$export(module.exports, \"write\", () => $7221566bd4d49f44$export$68d8715fc104d294, (v) => $7221566bd4d49f44$export$68d8715fc104d294 = v);\n/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ var $7221566bd4d49f44$export$aafa59e2e03f2942;\nvar $7221566bd4d49f44$export$68d8715fc104d294;\n$7221566bd4d49f44$export$aafa59e2e03f2942 = function(buffer, offset, isLE, mLen, nBytes) {\n var e, m;\n var eLen = nBytes * 8 - mLen - 1;\n var eMax = (1 << eLen) - 1;\n var eBias = eMax >> 1;\n var nBits = -7;\n var i = isLE ? nBytes - 1 : 0;\n var d = isLE ? -1 : 1;\n var s = buffer[offset + i];\n i += d;\n e = s & (1 << -nBits) - 1;\n s >>= -nBits;\n nBits += eLen;\n for(; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8);\n m = e & (1 << -nBits) - 1;\n e >>= -nBits;\n nBits += mLen;\n for(; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8);\n if (e === 0) e = 1 - eBias;\n else if (e === eMax) return m ? NaN : (s ? -1 : 1) * Infinity;\n else {\n m = m + Math.pow(2, mLen);\n e = e - eBias;\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen);\n};\n$7221566bd4d49f44$export$68d8715fc104d294 = function(buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c;\n var eLen = nBytes * 8 - mLen - 1;\n var eMax = (1 << eLen) - 1;\n var eBias = eMax >> 1;\n var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;\n var i = isLE ? 0 : nBytes - 1;\n var d = isLE ? 1 : -1;\n var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;\n value = Math.abs(value);\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0;\n e = eMax;\n } else {\n e = Math.floor(Math.log(value) / Math.LN2);\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--;\n c *= 2;\n }\n if (e + eBias >= 1) value += rt / c;\n else value += rt * Math.pow(2, 1 - eBias);\n if (value * c >= 2) {\n e++;\n c /= 2;\n }\n if (e + eBias >= eMax) {\n m = 0;\n e = eMax;\n } else if (e + eBias >= 1) {\n m = (value * c - 1) * Math.pow(2, mLen);\n e = e + eBias;\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);\n e = 0;\n }\n }\n for(; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8);\n e = e << mLen | m;\n eLen += mLen;\n for(; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8);\n buffer[offset + i - d] |= s * 128;\n};\n\n});\n\n\nparcelRegister(\"gNDby\", function(module, exports) {\n\n$parcel$export(module.exports, \"PublicKey\", () => $c3af9e523501759a$export$ca8b6604d6ce14de);\n$parcel$export(module.exports, \"Transaction\", () => $c3af9e523501759a$export$febc5573c75cefb0);\n$parcel$export(module.exports, \"VersionedTransaction\", () => $c3af9e523501759a$export$232cc3f078dcc284);\n\nvar $6ZWSX = parcelRequire(\"6ZWSX\");\n\nvar $kE5x4 = parcelRequire(\"kE5x4\");\n\nvar $dEXSZ = parcelRequire(\"dEXSZ\");\n\nvar $bYkMz = parcelRequire(\"bYkMz\");\n\nvar $6XnWx = parcelRequire(\"6XnWx\");\n\nvar $75BJw = parcelRequire(\"75BJw\");\n\nvar $Q02IV = parcelRequire(\"Q02IV\");\n\nvar $gyRuj = parcelRequire(\"gyRuj\");\n\nvar $5DqgT = parcelRequire(\"5DqgT\");\n\nvar $7pfXJ = parcelRequire(\"7pfXJ\");\n\nvar $ga6mf = parcelRequire(\"ga6mf\");\n\nvar $J0sDk = parcelRequire(\"J0sDk\");\n\nvar $5r7db = parcelRequire(\"5r7db\");\n/**\n * A 64 byte secret key, the first 32 bytes of which is the\n * private scalar and the last 32 bytes is the public key.\n * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/\n */ /**\n * Ed25519 Keypair\n */ const $c3af9e523501759a$var$generatePrivateKey = (0, $kE5x4.ed25519).utils.randomPrivateKey;\nconst $c3af9e523501759a$var$generateKeypair = ()=>{\n const privateScalar = (0, $kE5x4.ed25519).utils.randomPrivateKey();\n const publicKey = $c3af9e523501759a$var$getPublicKey(privateScalar);\n const secretKey = new Uint8Array(64);\n secretKey.set(privateScalar);\n secretKey.set(publicKey, 32);\n return {\n publicKey: publicKey,\n secretKey: secretKey\n };\n};\nconst $c3af9e523501759a$var$getPublicKey = (0, $kE5x4.ed25519).getPublicKey;\nfunction $c3af9e523501759a$var$isOnCurve(publicKey) {\n try {\n (0, $kE5x4.ed25519).ExtendedPoint.fromHex(publicKey);\n return true;\n } catch {\n return false;\n }\n}\nconst $c3af9e523501759a$var$sign = (message, secretKey)=>(0, $kE5x4.ed25519).sign(message, secretKey.slice(0, 32));\nconst $c3af9e523501759a$var$verify = (0, $kE5x4.ed25519).verify;\nconst $c3af9e523501759a$var$toBuffer = (arr)=>{\n if ((0, $6ZWSX.Buffer).isBuffer(arr)) return arr;\n else if (arr instanceof Uint8Array) return (0, $6ZWSX.Buffer).from(arr.buffer, arr.byteOffset, arr.byteLength);\n else return (0, $6ZWSX.Buffer).from(arr);\n};\n// Class wrapping a plain object\nclass $c3af9e523501759a$export$eabc71f011df675a {\n constructor(properties){\n Object.assign(this, properties);\n }\n encode() {\n return (0, $6ZWSX.Buffer).from((0, $75BJw.serialize)($c3af9e523501759a$export$68d13ce9b4cc48f3, this));\n }\n static decode(data) {\n return (0, $75BJw.deserialize)($c3af9e523501759a$export$68d13ce9b4cc48f3, this, data);\n }\n static decodeUnchecked(data) {\n return (0, $75BJw.deserializeUnchecked)($c3af9e523501759a$export$68d13ce9b4cc48f3, this, data);\n }\n}\n// Class representing a Rust-compatible enum, since enums are only strings or\n// numbers in pure JS\nclass $c3af9e523501759a$export$deb82508dd66d288 extends $c3af9e523501759a$export$eabc71f011df675a {\n constructor(properties){\n super(properties);\n this.enum = '';\n if (Object.keys(properties).length !== 1) throw new Error('Enum can only take single value');\n Object.keys(properties).map((key)=>{\n this.enum = key;\n });\n }\n}\nconst $c3af9e523501759a$export$68d13ce9b4cc48f3 = new Map();\nvar $c3af9e523501759a$var$_PublicKey;\n/**\n * Maximum length of derived pubkey seed\n */ const $c3af9e523501759a$export$8240f9da84ad7873 = 32;\n/**\n * Size of public key in bytes\n */ const $c3af9e523501759a$export$84fc0a248cc54343 = 32;\n/**\n * Value to be converted into public key\n */ /**\n * JSON object representation of PublicKey class\n */ function $c3af9e523501759a$var$isPublicKeyData(value) {\n return value._bn !== undefined;\n}\n// local counter used by PublicKey.unique()\nlet $c3af9e523501759a$var$uniquePublicKeyCounter = 1;\n/**\n * A public key\n */ class $c3af9e523501759a$export$ca8b6604d6ce14de extends $c3af9e523501759a$export$eabc71f011df675a {\n /**\n * Create a new PublicKey object\n * @param value ed25519 public key as buffer or base-58 encoded string\n */ constructor(value){\n super({});\n /** @internal */ this._bn = void 0;\n if ($c3af9e523501759a$var$isPublicKeyData(value)) this._bn = value._bn;\n else {\n if (typeof value === 'string') {\n // assume base 58 encoding by default\n const decoded = (0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).decode(value);\n if (decoded.length != $c3af9e523501759a$export$84fc0a248cc54343) throw new Error(`Invalid public key input`);\n this._bn = new (0, (/*@__PURE__*/$parcel$interopDefault($dEXSZ)))(decoded);\n } else this._bn = new (0, (/*@__PURE__*/$parcel$interopDefault($dEXSZ)))(value);\n if (this._bn.byteLength() > $c3af9e523501759a$export$84fc0a248cc54343) throw new Error(`Invalid public key input`);\n }\n }\n /**\n * Returns a unique PublicKey for tests and benchmarks using a counter\n */ static unique() {\n const key = new $c3af9e523501759a$export$ca8b6604d6ce14de($c3af9e523501759a$var$uniquePublicKeyCounter);\n $c3af9e523501759a$var$uniquePublicKeyCounter += 1;\n return new $c3af9e523501759a$export$ca8b6604d6ce14de(key.toBuffer());\n }\n /**\n * Default public key value. The base58-encoded string representation is all ones (as seen below)\n * The underlying BN number is 32 bytes that are all zeros\n */ /**\n * Checks if two publicKeys are equal\n */ equals(publicKey) {\n return this._bn.eq(publicKey._bn);\n }\n /**\n * Return the base-58 representation of the public key\n */ toBase58() {\n return (0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).encode(this.toBytes());\n }\n toJSON() {\n return this.toBase58();\n }\n /**\n * Return the byte array representation of the public key in big endian\n */ toBytes() {\n const buf = this.toBuffer();\n return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);\n }\n /**\n * Return the Buffer representation of the public key in big endian\n */ toBuffer() {\n const b = this._bn.toArrayLike((0, $6ZWSX.Buffer));\n if (b.length === $c3af9e523501759a$export$84fc0a248cc54343) return b;\n const zeroPad = (0, $6ZWSX.Buffer).alloc(32);\n b.copy(zeroPad, 32 - b.length);\n return zeroPad;\n }\n get [Symbol.toStringTag]() {\n return `PublicKey(${this.toString()})`;\n }\n /**\n * Return the base-58 representation of the public key\n */ toString() {\n return this.toBase58();\n }\n /**\n * Derive a public key from another key, a seed, and a program ID.\n * The program ID will also serve as the owner of the public key, giving\n * it permission to write data to the account.\n */ /* eslint-disable require-await */ static async createWithSeed(fromPublicKey, seed, programId) {\n const buffer = (0, $6ZWSX.Buffer).concat([\n fromPublicKey.toBuffer(),\n (0, $6ZWSX.Buffer).from(seed),\n programId.toBuffer()\n ]);\n const publicKeyBytes = (0, $6XnWx.sha256)(buffer);\n return new $c3af9e523501759a$export$ca8b6604d6ce14de(publicKeyBytes);\n }\n /**\n * Derive a program address from seeds and a program ID.\n */ /* eslint-disable require-await */ static createProgramAddressSync(seeds, programId) {\n let buffer = (0, $6ZWSX.Buffer).alloc(0);\n seeds.forEach(function(seed) {\n if (seed.length > $c3af9e523501759a$export$8240f9da84ad7873) throw new TypeError(`Max seed length exceeded`);\n buffer = (0, $6ZWSX.Buffer).concat([\n buffer,\n $c3af9e523501759a$var$toBuffer(seed)\n ]);\n });\n buffer = (0, $6ZWSX.Buffer).concat([\n buffer,\n programId.toBuffer(),\n (0, $6ZWSX.Buffer).from('ProgramDerivedAddress')\n ]);\n const publicKeyBytes = (0, $6XnWx.sha256)(buffer);\n if ($c3af9e523501759a$var$isOnCurve(publicKeyBytes)) throw new Error(`Invalid seeds, address must fall off the curve`);\n return new $c3af9e523501759a$export$ca8b6604d6ce14de(publicKeyBytes);\n }\n /**\n * Async version of createProgramAddressSync\n * For backwards compatibility\n *\n * @deprecated Use {@link createProgramAddressSync} instead\n */ /* eslint-disable require-await */ static async createProgramAddress(seeds, programId) {\n return this.createProgramAddressSync(seeds, programId);\n }\n /**\n * Find a valid program address\n *\n * Valid program addresses must fall off the ed25519 curve. This function\n * iterates a nonce until it finds one that when combined with the seeds\n * results in a valid program address.\n */ static findProgramAddressSync(seeds, programId) {\n let nonce = 255;\n let address;\n while(nonce != 0){\n try {\n const seedsWithNonce = seeds.concat((0, $6ZWSX.Buffer).from([\n nonce\n ]));\n address = this.createProgramAddressSync(seedsWithNonce, programId);\n } catch (err) {\n if (err instanceof TypeError) throw err;\n nonce--;\n continue;\n }\n return [\n address,\n nonce\n ];\n }\n throw new Error(`Unable to find a viable program address nonce`);\n }\n /**\n * Async version of findProgramAddressSync\n * For backwards compatibility\n *\n * @deprecated Use {@link findProgramAddressSync} instead\n */ static async findProgramAddress(seeds, programId) {\n return this.findProgramAddressSync(seeds, programId);\n }\n /**\n * Check that a pubkey is on the ed25519 curve.\n */ static isOnCurve(pubkeyData) {\n const pubkey = new $c3af9e523501759a$export$ca8b6604d6ce14de(pubkeyData);\n return $c3af9e523501759a$var$isOnCurve(pubkey.toBytes());\n }\n}\n$c3af9e523501759a$var$_PublicKey = $c3af9e523501759a$export$ca8b6604d6ce14de;\n$c3af9e523501759a$export$ca8b6604d6ce14de.default = new $c3af9e523501759a$var$_PublicKey('11111111111111111111111111111111');\n$c3af9e523501759a$export$68d13ce9b4cc48f3.set($c3af9e523501759a$export$ca8b6604d6ce14de, {\n kind: 'struct',\n fields: [\n [\n '_bn',\n 'u256'\n ]\n ]\n});\n/**\n * An account key pair (public and secret keys).\n *\n * @deprecated since v1.10.0, please use {@link Keypair} instead.\n */ class $c3af9e523501759a$export$1ed4b10e4aba04a7 {\n /**\n * Create a new Account object\n *\n * If the secretKey parameter is not provided a new key pair is randomly\n * created for the account\n *\n * @param secretKey Secret key for the account\n */ constructor(secretKey){\n /** @internal */ this._publicKey = void 0;\n /** @internal */ this._secretKey = void 0;\n if (secretKey) {\n const secretKeyBuffer = $c3af9e523501759a$var$toBuffer(secretKey);\n if (secretKey.length !== 64) throw new Error('bad secret key size');\n this._publicKey = secretKeyBuffer.slice(32, 64);\n this._secretKey = secretKeyBuffer.slice(0, 32);\n } else {\n this._secretKey = $c3af9e523501759a$var$toBuffer($c3af9e523501759a$var$generatePrivateKey());\n this._publicKey = $c3af9e523501759a$var$toBuffer($c3af9e523501759a$var$getPublicKey(this._secretKey));\n }\n }\n /**\n * The public key for this account\n */ get publicKey() {\n return new $c3af9e523501759a$export$ca8b6604d6ce14de(this._publicKey);\n }\n /**\n * The **unencrypted** secret key for this account. The first 32 bytes\n * is the private scalar and the last 32 bytes is the public key.\n * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/\n */ get secretKey() {\n return (0, $6ZWSX.Buffer).concat([\n this._secretKey,\n this._publicKey\n ], 64);\n }\n}\nconst $c3af9e523501759a$export$42bd37c1c64962b6 = new $c3af9e523501759a$export$ca8b6604d6ce14de('BPFLoader1111111111111111111111111111111111');\n/**\n * Maximum over-the-wire size of a Transaction\n *\n * 1280 is IPv6 minimum MTU\n * 40 bytes is the size of the IPv6 header\n * 8 bytes is the size of the fragment header\n */ const $c3af9e523501759a$export$4c6d5b89e1596f26 = 1232;\nconst $c3af9e523501759a$export$3c3793d809f8b858 = 0x7f;\nconst $c3af9e523501759a$export$14aee086fde78fa6 = 64;\nclass $c3af9e523501759a$export$718fcd78527f88ed extends Error {\n constructor(signature){\n super(`Signature ${signature} has expired: block height exceeded.`);\n this.signature = void 0;\n this.signature = signature;\n }\n}\nObject.defineProperty($c3af9e523501759a$export$718fcd78527f88ed.prototype, 'name', {\n value: 'TransactionExpiredBlockheightExceededError'\n});\nclass $c3af9e523501759a$export$b822204c22e46bdf extends Error {\n constructor(signature, timeoutSeconds){\n super(`Transaction was not confirmed in ${timeoutSeconds.toFixed(2)} seconds. It is ` + 'unknown if it succeeded or failed. Check signature ' + `${signature} using the Solana Explorer or CLI tools.`);\n this.signature = void 0;\n this.signature = signature;\n }\n}\nObject.defineProperty($c3af9e523501759a$export$b822204c22e46bdf.prototype, 'name', {\n value: 'TransactionExpiredTimeoutError'\n});\nclass $c3af9e523501759a$export$a3e7565a95f5a1e5 extends Error {\n constructor(signature){\n super(`Signature ${signature} has expired: the nonce is no longer valid.`);\n this.signature = void 0;\n this.signature = signature;\n }\n}\nObject.defineProperty($c3af9e523501759a$export$a3e7565a95f5a1e5.prototype, 'name', {\n value: 'TransactionExpiredNonceInvalidError'\n});\nclass $c3af9e523501759a$export$109914c107623102 {\n constructor(staticAccountKeys, accountKeysFromLookups){\n this.staticAccountKeys = void 0;\n this.accountKeysFromLookups = void 0;\n this.staticAccountKeys = staticAccountKeys;\n this.accountKeysFromLookups = accountKeysFromLookups;\n }\n keySegments() {\n const keySegments = [\n this.staticAccountKeys\n ];\n if (this.accountKeysFromLookups) {\n keySegments.push(this.accountKeysFromLookups.writable);\n keySegments.push(this.accountKeysFromLookups.readonly);\n }\n return keySegments;\n }\n get(index) {\n for (const keySegment of this.keySegments()){\n if (index < keySegment.length) return keySegment[index];\n else index -= keySegment.length;\n }\n return;\n }\n get length() {\n return this.keySegments().flat().length;\n }\n compileInstructions(instructions) {\n // Bail early if any account indexes would overflow a u8\n const U8_MAX = 255;\n if (this.length > U8_MAX + 1) throw new Error('Account index overflow encountered during compilation');\n const keyIndexMap = new Map();\n this.keySegments().flat().forEach((key, index)=>{\n keyIndexMap.set(key.toBase58(), index);\n });\n const findKeyIndex = (key)=>{\n const keyIndex = keyIndexMap.get(key.toBase58());\n if (keyIndex === undefined) throw new Error('Encountered an unknown instruction account key during compilation');\n return keyIndex;\n };\n return instructions.map((instruction)=>{\n return {\n programIdIndex: findKeyIndex(instruction.programId),\n accountKeyIndexes: instruction.keys.map((meta)=>findKeyIndex(meta.pubkey)),\n data: instruction.data\n };\n });\n }\n}\n/**\n * Layout for a public key\n */ const $c3af9e523501759a$var$publicKey = (property = 'publicKey')=>{\n return $Q02IV.blob(32, property);\n};\n/**\n * Layout for a signature\n */ const $c3af9e523501759a$var$signature = (property = 'signature')=>{\n return $Q02IV.blob(64, property);\n};\n/**\n * Layout for a Rust String type\n */ const $c3af9e523501759a$var$rustString = (property = 'string')=>{\n const rsl = $Q02IV.struct([\n $Q02IV.u32('length'),\n $Q02IV.u32('lengthPadding'),\n $Q02IV.blob($Q02IV.offset($Q02IV.u32(), -8), 'chars')\n ], property);\n const _decode = rsl.decode.bind(rsl);\n const _encode = rsl.encode.bind(rsl);\n const rslShim = rsl;\n rslShim.decode = (b, offset)=>{\n const data = _decode(b, offset);\n return data['chars'].toString();\n };\n rslShim.encode = (str, b, offset)=>{\n const data = {\n chars: (0, $6ZWSX.Buffer).from(str, 'utf8')\n };\n return _encode(data, b, offset);\n };\n rslShim.alloc = (str)=>{\n return $Q02IV.u32().span + $Q02IV.u32().span + (0, $6ZWSX.Buffer).from(str, 'utf8').length;\n };\n return rslShim;\n};\n/**\n * Layout for an Authorized object\n */ const $c3af9e523501759a$var$authorized = (property = 'authorized')=>{\n return $Q02IV.struct([\n $c3af9e523501759a$var$publicKey('staker'),\n $c3af9e523501759a$var$publicKey('withdrawer')\n ], property);\n};\n/**\n * Layout for a Lockup object\n */ const $c3af9e523501759a$var$lockup = (property = 'lockup')=>{\n return $Q02IV.struct([\n $Q02IV.ns64('unixTimestamp'),\n $Q02IV.ns64('epoch'),\n $c3af9e523501759a$var$publicKey('custodian')\n ], property);\n};\n/**\n * Layout for a VoteInit object\n */ const $c3af9e523501759a$var$voteInit = (property = 'voteInit')=>{\n return $Q02IV.struct([\n $c3af9e523501759a$var$publicKey('nodePubkey'),\n $c3af9e523501759a$var$publicKey('authorizedVoter'),\n $c3af9e523501759a$var$publicKey('authorizedWithdrawer'),\n $Q02IV.u8('commission')\n ], property);\n};\n/**\n * Layout for a VoteAuthorizeWithSeedArgs object\n */ const $c3af9e523501759a$var$voteAuthorizeWithSeedArgs = (property = 'voteAuthorizeWithSeedArgs')=>{\n return $Q02IV.struct([\n $Q02IV.u32('voteAuthorizationType'),\n $c3af9e523501759a$var$publicKey('currentAuthorityDerivedKeyOwnerPubkey'),\n $c3af9e523501759a$var$rustString('currentAuthorityDerivedKeySeed'),\n $c3af9e523501759a$var$publicKey('newAuthorized')\n ], property);\n};\nfunction $c3af9e523501759a$var$getAlloc(type, fields) {\n const getItemAlloc = (item)=>{\n if (item.span >= 0) return item.span;\n else if (typeof item.alloc === 'function') return item.alloc(fields[item.property]);\n else if ('count' in item && 'elementLayout' in item) {\n const field = fields[item.property];\n if (Array.isArray(field)) return field.length * getItemAlloc(item.elementLayout);\n } else if ('fields' in item) // This is a `Structure` whose size needs to be recursively measured.\n return $c3af9e523501759a$var$getAlloc({\n layout: item\n }, fields[item.property]);\n // Couldn't determine allocated size of layout\n return 0;\n };\n let alloc = 0;\n type.layout.fields.forEach((item)=>{\n alloc += getItemAlloc(item);\n });\n return alloc;\n}\nfunction $c3af9e523501759a$var$decodeLength(bytes) {\n let len = 0;\n let size = 0;\n for(;;){\n let elem = bytes.shift();\n len |= (elem & 0x7f) << size * 7;\n size += 1;\n if ((elem & 0x80) === 0) break;\n }\n return len;\n}\nfunction $c3af9e523501759a$var$encodeLength(bytes, len) {\n let rem_len = len;\n for(;;){\n let elem = rem_len & 0x7f;\n rem_len >>= 7;\n if (rem_len == 0) {\n bytes.push(elem);\n break;\n } else {\n elem |= 0x80;\n bytes.push(elem);\n }\n }\n}\nfunction $c3af9e523501759a$var$assert(condition, message) {\n if (!condition) throw new Error(message || 'Assertion failed');\n}\nclass $c3af9e523501759a$var$CompiledKeys {\n constructor(payer, keyMetaMap){\n this.payer = void 0;\n this.keyMetaMap = void 0;\n this.payer = payer;\n this.keyMetaMap = keyMetaMap;\n }\n static compile(instructions, payer) {\n const keyMetaMap = new Map();\n const getOrInsertDefault = (pubkey)=>{\n const address = pubkey.toBase58();\n let keyMeta = keyMetaMap.get(address);\n if (keyMeta === undefined) {\n keyMeta = {\n isSigner: false,\n isWritable: false,\n isInvoked: false\n };\n keyMetaMap.set(address, keyMeta);\n }\n return keyMeta;\n };\n const payerKeyMeta = getOrInsertDefault(payer);\n payerKeyMeta.isSigner = true;\n payerKeyMeta.isWritable = true;\n for (const ix of instructions){\n getOrInsertDefault(ix.programId).isInvoked = true;\n for (const accountMeta of ix.keys){\n const keyMeta = getOrInsertDefault(accountMeta.pubkey);\n keyMeta.isSigner ||= accountMeta.isSigner;\n keyMeta.isWritable ||= accountMeta.isWritable;\n }\n }\n return new $c3af9e523501759a$var$CompiledKeys(payer, keyMetaMap);\n }\n getMessageComponents() {\n const mapEntries = [\n ...this.keyMetaMap.entries()\n ];\n $c3af9e523501759a$var$assert(mapEntries.length <= 256, 'Max static account keys length exceeded');\n const writableSigners = mapEntries.filter(([, meta])=>meta.isSigner && meta.isWritable);\n const readonlySigners = mapEntries.filter(([, meta])=>meta.isSigner && !meta.isWritable);\n const writableNonSigners = mapEntries.filter(([, meta])=>!meta.isSigner && meta.isWritable);\n const readonlyNonSigners = mapEntries.filter(([, meta])=>!meta.isSigner && !meta.isWritable);\n const header = {\n numRequiredSignatures: writableSigners.length + readonlySigners.length,\n numReadonlySignedAccounts: readonlySigners.length,\n numReadonlyUnsignedAccounts: readonlyNonSigners.length\n };\n // sanity checks\n {\n $c3af9e523501759a$var$assert(writableSigners.length > 0, 'Expected at least one writable signer key');\n const [payerAddress] = writableSigners[0];\n $c3af9e523501759a$var$assert(payerAddress === this.payer.toBase58(), 'Expected first writable signer key to be the fee payer');\n }\n const staticAccountKeys = [\n ...writableSigners.map(([address])=>new $c3af9e523501759a$export$ca8b6604d6ce14de(address)),\n ...readonlySigners.map(([address])=>new $c3af9e523501759a$export$ca8b6604d6ce14de(address)),\n ...writableNonSigners.map(([address])=>new $c3af9e523501759a$export$ca8b6604d6ce14de(address)),\n ...readonlyNonSigners.map(([address])=>new $c3af9e523501759a$export$ca8b6604d6ce14de(address))\n ];\n return [\n header,\n staticAccountKeys\n ];\n }\n extractTableLookup(lookupTable) {\n const [writableIndexes, drainedWritableKeys] = this.drainKeysFoundInLookupTable(lookupTable.state.addresses, (keyMeta)=>!keyMeta.isSigner && !keyMeta.isInvoked && keyMeta.isWritable);\n const [readonlyIndexes, drainedReadonlyKeys] = this.drainKeysFoundInLookupTable(lookupTable.state.addresses, (keyMeta)=>!keyMeta.isSigner && !keyMeta.isInvoked && !keyMeta.isWritable);\n // Don't extract lookup if no keys were found\n if (writableIndexes.length === 0 && readonlyIndexes.length === 0) return;\n return [\n {\n accountKey: lookupTable.key,\n writableIndexes: writableIndexes,\n readonlyIndexes: readonlyIndexes\n },\n {\n writable: drainedWritableKeys,\n readonly: drainedReadonlyKeys\n }\n ];\n }\n /** @internal */ drainKeysFoundInLookupTable(lookupTableEntries, keyMetaFilter) {\n const lookupTableIndexes = new Array();\n const drainedKeys = new Array();\n for (const [address, keyMeta] of this.keyMetaMap.entries())if (keyMetaFilter(keyMeta)) {\n const key = new $c3af9e523501759a$export$ca8b6604d6ce14de(address);\n const lookupTableIndex = lookupTableEntries.findIndex((entry)=>entry.equals(key));\n if (lookupTableIndex >= 0) {\n $c3af9e523501759a$var$assert(lookupTableIndex < 256, 'Max lookup table index exceeded');\n lookupTableIndexes.push(lookupTableIndex);\n drainedKeys.push(key);\n this.keyMetaMap.delete(address);\n }\n }\n return [\n lookupTableIndexes,\n drainedKeys\n ];\n }\n}\nconst $c3af9e523501759a$var$END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';\n/**\n * Delegates to `Array#shift`, but throws if the array is zero-length.\n */ function $c3af9e523501759a$var$guardedShift(byteArray) {\n if (byteArray.length === 0) throw new Error($c3af9e523501759a$var$END_OF_BUFFER_ERROR_MESSAGE);\n return byteArray.shift();\n}\n/**\n * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of\n * the array.\n */ function $c3af9e523501759a$var$guardedSplice(byteArray, ...args) {\n const [start] = args;\n if (args.length === 2 // Implies that `deleteCount` was supplied\n ? start + (args[1] ?? 0) > byteArray.length : start >= byteArray.length) throw new Error($c3af9e523501759a$var$END_OF_BUFFER_ERROR_MESSAGE);\n return byteArray.splice(...args);\n}\n/**\n * An instruction to execute by a program\n *\n * @property {number} programIdIndex\n * @property {number[]} accounts\n * @property {string} data\n */ /**\n * Message constructor arguments\n */ /**\n * List of instructions to be processed atomically\n */ class $c3af9e523501759a$export$f69c19e57285b83a {\n constructor(args){\n this.header = void 0;\n this.accountKeys = void 0;\n this.recentBlockhash = void 0;\n this.instructions = void 0;\n this.indexToProgramIds = new Map();\n this.header = args.header;\n this.accountKeys = args.accountKeys.map((account)=>new $c3af9e523501759a$export$ca8b6604d6ce14de(account));\n this.recentBlockhash = args.recentBlockhash;\n this.instructions = args.instructions;\n this.instructions.forEach((ix)=>this.indexToProgramIds.set(ix.programIdIndex, this.accountKeys[ix.programIdIndex]));\n }\n get version() {\n return 'legacy';\n }\n get staticAccountKeys() {\n return this.accountKeys;\n }\n get compiledInstructions() {\n return this.instructions.map((ix)=>({\n programIdIndex: ix.programIdIndex,\n accountKeyIndexes: ix.accounts,\n data: (0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).decode(ix.data)\n }));\n }\n get addressTableLookups() {\n return [];\n }\n getAccountKeys() {\n return new $c3af9e523501759a$export$109914c107623102(this.staticAccountKeys);\n }\n static compile(args) {\n const compiledKeys = $c3af9e523501759a$var$CompiledKeys.compile(args.instructions, args.payerKey);\n const [header, staticAccountKeys] = compiledKeys.getMessageComponents();\n const accountKeys = new $c3af9e523501759a$export$109914c107623102(staticAccountKeys);\n const instructions = accountKeys.compileInstructions(args.instructions).map((ix)=>({\n programIdIndex: ix.programIdIndex,\n accounts: ix.accountKeyIndexes,\n data: (0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).encode(ix.data)\n }));\n return new $c3af9e523501759a$export$f69c19e57285b83a({\n header: header,\n accountKeys: staticAccountKeys,\n recentBlockhash: args.recentBlockhash,\n instructions: instructions\n });\n }\n isAccountSigner(index) {\n return index < this.header.numRequiredSignatures;\n }\n isAccountWritable(index) {\n const numSignedAccounts = this.header.numRequiredSignatures;\n if (index >= this.header.numRequiredSignatures) {\n const unsignedAccountIndex = index - numSignedAccounts;\n const numUnsignedAccounts = this.accountKeys.length - numSignedAccounts;\n const numWritableUnsignedAccounts = numUnsignedAccounts - this.header.numReadonlyUnsignedAccounts;\n return unsignedAccountIndex < numWritableUnsignedAccounts;\n } else {\n const numWritableSignedAccounts = numSignedAccounts - this.header.numReadonlySignedAccounts;\n return index < numWritableSignedAccounts;\n }\n }\n isProgramId(index) {\n return this.indexToProgramIds.has(index);\n }\n programIds() {\n return [\n ...this.indexToProgramIds.values()\n ];\n }\n nonProgramIds() {\n return this.accountKeys.filter((_, index)=>!this.isProgramId(index));\n }\n serialize() {\n const numKeys = this.accountKeys.length;\n let keyCount = [];\n $c3af9e523501759a$var$encodeLength(keyCount, numKeys);\n const instructions = this.instructions.map((instruction)=>{\n const { accounts: accounts, programIdIndex: programIdIndex } = instruction;\n const data = Array.from((0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).decode(instruction.data));\n let keyIndicesCount = [];\n $c3af9e523501759a$var$encodeLength(keyIndicesCount, accounts.length);\n let dataCount = [];\n $c3af9e523501759a$var$encodeLength(dataCount, data.length);\n return {\n programIdIndex: programIdIndex,\n keyIndicesCount: (0, $6ZWSX.Buffer).from(keyIndicesCount),\n keyIndices: accounts,\n dataLength: (0, $6ZWSX.Buffer).from(dataCount),\n data: data\n };\n });\n let instructionCount = [];\n $c3af9e523501759a$var$encodeLength(instructionCount, instructions.length);\n let instructionBuffer = (0, $6ZWSX.Buffer).alloc($c3af9e523501759a$export$4c6d5b89e1596f26);\n (0, $6ZWSX.Buffer).from(instructionCount).copy(instructionBuffer);\n let instructionBufferLength = instructionCount.length;\n instructions.forEach((instruction)=>{\n const instructionLayout = $Q02IV.struct([\n $Q02IV.u8('programIdIndex'),\n $Q02IV.blob(instruction.keyIndicesCount.length, 'keyIndicesCount'),\n $Q02IV.seq($Q02IV.u8('keyIndex'), instruction.keyIndices.length, 'keyIndices'),\n $Q02IV.blob(instruction.dataLength.length, 'dataLength'),\n $Q02IV.seq($Q02IV.u8('userdatum'), instruction.data.length, 'data')\n ]);\n const length = instructionLayout.encode(instruction, instructionBuffer, instructionBufferLength);\n instructionBufferLength += length;\n });\n instructionBuffer = instructionBuffer.slice(0, instructionBufferLength);\n const signDataLayout = $Q02IV.struct([\n $Q02IV.blob(1, 'numRequiredSignatures'),\n $Q02IV.blob(1, 'numReadonlySignedAccounts'),\n $Q02IV.blob(1, 'numReadonlyUnsignedAccounts'),\n $Q02IV.blob(keyCount.length, 'keyCount'),\n $Q02IV.seq($c3af9e523501759a$var$publicKey('key'), numKeys, 'keys'),\n $c3af9e523501759a$var$publicKey('recentBlockhash')\n ]);\n const transaction = {\n numRequiredSignatures: (0, $6ZWSX.Buffer).from([\n this.header.numRequiredSignatures\n ]),\n numReadonlySignedAccounts: (0, $6ZWSX.Buffer).from([\n this.header.numReadonlySignedAccounts\n ]),\n numReadonlyUnsignedAccounts: (0, $6ZWSX.Buffer).from([\n this.header.numReadonlyUnsignedAccounts\n ]),\n keyCount: (0, $6ZWSX.Buffer).from(keyCount),\n keys: this.accountKeys.map((key)=>$c3af9e523501759a$var$toBuffer(key.toBytes())),\n recentBlockhash: (0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).decode(this.recentBlockhash)\n };\n let signData = (0, $6ZWSX.Buffer).alloc(2048);\n const length = signDataLayout.encode(transaction, signData);\n instructionBuffer.copy(signData, length);\n return signData.slice(0, length + instructionBuffer.length);\n }\n /**\n * Decode a compiled message into a Message object.\n */ static from(buffer) {\n // Slice up wire data\n let byteArray = [\n ...buffer\n ];\n const numRequiredSignatures = $c3af9e523501759a$var$guardedShift(byteArray);\n if (numRequiredSignatures !== (numRequiredSignatures & $c3af9e523501759a$export$3c3793d809f8b858)) throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');\n const numReadonlySignedAccounts = $c3af9e523501759a$var$guardedShift(byteArray);\n const numReadonlyUnsignedAccounts = $c3af9e523501759a$var$guardedShift(byteArray);\n const accountCount = $c3af9e523501759a$var$decodeLength(byteArray);\n let accountKeys = [];\n for(let i = 0; i < accountCount; i++){\n const account = $c3af9e523501759a$var$guardedSplice(byteArray, 0, $c3af9e523501759a$export$84fc0a248cc54343);\n accountKeys.push(new $c3af9e523501759a$export$ca8b6604d6ce14de((0, $6ZWSX.Buffer).from(account)));\n }\n const recentBlockhash = $c3af9e523501759a$var$guardedSplice(byteArray, 0, $c3af9e523501759a$export$84fc0a248cc54343);\n const instructionCount = $c3af9e523501759a$var$decodeLength(byteArray);\n let instructions = [];\n for(let i = 0; i < instructionCount; i++){\n const programIdIndex = $c3af9e523501759a$var$guardedShift(byteArray);\n const accountCount = $c3af9e523501759a$var$decodeLength(byteArray);\n const accounts = $c3af9e523501759a$var$guardedSplice(byteArray, 0, accountCount);\n const dataLength = $c3af9e523501759a$var$decodeLength(byteArray);\n const dataSlice = $c3af9e523501759a$var$guardedSplice(byteArray, 0, dataLength);\n const data = (0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).encode((0, $6ZWSX.Buffer).from(dataSlice));\n instructions.push({\n programIdIndex: programIdIndex,\n accounts: accounts,\n data: data\n });\n }\n const messageArgs = {\n header: {\n numRequiredSignatures: numRequiredSignatures,\n numReadonlySignedAccounts: numReadonlySignedAccounts,\n numReadonlyUnsignedAccounts: numReadonlyUnsignedAccounts\n },\n recentBlockhash: (0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).encode((0, $6ZWSX.Buffer).from(recentBlockhash)),\n accountKeys: accountKeys,\n instructions: instructions\n };\n return new $c3af9e523501759a$export$f69c19e57285b83a(messageArgs);\n }\n}\n/**\n * Message constructor arguments\n */ class $c3af9e523501759a$export$ee274c70e0fae590 {\n constructor(args){\n this.header = void 0;\n this.staticAccountKeys = void 0;\n this.recentBlockhash = void 0;\n this.compiledInstructions = void 0;\n this.addressTableLookups = void 0;\n this.header = args.header;\n this.staticAccountKeys = args.staticAccountKeys;\n this.recentBlockhash = args.recentBlockhash;\n this.compiledInstructions = args.compiledInstructions;\n this.addressTableLookups = args.addressTableLookups;\n }\n get version() {\n return 0;\n }\n get numAccountKeysFromLookups() {\n let count = 0;\n for (const lookup of this.addressTableLookups)count += lookup.readonlyIndexes.length + lookup.writableIndexes.length;\n return count;\n }\n getAccountKeys(args) {\n let accountKeysFromLookups;\n if (args && 'accountKeysFromLookups' in args && args.accountKeysFromLookups) {\n if (this.numAccountKeysFromLookups != args.accountKeysFromLookups.writable.length + args.accountKeysFromLookups.readonly.length) throw new Error('Failed to get account keys because of a mismatch in the number of account keys from lookups');\n accountKeysFromLookups = args.accountKeysFromLookups;\n } else if (args && 'addressLookupTableAccounts' in args && args.addressLookupTableAccounts) accountKeysFromLookups = this.resolveAddressTableLookups(args.addressLookupTableAccounts);\n else if (this.addressTableLookups.length > 0) throw new Error('Failed to get account keys because address table lookups were not resolved');\n return new $c3af9e523501759a$export$109914c107623102(this.staticAccountKeys, accountKeysFromLookups);\n }\n isAccountSigner(index) {\n return index < this.header.numRequiredSignatures;\n }\n isAccountWritable(index) {\n const numSignedAccounts = this.header.numRequiredSignatures;\n const numStaticAccountKeys = this.staticAccountKeys.length;\n if (index >= numStaticAccountKeys) {\n const lookupAccountKeysIndex = index - numStaticAccountKeys;\n const numWritableLookupAccountKeys = this.addressTableLookups.reduce((count, lookup)=>count + lookup.writableIndexes.length, 0);\n return lookupAccountKeysIndex < numWritableLookupAccountKeys;\n } else if (index >= this.header.numRequiredSignatures) {\n const unsignedAccountIndex = index - numSignedAccounts;\n const numUnsignedAccounts = numStaticAccountKeys - numSignedAccounts;\n const numWritableUnsignedAccounts = numUnsignedAccounts - this.header.numReadonlyUnsignedAccounts;\n return unsignedAccountIndex < numWritableUnsignedAccounts;\n } else {\n const numWritableSignedAccounts = numSignedAccounts - this.header.numReadonlySignedAccounts;\n return index < numWritableSignedAccounts;\n }\n }\n resolveAddressTableLookups(addressLookupTableAccounts) {\n const accountKeysFromLookups = {\n writable: [],\n readonly: []\n };\n for (const tableLookup of this.addressTableLookups){\n const tableAccount = addressLookupTableAccounts.find((account)=>account.key.equals(tableLookup.accountKey));\n if (!tableAccount) throw new Error(`Failed to find address lookup table account for table key ${tableLookup.accountKey.toBase58()}`);\n for (const index of tableLookup.writableIndexes){\n if (index < tableAccount.state.addresses.length) accountKeysFromLookups.writable.push(tableAccount.state.addresses[index]);\n else throw new Error(`Failed to find address for index ${index} in address lookup table ${tableLookup.accountKey.toBase58()}`);\n }\n for (const index of tableLookup.readonlyIndexes){\n if (index < tableAccount.state.addresses.length) accountKeysFromLookups.readonly.push(tableAccount.state.addresses[index]);\n else throw new Error(`Failed to find address for index ${index} in address lookup table ${tableLookup.accountKey.toBase58()}`);\n }\n }\n return accountKeysFromLookups;\n }\n static compile(args) {\n const compiledKeys = $c3af9e523501759a$var$CompiledKeys.compile(args.instructions, args.payerKey);\n const addressTableLookups = new Array();\n const accountKeysFromLookups = {\n writable: new Array(),\n readonly: new Array()\n };\n const lookupTableAccounts = args.addressLookupTableAccounts || [];\n for (const lookupTable of lookupTableAccounts){\n const extractResult = compiledKeys.extractTableLookup(lookupTable);\n if (extractResult !== undefined) {\n const [addressTableLookup, { writable: writable, readonly: readonly }] = extractResult;\n addressTableLookups.push(addressTableLookup);\n accountKeysFromLookups.writable.push(...writable);\n accountKeysFromLookups.readonly.push(...readonly);\n }\n }\n const [header, staticAccountKeys] = compiledKeys.getMessageComponents();\n const accountKeys = new $c3af9e523501759a$export$109914c107623102(staticAccountKeys, accountKeysFromLookups);\n const compiledInstructions = accountKeys.compileInstructions(args.instructions);\n return new $c3af9e523501759a$export$ee274c70e0fae590({\n header: header,\n staticAccountKeys: staticAccountKeys,\n recentBlockhash: args.recentBlockhash,\n compiledInstructions: compiledInstructions,\n addressTableLookups: addressTableLookups\n });\n }\n serialize() {\n const encodedStaticAccountKeysLength = Array();\n $c3af9e523501759a$var$encodeLength(encodedStaticAccountKeysLength, this.staticAccountKeys.length);\n const serializedInstructions = this.serializeInstructions();\n const encodedInstructionsLength = Array();\n $c3af9e523501759a$var$encodeLength(encodedInstructionsLength, this.compiledInstructions.length);\n const serializedAddressTableLookups = this.serializeAddressTableLookups();\n const encodedAddressTableLookupsLength = Array();\n $c3af9e523501759a$var$encodeLength(encodedAddressTableLookupsLength, this.addressTableLookups.length);\n const messageLayout = $Q02IV.struct([\n $Q02IV.u8('prefix'),\n $Q02IV.struct([\n $Q02IV.u8('numRequiredSignatures'),\n $Q02IV.u8('numReadonlySignedAccounts'),\n $Q02IV.u8('numReadonlyUnsignedAccounts')\n ], 'header'),\n $Q02IV.blob(encodedStaticAccountKeysLength.length, 'staticAccountKeysLength'),\n $Q02IV.seq($c3af9e523501759a$var$publicKey(), this.staticAccountKeys.length, 'staticAccountKeys'),\n $c3af9e523501759a$var$publicKey('recentBlockhash'),\n $Q02IV.blob(encodedInstructionsLength.length, 'instructionsLength'),\n $Q02IV.blob(serializedInstructions.length, 'serializedInstructions'),\n $Q02IV.blob(encodedAddressTableLookupsLength.length, 'addressTableLookupsLength'),\n $Q02IV.blob(serializedAddressTableLookups.length, 'serializedAddressTableLookups')\n ]);\n const serializedMessage = new Uint8Array($c3af9e523501759a$export$4c6d5b89e1596f26);\n const MESSAGE_VERSION_0_PREFIX = 128;\n const serializedMessageLength = messageLayout.encode({\n prefix: MESSAGE_VERSION_0_PREFIX,\n header: this.header,\n staticAccountKeysLength: new Uint8Array(encodedStaticAccountKeysLength),\n staticAccountKeys: this.staticAccountKeys.map((key)=>key.toBytes()),\n recentBlockhash: (0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).decode(this.recentBlockhash),\n instructionsLength: new Uint8Array(encodedInstructionsLength),\n serializedInstructions: serializedInstructions,\n addressTableLookupsLength: new Uint8Array(encodedAddressTableLookupsLength),\n serializedAddressTableLookups: serializedAddressTableLookups\n }, serializedMessage);\n return serializedMessage.slice(0, serializedMessageLength);\n }\n serializeInstructions() {\n let serializedLength = 0;\n const serializedInstructions = new Uint8Array($c3af9e523501759a$export$4c6d5b89e1596f26);\n for (const instruction of this.compiledInstructions){\n const encodedAccountKeyIndexesLength = Array();\n $c3af9e523501759a$var$encodeLength(encodedAccountKeyIndexesLength, instruction.accountKeyIndexes.length);\n const encodedDataLength = Array();\n $c3af9e523501759a$var$encodeLength(encodedDataLength, instruction.data.length);\n const instructionLayout = $Q02IV.struct([\n $Q02IV.u8('programIdIndex'),\n $Q02IV.blob(encodedAccountKeyIndexesLength.length, 'encodedAccountKeyIndexesLength'),\n $Q02IV.seq($Q02IV.u8(), instruction.accountKeyIndexes.length, 'accountKeyIndexes'),\n $Q02IV.blob(encodedDataLength.length, 'encodedDataLength'),\n $Q02IV.blob(instruction.data.length, 'data')\n ]);\n serializedLength += instructionLayout.encode({\n programIdIndex: instruction.programIdIndex,\n encodedAccountKeyIndexesLength: new Uint8Array(encodedAccountKeyIndexesLength),\n accountKeyIndexes: instruction.accountKeyIndexes,\n encodedDataLength: new Uint8Array(encodedDataLength),\n data: instruction.data\n }, serializedInstructions, serializedLength);\n }\n return serializedInstructions.slice(0, serializedLength);\n }\n serializeAddressTableLookups() {\n let serializedLength = 0;\n const serializedAddressTableLookups = new Uint8Array($c3af9e523501759a$export$4c6d5b89e1596f26);\n for (const lookup of this.addressTableLookups){\n const encodedWritableIndexesLength = Array();\n $c3af9e523501759a$var$encodeLength(encodedWritableIndexesLength, lookup.writableIndexes.length);\n const encodedReadonlyIndexesLength = Array();\n $c3af9e523501759a$var$encodeLength(encodedReadonlyIndexesLength, lookup.readonlyIndexes.length);\n const addressTableLookupLayout = $Q02IV.struct([\n $c3af9e523501759a$var$publicKey('accountKey'),\n $Q02IV.blob(encodedWritableIndexesLength.length, 'encodedWritableIndexesLength'),\n $Q02IV.seq($Q02IV.u8(), lookup.writableIndexes.length, 'writableIndexes'),\n $Q02IV.blob(encodedReadonlyIndexesLength.length, 'encodedReadonlyIndexesLength'),\n $Q02IV.seq($Q02IV.u8(), lookup.readonlyIndexes.length, 'readonlyIndexes')\n ]);\n serializedLength += addressTableLookupLayout.encode({\n accountKey: lookup.accountKey.toBytes(),\n encodedWritableIndexesLength: new Uint8Array(encodedWritableIndexesLength),\n writableIndexes: lookup.writableIndexes,\n encodedReadonlyIndexesLength: new Uint8Array(encodedReadonlyIndexesLength),\n readonlyIndexes: lookup.readonlyIndexes\n }, serializedAddressTableLookups, serializedLength);\n }\n return serializedAddressTableLookups.slice(0, serializedLength);\n }\n static deserialize(serializedMessage) {\n let byteArray = [\n ...serializedMessage\n ];\n const prefix = $c3af9e523501759a$var$guardedShift(byteArray);\n const maskedPrefix = prefix & $c3af9e523501759a$export$3c3793d809f8b858;\n $c3af9e523501759a$var$assert(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);\n const version = maskedPrefix;\n $c3af9e523501759a$var$assert(version === 0, `Expected versioned message with version 0 but found version ${version}`);\n const header = {\n numRequiredSignatures: $c3af9e523501759a$var$guardedShift(byteArray),\n numReadonlySignedAccounts: $c3af9e523501759a$var$guardedShift(byteArray),\n numReadonlyUnsignedAccounts: $c3af9e523501759a$var$guardedShift(byteArray)\n };\n const staticAccountKeys = [];\n const staticAccountKeysLength = $c3af9e523501759a$var$decodeLength(byteArray);\n for(let i = 0; i < staticAccountKeysLength; i++)staticAccountKeys.push(new $c3af9e523501759a$export$ca8b6604d6ce14de($c3af9e523501759a$var$guardedSplice(byteArray, 0, $c3af9e523501759a$export$84fc0a248cc54343)));\n const recentBlockhash = (0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).encode($c3af9e523501759a$var$guardedSplice(byteArray, 0, $c3af9e523501759a$export$84fc0a248cc54343));\n const instructionCount = $c3af9e523501759a$var$decodeLength(byteArray);\n const compiledInstructions = [];\n for(let i = 0; i < instructionCount; i++){\n const programIdIndex = $c3af9e523501759a$var$guardedShift(byteArray);\n const accountKeyIndexesLength = $c3af9e523501759a$var$decodeLength(byteArray);\n const accountKeyIndexes = $c3af9e523501759a$var$guardedSplice(byteArray, 0, accountKeyIndexesLength);\n const dataLength = $c3af9e523501759a$var$decodeLength(byteArray);\n const data = new Uint8Array($c3af9e523501759a$var$guardedSplice(byteArray, 0, dataLength));\n compiledInstructions.push({\n programIdIndex: programIdIndex,\n accountKeyIndexes: accountKeyIndexes,\n data: data\n });\n }\n const addressTableLookupsCount = $c3af9e523501759a$var$decodeLength(byteArray);\n const addressTableLookups = [];\n for(let i = 0; i < addressTableLookupsCount; i++){\n const accountKey = new $c3af9e523501759a$export$ca8b6604d6ce14de($c3af9e523501759a$var$guardedSplice(byteArray, 0, $c3af9e523501759a$export$84fc0a248cc54343));\n const writableIndexesLength = $c3af9e523501759a$var$decodeLength(byteArray);\n const writableIndexes = $c3af9e523501759a$var$guardedSplice(byteArray, 0, writableIndexesLength);\n const readonlyIndexesLength = $c3af9e523501759a$var$decodeLength(byteArray);\n const readonlyIndexes = $c3af9e523501759a$var$guardedSplice(byteArray, 0, readonlyIndexesLength);\n addressTableLookups.push({\n accountKey: accountKey,\n writableIndexes: writableIndexes,\n readonlyIndexes: readonlyIndexes\n });\n }\n return new $c3af9e523501759a$export$ee274c70e0fae590({\n header: header,\n staticAccountKeys: staticAccountKeys,\n recentBlockhash: recentBlockhash,\n compiledInstructions: compiledInstructions,\n addressTableLookups: addressTableLookups\n });\n }\n}\n// eslint-disable-next-line no-redeclare\nconst $c3af9e523501759a$export$b0a61927d00ede7f = {\n deserializeMessageVersion (serializedMessage) {\n const prefix = serializedMessage[0];\n const maskedPrefix = prefix & $c3af9e523501759a$export$3c3793d809f8b858;\n // if the highest bit of the prefix is not set, the message is not versioned\n if (maskedPrefix === prefix) return 'legacy';\n // the lower 7 bits of the prefix indicate the message version\n return maskedPrefix;\n },\n deserialize: (serializedMessage)=>{\n const version = $c3af9e523501759a$export$b0a61927d00ede7f.deserializeMessageVersion(serializedMessage);\n if (version === 'legacy') return $c3af9e523501759a$export$f69c19e57285b83a.from(serializedMessage);\n if (version === 0) return $c3af9e523501759a$export$ee274c70e0fae590.deserialize(serializedMessage);\n else throw new Error(`Transaction message version ${version} deserialization is not supported`);\n }\n};\n/** @internal */ /**\n * Transaction signature as base-58 encoded string\n */ let $c3af9e523501759a$export$7c391bd3b61d2374 = /*#__PURE__*/ function(TransactionStatus) {\n TransactionStatus[TransactionStatus[\"BLOCKHEIGHT_EXCEEDED\"] = 0] = \"BLOCKHEIGHT_EXCEEDED\";\n TransactionStatus[TransactionStatus[\"PROCESSED\"] = 1] = \"PROCESSED\";\n TransactionStatus[TransactionStatus[\"TIMED_OUT\"] = 2] = \"TIMED_OUT\";\n TransactionStatus[TransactionStatus[\"NONCE_INVALID\"] = 3] = \"NONCE_INVALID\";\n return TransactionStatus;\n}({});\n/**\n * Default (empty) signature\n */ const $c3af9e523501759a$var$DEFAULT_SIGNATURE = (0, $6ZWSX.Buffer).alloc($c3af9e523501759a$export$14aee086fde78fa6).fill(0);\n/**\n * Account metadata used to define instructions\n */ /**\n * List of TransactionInstruction object fields that may be initialized at construction\n */ /**\n * Configuration object for Transaction.serialize()\n */ /**\n * @internal\n */ /**\n * Transaction Instruction class\n */ class $c3af9e523501759a$export$a7a3aa8360ac9f59 {\n constructor(opts){\n /**\n * Public keys to include in this transaction\n * Boolean represents whether this pubkey needs to sign the transaction\n */ this.keys = void 0;\n /**\n * Program Id to execute\n */ this.programId = void 0;\n /**\n * Program input\n */ this.data = (0, $6ZWSX.Buffer).alloc(0);\n this.programId = opts.programId;\n this.keys = opts.keys;\n if (opts.data) this.data = opts.data;\n }\n /**\n * @internal\n */ toJSON() {\n return {\n keys: this.keys.map(({ pubkey: pubkey, isSigner: isSigner, isWritable: isWritable })=>({\n pubkey: pubkey.toJSON(),\n isSigner: isSigner,\n isWritable: isWritable\n })),\n programId: this.programId.toJSON(),\n data: [\n ...this.data\n ]\n };\n }\n}\n/**\n * Pair of signature and corresponding public key\n */ /**\n * List of Transaction object fields that may be initialized at construction\n */ // For backward compatibility; an unfortunate consequence of being\n// forced to over-export types by the documentation generator.\n// See https://github.com/solana-labs/solana/pull/25820\n/**\n * Blockhash-based transactions have a lifetime that are defined by\n * the blockhash they include. Any transaction whose blockhash is\n * too old will be rejected.\n */ /**\n * Use these options to construct a durable nonce transaction.\n */ /**\n * Nonce information to be used to build an offline Transaction.\n */ /**\n * @internal\n */ /**\n * Transaction class\n */ class $c3af9e523501759a$export$febc5573c75cefb0 {\n /**\n * The first (payer) Transaction signature\n *\n * @returns {Buffer | null} Buffer of payer's signature\n */ get signature() {\n if (this.signatures.length > 0) return this.signatures[0].signature;\n return null;\n }\n /**\n * The transaction fee payer\n */ // Construct a transaction with a blockhash and lastValidBlockHeight\n // Construct a transaction using a durable nonce\n /**\n * @deprecated `TransactionCtorFields` has been deprecated and will be removed in a future version.\n * Please supply a `TransactionBlockhashCtor` instead.\n */ /**\n * Construct an empty Transaction\n */ constructor(opts){\n /**\n * Signatures for the transaction. Typically created by invoking the\n * `sign()` method\n */ this.signatures = [];\n this.feePayer = void 0;\n /**\n * The instructions to atomically execute\n */ this.instructions = [];\n /**\n * A recent transaction id. Must be populated by the caller\n */ this.recentBlockhash = void 0;\n /**\n * the last block chain can advance to before tx is declared expired\n * */ this.lastValidBlockHeight = void 0;\n /**\n * Optional Nonce information. If populated, transaction will use a durable\n * Nonce hash instead of a recentBlockhash. Must be populated by the caller\n */ this.nonceInfo = void 0;\n /**\n * If this is a nonce transaction this represents the minimum slot from which\n * to evaluate if the nonce has advanced when attempting to confirm the\n * transaction. This protects against a case where the transaction confirmation\n * logic loads the nonce account from an old slot and assumes the mismatch in\n * nonce value implies that the nonce has been advanced.\n */ this.minNonceContextSlot = void 0;\n /**\n * @internal\n */ this._message = void 0;\n /**\n * @internal\n */ this._json = void 0;\n if (!opts) return;\n if (opts.feePayer) this.feePayer = opts.feePayer;\n if (opts.signatures) this.signatures = opts.signatures;\n if (Object.prototype.hasOwnProperty.call(opts, 'nonceInfo')) {\n const { minContextSlot: minContextSlot, nonceInfo: nonceInfo } = opts;\n this.minNonceContextSlot = minContextSlot;\n this.nonceInfo = nonceInfo;\n } else if (Object.prototype.hasOwnProperty.call(opts, 'lastValidBlockHeight')) {\n const { blockhash: blockhash, lastValidBlockHeight: lastValidBlockHeight } = opts;\n this.recentBlockhash = blockhash;\n this.lastValidBlockHeight = lastValidBlockHeight;\n } else {\n const { recentBlockhash: recentBlockhash, nonceInfo: nonceInfo } = opts;\n if (nonceInfo) this.nonceInfo = nonceInfo;\n this.recentBlockhash = recentBlockhash;\n }\n }\n /**\n * @internal\n */ toJSON() {\n return {\n recentBlockhash: this.recentBlockhash || null,\n feePayer: this.feePayer ? this.feePayer.toJSON() : null,\n nonceInfo: this.nonceInfo ? {\n nonce: this.nonceInfo.nonce,\n nonceInstruction: this.nonceInfo.nonceInstruction.toJSON()\n } : null,\n instructions: this.instructions.map((instruction)=>instruction.toJSON()),\n signers: this.signatures.map(({ publicKey: publicKey })=>{\n return publicKey.toJSON();\n })\n };\n }\n /**\n * Add one or more instructions to this Transaction\n *\n * @param {Array< Transaction | TransactionInstruction | TransactionInstructionCtorFields >} items - Instructions to add to the Transaction\n */ add(...items) {\n if (items.length === 0) throw new Error('No instructions');\n items.forEach((item)=>{\n if ('instructions' in item) this.instructions = this.instructions.concat(item.instructions);\n else if ('data' in item && 'programId' in item && 'keys' in item) this.instructions.push(item);\n else this.instructions.push(new $c3af9e523501759a$export$a7a3aa8360ac9f59(item));\n });\n return this;\n }\n /**\n * Compile transaction data\n */ compileMessage() {\n if (this._message && JSON.stringify(this.toJSON()) === JSON.stringify(this._json)) return this._message;\n let recentBlockhash;\n let instructions;\n if (this.nonceInfo) {\n recentBlockhash = this.nonceInfo.nonce;\n if (this.instructions[0] != this.nonceInfo.nonceInstruction) instructions = [\n this.nonceInfo.nonceInstruction,\n ...this.instructions\n ];\n else instructions = this.instructions;\n } else {\n recentBlockhash = this.recentBlockhash;\n instructions = this.instructions;\n }\n if (!recentBlockhash) throw new Error('Transaction recentBlockhash required');\n if (instructions.length < 1) console.warn('No instructions provided');\n let feePayer;\n if (this.feePayer) feePayer = this.feePayer;\n else if (this.signatures.length > 0 && this.signatures[0].publicKey) // Use implicit fee payer\n feePayer = this.signatures[0].publicKey;\n else throw new Error('Transaction fee payer required');\n for(let i = 0; i < instructions.length; i++){\n if (instructions[i].programId === undefined) throw new Error(`Transaction instruction index ${i} has undefined program id`);\n }\n const programIds = [];\n const accountMetas = [];\n instructions.forEach((instruction)=>{\n instruction.keys.forEach((accountMeta)=>{\n accountMetas.push({\n ...accountMeta\n });\n });\n const programId = instruction.programId.toString();\n if (!programIds.includes(programId)) programIds.push(programId);\n });\n // Append programID account metas\n programIds.forEach((programId)=>{\n accountMetas.push({\n pubkey: new $c3af9e523501759a$export$ca8b6604d6ce14de(programId),\n isSigner: false,\n isWritable: false\n });\n });\n // Cull duplicate account metas\n const uniqueMetas = [];\n accountMetas.forEach((accountMeta)=>{\n const pubkeyString = accountMeta.pubkey.toString();\n const uniqueIndex = uniqueMetas.findIndex((x)=>{\n return x.pubkey.toString() === pubkeyString;\n });\n if (uniqueIndex > -1) {\n uniqueMetas[uniqueIndex].isWritable = uniqueMetas[uniqueIndex].isWritable || accountMeta.isWritable;\n uniqueMetas[uniqueIndex].isSigner = uniqueMetas[uniqueIndex].isSigner || accountMeta.isSigner;\n } else uniqueMetas.push(accountMeta);\n });\n // Sort. Prioritizing first by signer, then by writable\n uniqueMetas.sort(function(x, y) {\n if (x.isSigner !== y.isSigner) // Signers always come before non-signers\n return x.isSigner ? -1 : 1;\n if (x.isWritable !== y.isWritable) // Writable accounts always come before read-only accounts\n return x.isWritable ? -1 : 1;\n // Otherwise, sort by pubkey, stringwise.\n const options = {\n localeMatcher: 'best fit',\n usage: 'sort',\n sensitivity: 'variant',\n ignorePunctuation: false,\n numeric: false,\n caseFirst: 'lower'\n };\n return x.pubkey.toBase58().localeCompare(y.pubkey.toBase58(), 'en', options);\n });\n // Move fee payer to the front\n const feePayerIndex = uniqueMetas.findIndex((x)=>{\n return x.pubkey.equals(feePayer);\n });\n if (feePayerIndex > -1) {\n const [payerMeta] = uniqueMetas.splice(feePayerIndex, 1);\n payerMeta.isSigner = true;\n payerMeta.isWritable = true;\n uniqueMetas.unshift(payerMeta);\n } else uniqueMetas.unshift({\n pubkey: feePayer,\n isSigner: true,\n isWritable: true\n });\n // Disallow unknown signers\n for (const signature of this.signatures){\n const uniqueIndex = uniqueMetas.findIndex((x)=>{\n return x.pubkey.equals(signature.publicKey);\n });\n if (uniqueIndex > -1) {\n if (!uniqueMetas[uniqueIndex].isSigner) {\n uniqueMetas[uniqueIndex].isSigner = true;\n console.warn(\"Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction. This behavior is deprecated and will throw an error in the next major version release.\");\n }\n } else throw new Error(`unknown signer: ${signature.publicKey.toString()}`);\n }\n let numRequiredSignatures = 0;\n let numReadonlySignedAccounts = 0;\n let numReadonlyUnsignedAccounts = 0;\n // Split out signing from non-signing keys and count header values\n const signedKeys = [];\n const unsignedKeys = [];\n uniqueMetas.forEach(({ pubkey: pubkey, isSigner: isSigner, isWritable: isWritable })=>{\n if (isSigner) {\n signedKeys.push(pubkey.toString());\n numRequiredSignatures += 1;\n if (!isWritable) numReadonlySignedAccounts += 1;\n } else {\n unsignedKeys.push(pubkey.toString());\n if (!isWritable) numReadonlyUnsignedAccounts += 1;\n }\n });\n const accountKeys = signedKeys.concat(unsignedKeys);\n const compiledInstructions = instructions.map((instruction)=>{\n const { data: data, programId: programId } = instruction;\n return {\n programIdIndex: accountKeys.indexOf(programId.toString()),\n accounts: instruction.keys.map((meta)=>accountKeys.indexOf(meta.pubkey.toString())),\n data: (0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).encode(data)\n };\n });\n compiledInstructions.forEach((instruction)=>{\n $c3af9e523501759a$var$assert(instruction.programIdIndex >= 0);\n instruction.accounts.forEach((keyIndex)=>$c3af9e523501759a$var$assert(keyIndex >= 0));\n });\n return new $c3af9e523501759a$export$f69c19e57285b83a({\n header: {\n numRequiredSignatures: numRequiredSignatures,\n numReadonlySignedAccounts: numReadonlySignedAccounts,\n numReadonlyUnsignedAccounts: numReadonlyUnsignedAccounts\n },\n accountKeys: accountKeys,\n recentBlockhash: recentBlockhash,\n instructions: compiledInstructions\n });\n }\n /**\n * @internal\n */ _compile() {\n const message = this.compileMessage();\n const signedKeys = message.accountKeys.slice(0, message.header.numRequiredSignatures);\n if (this.signatures.length === signedKeys.length) {\n const valid = this.signatures.every((pair, index)=>{\n return signedKeys[index].equals(pair.publicKey);\n });\n if (valid) return message;\n }\n this.signatures = signedKeys.map((publicKey)=>({\n signature: null,\n publicKey: publicKey\n }));\n return message;\n }\n /**\n * Get a buffer of the Transaction data that need to be covered by signatures\n */ serializeMessage() {\n return this._compile().serialize();\n }\n /**\n * Get the estimated fee associated with a transaction\n *\n * @param {Connection} connection Connection to RPC Endpoint.\n *\n * @returns {Promise} The estimated fee for the transaction\n */ async getEstimatedFee(connection) {\n return (await connection.getFeeForMessage(this.compileMessage())).value;\n }\n /**\n * Specify the public keys which will be used to sign the Transaction.\n * The first signer will be used as the transaction fee payer account.\n *\n * Signatures can be added with either `partialSign` or `addSignature`\n *\n * @deprecated Deprecated since v0.84.0. Only the fee payer needs to be\n * specified and it can be set in the Transaction constructor or with the\n * `feePayer` property.\n */ setSigners(...signers) {\n if (signers.length === 0) throw new Error('No signers');\n const seen = new Set();\n this.signatures = signers.filter((publicKey)=>{\n const key = publicKey.toString();\n if (seen.has(key)) return false;\n else {\n seen.add(key);\n return true;\n }\n }).map((publicKey)=>({\n signature: null,\n publicKey: publicKey\n }));\n }\n /**\n * Sign the Transaction with the specified signers. Multiple signatures may\n * be applied to a Transaction. The first signature is considered \"primary\"\n * and is used identify and confirm transactions.\n *\n * If the Transaction `feePayer` is not set, the first signer will be used\n * as the transaction fee payer account.\n *\n * Transaction fields should not be modified after the first call to `sign`,\n * as doing so may invalidate the signature and cause the Transaction to be\n * rejected.\n *\n * The Transaction must be assigned a valid `recentBlockhash` before invoking this method\n *\n * @param {Array} signers Array of signers that will sign the transaction\n */ sign(...signers) {\n if (signers.length === 0) throw new Error('No signers');\n // Dedupe signers\n const seen = new Set();\n const uniqueSigners = [];\n for (const signer of signers){\n const key = signer.publicKey.toString();\n if (seen.has(key)) continue;\n else {\n seen.add(key);\n uniqueSigners.push(signer);\n }\n }\n this.signatures = uniqueSigners.map((signer)=>({\n signature: null,\n publicKey: signer.publicKey\n }));\n const message = this._compile();\n this._partialSign(message, ...uniqueSigners);\n }\n /**\n * Partially sign a transaction with the specified accounts. All accounts must\n * correspond to either the fee payer or a signer account in the transaction\n * instructions.\n *\n * All the caveats from the `sign` method apply to `partialSign`\n *\n * @param {Array} signers Array of signers that will sign the transaction\n */ partialSign(...signers) {\n if (signers.length === 0) throw new Error('No signers');\n // Dedupe signers\n const seen = new Set();\n const uniqueSigners = [];\n for (const signer of signers){\n const key = signer.publicKey.toString();\n if (seen.has(key)) continue;\n else {\n seen.add(key);\n uniqueSigners.push(signer);\n }\n }\n const message = this._compile();\n this._partialSign(message, ...uniqueSigners);\n }\n /**\n * @internal\n */ _partialSign(message, ...signers) {\n const signData = message.serialize();\n signers.forEach((signer)=>{\n const signature = $c3af9e523501759a$var$sign(signData, signer.secretKey);\n this._addSignature(signer.publicKey, $c3af9e523501759a$var$toBuffer(signature));\n });\n }\n /**\n * Add an externally created signature to a transaction. The public key\n * must correspond to either the fee payer or a signer account in the transaction\n * instructions.\n *\n * @param {PublicKey} pubkey Public key that will be added to the transaction.\n * @param {Buffer} signature An externally created signature to add to the transaction.\n */ addSignature(pubkey, signature) {\n this._compile(); // Ensure signatures array is populated\n this._addSignature(pubkey, signature);\n }\n /**\n * @internal\n */ _addSignature(pubkey, signature) {\n $c3af9e523501759a$var$assert(signature.length === 64);\n const index = this.signatures.findIndex((sigpair)=>pubkey.equals(sigpair.publicKey));\n if (index < 0) throw new Error(`unknown signer: ${pubkey.toString()}`);\n this.signatures[index].signature = (0, $6ZWSX.Buffer).from(signature);\n }\n /**\n * Verify signatures of a Transaction\n * Optional parameter specifies if we're expecting a fully signed Transaction or a partially signed one.\n * If no boolean is provided, we expect a fully signed Transaction by default.\n *\n * @param {boolean} [requireAllSignatures=true] Require a fully signed Transaction\n */ verifySignatures(requireAllSignatures = true) {\n const signatureErrors = this._getMessageSignednessErrors(this.serializeMessage(), requireAllSignatures);\n return !signatureErrors;\n }\n /**\n * @internal\n */ _getMessageSignednessErrors(message, requireAllSignatures) {\n const errors = {};\n for (const { signature: signature, publicKey: publicKey } of this.signatures){\n if (signature === null) {\n if (requireAllSignatures) (errors.missing ||= []).push(publicKey);\n } else if (!$c3af9e523501759a$var$verify(signature, message, publicKey.toBytes())) (errors.invalid ||= []).push(publicKey);\n }\n return errors.invalid || errors.missing ? errors : undefined;\n }\n /**\n * Serialize the Transaction in the wire format.\n *\n * @param {Buffer} [config] Config of transaction.\n *\n * @returns {Buffer} Signature of transaction in wire format.\n */ serialize(config) {\n const { requireAllSignatures: requireAllSignatures, verifySignatures: verifySignatures } = Object.assign({\n requireAllSignatures: true,\n verifySignatures: true\n }, config);\n const signData = this.serializeMessage();\n if (verifySignatures) {\n const sigErrors = this._getMessageSignednessErrors(signData, requireAllSignatures);\n if (sigErrors) {\n let errorMessage = 'Signature verification failed.';\n if (sigErrors.invalid) errorMessage += `\\nInvalid signature for public key${sigErrors.invalid.length === 1 ? '' : '(s)'} [\\`${sigErrors.invalid.map((p)=>p.toBase58()).join('`, `')}\\`].`;\n if (sigErrors.missing) errorMessage += `\\nMissing signature for public key${sigErrors.missing.length === 1 ? '' : '(s)'} [\\`${sigErrors.missing.map((p)=>p.toBase58()).join('`, `')}\\`].`;\n throw new Error(errorMessage);\n }\n }\n return this._serialize(signData);\n }\n /**\n * @internal\n */ _serialize(signData) {\n const { signatures: signatures } = this;\n const signatureCount = [];\n $c3af9e523501759a$var$encodeLength(signatureCount, signatures.length);\n const transactionLength = signatureCount.length + signatures.length * 64 + signData.length;\n const wireTransaction = (0, $6ZWSX.Buffer).alloc(transactionLength);\n $c3af9e523501759a$var$assert(signatures.length < 256);\n (0, $6ZWSX.Buffer).from(signatureCount).copy(wireTransaction, 0);\n signatures.forEach(({ signature: signature }, index)=>{\n if (signature !== null) {\n $c3af9e523501759a$var$assert(signature.length === 64, `signature has invalid length`);\n (0, $6ZWSX.Buffer).from(signature).copy(wireTransaction, signatureCount.length + index * 64);\n }\n });\n signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);\n $c3af9e523501759a$var$assert(wireTransaction.length <= $c3af9e523501759a$export$4c6d5b89e1596f26, `Transaction too large: ${wireTransaction.length} > ${$c3af9e523501759a$export$4c6d5b89e1596f26}`);\n return wireTransaction;\n }\n /**\n * Deprecated method\n * @internal\n */ get keys() {\n $c3af9e523501759a$var$assert(this.instructions.length === 1);\n return this.instructions[0].keys.map((keyObj)=>keyObj.pubkey);\n }\n /**\n * Deprecated method\n * @internal\n */ get programId() {\n $c3af9e523501759a$var$assert(this.instructions.length === 1);\n return this.instructions[0].programId;\n }\n /**\n * Deprecated method\n * @internal\n */ get data() {\n $c3af9e523501759a$var$assert(this.instructions.length === 1);\n return this.instructions[0].data;\n }\n /**\n * Parse a wire transaction into a Transaction object.\n *\n * @param {Buffer | Uint8Array | Array} buffer Signature of wire Transaction\n *\n * @returns {Transaction} Transaction associated with the signature\n */ static from(buffer) {\n // Slice up wire data\n let byteArray = [\n ...buffer\n ];\n const signatureCount = $c3af9e523501759a$var$decodeLength(byteArray);\n let signatures = [];\n for(let i = 0; i < signatureCount; i++){\n const signature = $c3af9e523501759a$var$guardedSplice(byteArray, 0, $c3af9e523501759a$export$14aee086fde78fa6);\n signatures.push((0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).encode((0, $6ZWSX.Buffer).from(signature)));\n }\n return $c3af9e523501759a$export$febc5573c75cefb0.populate($c3af9e523501759a$export$f69c19e57285b83a.from(byteArray), signatures);\n }\n /**\n * Populate Transaction object from message and signatures\n *\n * @param {Message} message Message of transaction\n * @param {Array} signatures List of signatures to assign to the transaction\n *\n * @returns {Transaction} The populated Transaction\n */ static populate(message, signatures = []) {\n const transaction = new $c3af9e523501759a$export$febc5573c75cefb0();\n transaction.recentBlockhash = message.recentBlockhash;\n if (message.header.numRequiredSignatures > 0) transaction.feePayer = message.accountKeys[0];\n signatures.forEach((signature, index)=>{\n const sigPubkeyPair = {\n signature: signature == (0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).encode($c3af9e523501759a$var$DEFAULT_SIGNATURE) ? null : (0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).decode(signature),\n publicKey: message.accountKeys[index]\n };\n transaction.signatures.push(sigPubkeyPair);\n });\n message.instructions.forEach((instruction)=>{\n const keys = instruction.accounts.map((account)=>{\n const pubkey = message.accountKeys[account];\n return {\n pubkey: pubkey,\n isSigner: transaction.signatures.some((keyObj)=>keyObj.publicKey.toString() === pubkey.toString()) || message.isAccountSigner(account),\n isWritable: message.isAccountWritable(account)\n };\n });\n transaction.instructions.push(new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n keys: keys,\n programId: message.accountKeys[instruction.programIdIndex],\n data: (0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).decode(instruction.data)\n }));\n });\n transaction._message = message;\n transaction._json = transaction.toJSON();\n return transaction;\n }\n}\nclass $c3af9e523501759a$export$eb15f3e001dd262d {\n constructor(args){\n this.payerKey = void 0;\n this.instructions = void 0;\n this.recentBlockhash = void 0;\n this.payerKey = args.payerKey;\n this.instructions = args.instructions;\n this.recentBlockhash = args.recentBlockhash;\n }\n static decompile(message, args) {\n const { header: header, compiledInstructions: compiledInstructions, recentBlockhash: recentBlockhash } = message;\n const { numRequiredSignatures: numRequiredSignatures, numReadonlySignedAccounts: numReadonlySignedAccounts, numReadonlyUnsignedAccounts: numReadonlyUnsignedAccounts } = header;\n const numWritableSignedAccounts = numRequiredSignatures - numReadonlySignedAccounts;\n $c3af9e523501759a$var$assert(numWritableSignedAccounts > 0, 'Message header is invalid');\n const numWritableUnsignedAccounts = message.staticAccountKeys.length - numRequiredSignatures - numReadonlyUnsignedAccounts;\n $c3af9e523501759a$var$assert(numWritableUnsignedAccounts >= 0, 'Message header is invalid');\n const accountKeys = message.getAccountKeys(args);\n const payerKey = accountKeys.get(0);\n if (payerKey === undefined) throw new Error('Failed to decompile message because no account keys were found');\n const instructions = [];\n for (const compiledIx of compiledInstructions){\n const keys = [];\n for (const keyIndex of compiledIx.accountKeyIndexes){\n const pubkey = accountKeys.get(keyIndex);\n if (pubkey === undefined) throw new Error(`Failed to find key for account key index ${keyIndex}`);\n const isSigner = keyIndex < numRequiredSignatures;\n let isWritable;\n if (isSigner) isWritable = keyIndex < numWritableSignedAccounts;\n else if (keyIndex < accountKeys.staticAccountKeys.length) isWritable = keyIndex - numRequiredSignatures < numWritableUnsignedAccounts;\n else isWritable = keyIndex - accountKeys.staticAccountKeys.length < // accountKeysFromLookups cannot be undefined because we already found a pubkey for this index above\n accountKeys.accountKeysFromLookups.writable.length;\n keys.push({\n pubkey: pubkey,\n isSigner: keyIndex < header.numRequiredSignatures,\n isWritable: isWritable\n });\n }\n const programId = accountKeys.get(compiledIx.programIdIndex);\n if (programId === undefined) throw new Error(`Failed to find program id for program id index ${compiledIx.programIdIndex}`);\n instructions.push(new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n programId: programId,\n data: $c3af9e523501759a$var$toBuffer(compiledIx.data),\n keys: keys\n }));\n }\n return new $c3af9e523501759a$export$eb15f3e001dd262d({\n payerKey: payerKey,\n instructions: instructions,\n recentBlockhash: recentBlockhash\n });\n }\n compileToLegacyMessage() {\n return $c3af9e523501759a$export$f69c19e57285b83a.compile({\n payerKey: this.payerKey,\n recentBlockhash: this.recentBlockhash,\n instructions: this.instructions\n });\n }\n compileToV0Message(addressLookupTableAccounts) {\n return $c3af9e523501759a$export$ee274c70e0fae590.compile({\n payerKey: this.payerKey,\n recentBlockhash: this.recentBlockhash,\n instructions: this.instructions,\n addressLookupTableAccounts: addressLookupTableAccounts\n });\n }\n}\n/**\n * Versioned transaction class\n */ class $c3af9e523501759a$export$232cc3f078dcc284 {\n get version() {\n return this.message.version;\n }\n constructor(message, signatures){\n this.signatures = void 0;\n this.message = void 0;\n if (signatures !== undefined) {\n $c3af9e523501759a$var$assert(signatures.length === message.header.numRequiredSignatures, 'Expected signatures length to be equal to the number of required signatures');\n this.signatures = signatures;\n } else {\n const defaultSignatures = [];\n for(let i = 0; i < message.header.numRequiredSignatures; i++)defaultSignatures.push(new Uint8Array($c3af9e523501759a$export$14aee086fde78fa6));\n this.signatures = defaultSignatures;\n }\n this.message = message;\n }\n serialize() {\n const serializedMessage = this.message.serialize();\n const encodedSignaturesLength = Array();\n $c3af9e523501759a$var$encodeLength(encodedSignaturesLength, this.signatures.length);\n const transactionLayout = $Q02IV.struct([\n $Q02IV.blob(encodedSignaturesLength.length, 'encodedSignaturesLength'),\n $Q02IV.seq($c3af9e523501759a$var$signature(), this.signatures.length, 'signatures'),\n $Q02IV.blob(serializedMessage.length, 'serializedMessage')\n ]);\n const serializedTransaction = new Uint8Array(2048);\n const serializedTransactionLength = transactionLayout.encode({\n encodedSignaturesLength: new Uint8Array(encodedSignaturesLength),\n signatures: this.signatures,\n serializedMessage: serializedMessage\n }, serializedTransaction);\n return serializedTransaction.slice(0, serializedTransactionLength);\n }\n static deserialize(serializedTransaction) {\n let byteArray = [\n ...serializedTransaction\n ];\n const signatures = [];\n const signaturesLength = $c3af9e523501759a$var$decodeLength(byteArray);\n for(let i = 0; i < signaturesLength; i++)signatures.push(new Uint8Array($c3af9e523501759a$var$guardedSplice(byteArray, 0, $c3af9e523501759a$export$14aee086fde78fa6)));\n const message = $c3af9e523501759a$export$b0a61927d00ede7f.deserialize(new Uint8Array(byteArray));\n return new $c3af9e523501759a$export$232cc3f078dcc284(message, signatures);\n }\n sign(signers) {\n const messageData = this.message.serialize();\n const signerPubkeys = this.message.staticAccountKeys.slice(0, this.message.header.numRequiredSignatures);\n for (const signer of signers){\n const signerIndex = signerPubkeys.findIndex((pubkey)=>pubkey.equals(signer.publicKey));\n $c3af9e523501759a$var$assert(signerIndex >= 0, `Cannot sign with non signer key ${signer.publicKey.toBase58()}`);\n this.signatures[signerIndex] = $c3af9e523501759a$var$sign(messageData, signer.secretKey);\n }\n }\n addSignature(publicKey, signature) {\n $c3af9e523501759a$var$assert(signature.byteLength === 64, 'Signature must be 64 bytes long');\n const signerPubkeys = this.message.staticAccountKeys.slice(0, this.message.header.numRequiredSignatures);\n const signerIndex = signerPubkeys.findIndex((pubkey)=>pubkey.equals(publicKey));\n $c3af9e523501759a$var$assert(signerIndex >= 0, `Can not add signature; \\`${publicKey.toBase58()}\\` is not required to sign this transaction`);\n this.signatures[signerIndex] = signature;\n }\n}\n// TODO: These constants should be removed in favor of reading them out of a\n// Syscall account\n/**\n * @internal\n */ const $c3af9e523501759a$var$NUM_TICKS_PER_SECOND = 160;\n/**\n * @internal\n */ const $c3af9e523501759a$var$DEFAULT_TICKS_PER_SLOT = 64;\n/**\n * @internal\n */ const $c3af9e523501759a$var$NUM_SLOTS_PER_SECOND = $c3af9e523501759a$var$NUM_TICKS_PER_SECOND / $c3af9e523501759a$var$DEFAULT_TICKS_PER_SLOT;\n/**\n * @internal\n */ const $c3af9e523501759a$var$MS_PER_SLOT = 1000 / $c3af9e523501759a$var$NUM_SLOTS_PER_SECOND;\nconst $c3af9e523501759a$export$393aa1412d47050e = new $c3af9e523501759a$export$ca8b6604d6ce14de('SysvarC1ock11111111111111111111111111111111');\nconst $c3af9e523501759a$export$2b71d479444d2f4 = new $c3af9e523501759a$export$ca8b6604d6ce14de('SysvarEpochSchedu1e111111111111111111111111');\nconst $c3af9e523501759a$export$54419cc1a3ece8d6 = new $c3af9e523501759a$export$ca8b6604d6ce14de('Sysvar1nstructions1111111111111111111111111');\nconst $c3af9e523501759a$export$e74201139e9833db = new $c3af9e523501759a$export$ca8b6604d6ce14de('SysvarRecentB1ockHashes11111111111111111111');\nconst $c3af9e523501759a$export$970d0190cdb3a8e9 = new $c3af9e523501759a$export$ca8b6604d6ce14de('SysvarRent111111111111111111111111111111111');\nconst $c3af9e523501759a$export$da3b38d796bc1af1 = new $c3af9e523501759a$export$ca8b6604d6ce14de('SysvarRewards111111111111111111111111111111');\nconst $c3af9e523501759a$export$7b3a057916a4a7ae = new $c3af9e523501759a$export$ca8b6604d6ce14de('SysvarS1otHashes111111111111111111111111111');\nconst $c3af9e523501759a$export$3272815bf0633907 = new $c3af9e523501759a$export$ca8b6604d6ce14de('SysvarS1otHistory11111111111111111111111111');\nconst $c3af9e523501759a$export$ca994171317280ea = new $c3af9e523501759a$export$ca8b6604d6ce14de('SysvarStakeHistory1111111111111111111111111');\nclass $c3af9e523501759a$export$121e803f723b3045 extends Error {\n constructor({ action: action, signature: signature, transactionMessage: transactionMessage, logs: logs }){\n const maybeLogsOutput = logs ? `Logs: \\n${JSON.stringify(logs.slice(-10), null, 2)}. ` : '';\n const guideText = '\\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.';\n let message;\n switch(action){\n case 'send':\n message = `Transaction ${signature} resulted in an error. \\n` + `${transactionMessage}. ` + maybeLogsOutput + guideText;\n break;\n case 'simulate':\n message = `Simulation failed. \\nMessage: ${transactionMessage}. \\n` + maybeLogsOutput + guideText;\n break;\n default:\n message = `Unknown action '${((a)=>a)(action)}'`;\n }\n super(message);\n this.signature = void 0;\n this.transactionMessage = void 0;\n this.transactionLogs = void 0;\n this.signature = signature;\n this.transactionMessage = transactionMessage;\n this.transactionLogs = logs ? logs : undefined;\n }\n get transactionError() {\n return {\n message: this.transactionMessage,\n logs: Array.isArray(this.transactionLogs) ? this.transactionLogs : undefined\n };\n }\n /* @deprecated Use `await getLogs()` instead */ get logs() {\n const cachedLogs = this.transactionLogs;\n if (cachedLogs != null && typeof cachedLogs === 'object' && 'then' in cachedLogs) return undefined;\n return cachedLogs;\n }\n async getLogs(connection) {\n if (!Array.isArray(this.transactionLogs)) this.transactionLogs = new Promise((resolve, reject)=>{\n connection.getTransaction(this.signature).then((tx)=>{\n if (tx && tx.meta && tx.meta.logMessages) {\n const logs = tx.meta.logMessages;\n this.transactionLogs = logs;\n resolve(logs);\n } else reject(new Error('Log messages not found'));\n }).catch(reject);\n });\n return await this.transactionLogs;\n }\n}\n// Keep in sync with client/src/rpc_custom_errors.rs\n// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/\nconst $c3af9e523501759a$export$e5e9869922dd22f8 = {\n JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001,\n JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002,\n JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003,\n JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004,\n JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005,\n JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006,\n JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007,\n JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008,\n JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009,\n JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010,\n JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011,\n JSON_RPC_SCAN_ERROR: -32012,\n JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013,\n JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014,\n JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015,\n JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016\n};\nclass $c3af9e523501759a$export$ea1b1a1bba5c14ad extends Error {\n constructor({ code: code, message: message, data: data }, customMessage){\n super(customMessage != null ? `${customMessage}: ${message}` : message);\n this.code = void 0;\n this.data = void 0;\n this.code = code;\n this.data = data;\n this.name = 'SolanaJSONRPCError';\n }\n}\n/**\n * Sign, send and confirm a transaction.\n *\n * If `commitment` option is not specified, defaults to 'max' commitment.\n *\n * @param {Connection} connection\n * @param {Transaction} transaction\n * @param {Array} signers\n * @param {ConfirmOptions} [options]\n * @returns {Promise}\n */ async function $c3af9e523501759a$export$4ad6fe6dae0b6bc3(connection, transaction, signers, options) {\n const sendOptions = options && {\n skipPreflight: options.skipPreflight,\n preflightCommitment: options.preflightCommitment || options.commitment,\n maxRetries: options.maxRetries,\n minContextSlot: options.minContextSlot\n };\n const signature = await connection.sendTransaction(transaction, signers, sendOptions);\n let status;\n if (transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null) status = (await connection.confirmTransaction({\n abortSignal: options?.abortSignal,\n signature: signature,\n blockhash: transaction.recentBlockhash,\n lastValidBlockHeight: transaction.lastValidBlockHeight\n }, options && options.commitment)).value;\n else if (transaction.minNonceContextSlot != null && transaction.nonceInfo != null) {\n const { nonceInstruction: nonceInstruction } = transaction.nonceInfo;\n const nonceAccountPubkey = nonceInstruction.keys[0].pubkey;\n status = (await connection.confirmTransaction({\n abortSignal: options?.abortSignal,\n minContextSlot: transaction.minNonceContextSlot,\n nonceAccountPubkey: nonceAccountPubkey,\n nonceValue: transaction.nonceInfo.nonce,\n signature: signature\n }, options && options.commitment)).value;\n } else {\n if (options?.abortSignal != null) console.warn(\"sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` or a combination of `nonceInfo` and `minNonceContextSlot` are abortable.\");\n status = (await connection.confirmTransaction(signature, options && options.commitment)).value;\n }\n if (status.err) {\n if (signature != null) throw new $c3af9e523501759a$export$121e803f723b3045({\n action: 'send',\n signature: signature,\n transactionMessage: `Status: (${JSON.stringify(status)})`\n });\n throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);\n }\n return signature;\n}\n// zzz\nfunction $c3af9e523501759a$var$sleep(ms) {\n return new Promise((resolve)=>setTimeout(resolve, ms));\n}\n/**\n * @internal\n */ /**\n * Populate a buffer of instruction data using an InstructionType\n * @internal\n */ function $c3af9e523501759a$var$encodeData(type, fields) {\n const allocLength = type.layout.span >= 0 ? type.layout.span : $c3af9e523501759a$var$getAlloc(type, fields);\n const data = (0, $6ZWSX.Buffer).alloc(allocLength);\n const layoutFields = Object.assign({\n instruction: type.index\n }, fields);\n type.layout.encode(layoutFields, data);\n return data;\n}\n/**\n * Decode instruction data buffer using an InstructionType\n * @internal\n */ function $c3af9e523501759a$var$decodeData$1(type, buffer) {\n let data;\n try {\n data = type.layout.decode(buffer);\n } catch (err) {\n throw new Error('invalid instruction; ' + err);\n }\n if (data.instruction !== type.index) throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);\n return data;\n}\n/**\n * https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11\n *\n * @internal\n */ const $c3af9e523501759a$export$d1cc579b1c48f515 = $Q02IV.nu64('lamportsPerSignature');\n/**\n * Calculator for transaction fees.\n *\n * @deprecated Deprecated since Solana v1.8.0.\n */ /**\n * See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32\n *\n * @internal\n */ const $c3af9e523501759a$var$NonceAccountLayout = $Q02IV.struct([\n $Q02IV.u32('version'),\n $Q02IV.u32('state'),\n $c3af9e523501759a$var$publicKey('authorizedPubkey'),\n $c3af9e523501759a$var$publicKey('nonce'),\n $Q02IV.struct([\n $c3af9e523501759a$export$d1cc579b1c48f515\n ], 'feeCalculator')\n]);\nconst $c3af9e523501759a$export$7126250b6d8bd94a = $c3af9e523501759a$var$NonceAccountLayout.span;\n/**\n * A durable nonce is a 32 byte value encoded as a base58 string.\n */ /**\n * NonceAccount class\n */ class $c3af9e523501759a$export$ed1c2356ce604759 {\n /**\n * @internal\n */ constructor(args){\n this.authorizedPubkey = void 0;\n this.nonce = void 0;\n this.feeCalculator = void 0;\n this.authorizedPubkey = args.authorizedPubkey;\n this.nonce = args.nonce;\n this.feeCalculator = args.feeCalculator;\n }\n /**\n * Deserialize NonceAccount from the account data.\n *\n * @param buffer account data\n * @return NonceAccount\n */ static fromAccountData(buffer) {\n const nonceAccount = $c3af9e523501759a$var$NonceAccountLayout.decode($c3af9e523501759a$var$toBuffer(buffer), 0);\n return new $c3af9e523501759a$export$ed1c2356ce604759({\n authorizedPubkey: new $c3af9e523501759a$export$ca8b6604d6ce14de(nonceAccount.authorizedPubkey),\n nonce: new $c3af9e523501759a$export$ca8b6604d6ce14de(nonceAccount.nonce).toString(),\n feeCalculator: nonceAccount.feeCalculator\n });\n }\n}\nconst $c3af9e523501759a$var$encodeDecode = (layout)=>{\n const decode = layout.decode.bind(layout);\n const encode = layout.encode.bind(layout);\n return {\n decode: decode,\n encode: encode\n };\n};\nconst $c3af9e523501759a$var$bigInt = (length)=>(property)=>{\n const layout = (0, $Q02IV.blob)(length, property);\n const { encode: encode, decode: decode } = $c3af9e523501759a$var$encodeDecode(layout);\n const bigIntLayout = layout;\n bigIntLayout.decode = (buffer, offset)=>{\n const src = decode(buffer, offset);\n return (0, $gyRuj.toBigIntLE)((0, $6ZWSX.Buffer).from(src));\n };\n bigIntLayout.encode = (bigInt, buffer, offset)=>{\n const src = (0, $gyRuj.toBufferLE)(bigInt, length);\n return encode(src, buffer, offset);\n };\n return bigIntLayout;\n };\nconst $c3af9e523501759a$var$u64 = $c3af9e523501759a$var$bigInt(8);\n/**\n * Create account system transaction params\n */ /**\n * Transfer system transaction params\n */ /**\n * Assign system transaction params\n */ /**\n * Create account with seed system transaction params\n */ /**\n * Create nonce account system transaction params\n */ /**\n * Create nonce account with seed system transaction params\n */ /**\n * Initialize nonce account system instruction params\n */ /**\n * Advance nonce account system instruction params\n */ /**\n * Withdraw nonce account system transaction params\n */ /**\n * Authorize nonce account system transaction params\n */ /**\n * Allocate account system transaction params\n */ /**\n * Allocate account with seed system transaction params\n */ /**\n * Assign account with seed system transaction params\n */ /**\n * Transfer with seed system transaction params\n */ /** Decoded transfer system transaction instruction */ /** Decoded transferWithSeed system transaction instruction */ /**\n * System Instruction class\n */ class $c3af9e523501759a$export$f009802131fa3d06 {\n /**\n * @internal\n */ constructor(){}\n /**\n * Decode a system instruction and retrieve the instruction type.\n */ static decodeInstructionType(instruction) {\n this.checkProgramId(instruction.programId);\n const instructionTypeLayout = $Q02IV.u32('instruction');\n const typeIndex = instructionTypeLayout.decode(instruction.data);\n let type;\n for (const [ixType, layout] of Object.entries($c3af9e523501759a$export$74bdf41d8d1e7108))if (layout.index == typeIndex) {\n type = ixType;\n break;\n }\n if (!type) throw new Error('Instruction type incorrect; not a SystemInstruction');\n return type;\n }\n /**\n * Decode a create account system instruction and retrieve the instruction params.\n */ static decodeCreateAccount(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n const { lamports: lamports, space: space, programId: programId } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$74bdf41d8d1e7108.Create, instruction.data);\n return {\n fromPubkey: instruction.keys[0].pubkey,\n newAccountPubkey: instruction.keys[1].pubkey,\n lamports: lamports,\n space: space,\n programId: new $c3af9e523501759a$export$ca8b6604d6ce14de(programId)\n };\n }\n /**\n * Decode a transfer system instruction and retrieve the instruction params.\n */ static decodeTransfer(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n const { lamports: lamports } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$74bdf41d8d1e7108.Transfer, instruction.data);\n return {\n fromPubkey: instruction.keys[0].pubkey,\n toPubkey: instruction.keys[1].pubkey,\n lamports: lamports\n };\n }\n /**\n * Decode a transfer with seed system instruction and retrieve the instruction params.\n */ static decodeTransferWithSeed(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const { lamports: lamports, seed: seed, programId: programId } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$74bdf41d8d1e7108.TransferWithSeed, instruction.data);\n return {\n fromPubkey: instruction.keys[0].pubkey,\n basePubkey: instruction.keys[1].pubkey,\n toPubkey: instruction.keys[2].pubkey,\n lamports: lamports,\n seed: seed,\n programId: new $c3af9e523501759a$export$ca8b6604d6ce14de(programId)\n };\n }\n /**\n * Decode an allocate system instruction and retrieve the instruction params.\n */ static decodeAllocate(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 1);\n const { space: space } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$74bdf41d8d1e7108.Allocate, instruction.data);\n return {\n accountPubkey: instruction.keys[0].pubkey,\n space: space\n };\n }\n /**\n * Decode an allocate with seed system instruction and retrieve the instruction params.\n */ static decodeAllocateWithSeed(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 1);\n const { base: base, seed: seed, space: space, programId: programId } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$74bdf41d8d1e7108.AllocateWithSeed, instruction.data);\n return {\n accountPubkey: instruction.keys[0].pubkey,\n basePubkey: new $c3af9e523501759a$export$ca8b6604d6ce14de(base),\n seed: seed,\n space: space,\n programId: new $c3af9e523501759a$export$ca8b6604d6ce14de(programId)\n };\n }\n /**\n * Decode an assign system instruction and retrieve the instruction params.\n */ static decodeAssign(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 1);\n const { programId: programId } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$74bdf41d8d1e7108.Assign, instruction.data);\n return {\n accountPubkey: instruction.keys[0].pubkey,\n programId: new $c3af9e523501759a$export$ca8b6604d6ce14de(programId)\n };\n }\n /**\n * Decode an assign with seed system instruction and retrieve the instruction params.\n */ static decodeAssignWithSeed(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 1);\n const { base: base, seed: seed, programId: programId } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$74bdf41d8d1e7108.AssignWithSeed, instruction.data);\n return {\n accountPubkey: instruction.keys[0].pubkey,\n basePubkey: new $c3af9e523501759a$export$ca8b6604d6ce14de(base),\n seed: seed,\n programId: new $c3af9e523501759a$export$ca8b6604d6ce14de(programId)\n };\n }\n /**\n * Decode a create account with seed system instruction and retrieve the instruction params.\n */ static decodeCreateWithSeed(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n const { base: base, seed: seed, lamports: lamports, space: space, programId: programId } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$74bdf41d8d1e7108.CreateWithSeed, instruction.data);\n return {\n fromPubkey: instruction.keys[0].pubkey,\n newAccountPubkey: instruction.keys[1].pubkey,\n basePubkey: new $c3af9e523501759a$export$ca8b6604d6ce14de(base),\n seed: seed,\n lamports: lamports,\n space: space,\n programId: new $c3af9e523501759a$export$ca8b6604d6ce14de(programId)\n };\n }\n /**\n * Decode a nonce initialize system instruction and retrieve the instruction params.\n */ static decodeNonceInitialize(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const { authorized: authorized } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$74bdf41d8d1e7108.InitializeNonceAccount, instruction.data);\n return {\n noncePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: new $c3af9e523501759a$export$ca8b6604d6ce14de(authorized)\n };\n }\n /**\n * Decode a nonce advance system instruction and retrieve the instruction params.\n */ static decodeNonceAdvance(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$74bdf41d8d1e7108.AdvanceNonceAccount, instruction.data);\n return {\n noncePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: instruction.keys[2].pubkey\n };\n }\n /**\n * Decode a nonce withdraw system instruction and retrieve the instruction params.\n */ static decodeNonceWithdraw(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 5);\n const { lamports: lamports } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$74bdf41d8d1e7108.WithdrawNonceAccount, instruction.data);\n return {\n noncePubkey: instruction.keys[0].pubkey,\n toPubkey: instruction.keys[1].pubkey,\n authorizedPubkey: instruction.keys[4].pubkey,\n lamports: lamports\n };\n }\n /**\n * Decode a nonce authorize system instruction and retrieve the instruction params.\n */ static decodeNonceAuthorize(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n const { authorized: authorized } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$74bdf41d8d1e7108.AuthorizeNonceAccount, instruction.data);\n return {\n noncePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: instruction.keys[1].pubkey,\n newAuthorizedPubkey: new $c3af9e523501759a$export$ca8b6604d6ce14de(authorized)\n };\n }\n /**\n * @internal\n */ static checkProgramId(programId) {\n if (!programId.equals($c3af9e523501759a$export$d8c4e17726848113.programId)) throw new Error('invalid instruction; programId is not SystemProgram');\n }\n /**\n * @internal\n */ static checkKeyLength(keys, expectedLength) {\n if (keys.length < expectedLength) throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);\n }\n}\n/**\n * An enumeration of valid SystemInstructionType's\n */ /**\n * An enumeration of valid system InstructionType's\n * @internal\n */ const $c3af9e523501759a$export$74bdf41d8d1e7108 = Object.freeze({\n Create: {\n index: 0,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $Q02IV.ns64('lamports'),\n $Q02IV.ns64('space'),\n $c3af9e523501759a$var$publicKey('programId')\n ])\n },\n Assign: {\n index: 1,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$publicKey('programId')\n ])\n },\n Transfer: {\n index: 2,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$u64('lamports')\n ])\n },\n CreateWithSeed: {\n index: 3,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$publicKey('base'),\n $c3af9e523501759a$var$rustString('seed'),\n $Q02IV.ns64('lamports'),\n $Q02IV.ns64('space'),\n $c3af9e523501759a$var$publicKey('programId')\n ])\n },\n AdvanceNonceAccount: {\n index: 4,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction')\n ])\n },\n WithdrawNonceAccount: {\n index: 5,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $Q02IV.ns64('lamports')\n ])\n },\n InitializeNonceAccount: {\n index: 6,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$publicKey('authorized')\n ])\n },\n AuthorizeNonceAccount: {\n index: 7,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$publicKey('authorized')\n ])\n },\n Allocate: {\n index: 8,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $Q02IV.ns64('space')\n ])\n },\n AllocateWithSeed: {\n index: 9,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$publicKey('base'),\n $c3af9e523501759a$var$rustString('seed'),\n $Q02IV.ns64('space'),\n $c3af9e523501759a$var$publicKey('programId')\n ])\n },\n AssignWithSeed: {\n index: 10,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$publicKey('base'),\n $c3af9e523501759a$var$rustString('seed'),\n $c3af9e523501759a$var$publicKey('programId')\n ])\n },\n TransferWithSeed: {\n index: 11,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$u64('lamports'),\n $c3af9e523501759a$var$rustString('seed'),\n $c3af9e523501759a$var$publicKey('programId')\n ])\n },\n UpgradeNonceAccount: {\n index: 12,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction')\n ])\n }\n});\n/**\n * Factory class for transactions to interact with the System program\n */ class $c3af9e523501759a$export$d8c4e17726848113 {\n /**\n * @internal\n */ constructor(){}\n /**\n * Public key that identifies the System program\n */ /**\n * Generate a transaction instruction that creates a new account\n */ static createAccount(params) {\n const type = $c3af9e523501759a$export$74bdf41d8d1e7108.Create;\n const data = $c3af9e523501759a$var$encodeData(type, {\n lamports: params.lamports,\n space: params.space,\n programId: $c3af9e523501759a$var$toBuffer(params.programId.toBuffer())\n });\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n keys: [\n {\n pubkey: params.fromPubkey,\n isSigner: true,\n isWritable: true\n },\n {\n pubkey: params.newAccountPubkey,\n isSigner: true,\n isWritable: true\n }\n ],\n programId: this.programId,\n data: data\n });\n }\n /**\n * Generate a transaction instruction that transfers lamports from one account to another\n */ static transfer(params) {\n let data;\n let keys;\n if ('basePubkey' in params) {\n const type = $c3af9e523501759a$export$74bdf41d8d1e7108.TransferWithSeed;\n data = $c3af9e523501759a$var$encodeData(type, {\n lamports: BigInt(params.lamports),\n seed: params.seed,\n programId: $c3af9e523501759a$var$toBuffer(params.programId.toBuffer())\n });\n keys = [\n {\n pubkey: params.fromPubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: params.basePubkey,\n isSigner: true,\n isWritable: false\n },\n {\n pubkey: params.toPubkey,\n isSigner: false,\n isWritable: true\n }\n ];\n } else {\n const type = $c3af9e523501759a$export$74bdf41d8d1e7108.Transfer;\n data = $c3af9e523501759a$var$encodeData(type, {\n lamports: BigInt(params.lamports)\n });\n keys = [\n {\n pubkey: params.fromPubkey,\n isSigner: true,\n isWritable: true\n },\n {\n pubkey: params.toPubkey,\n isSigner: false,\n isWritable: true\n }\n ];\n }\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n keys: keys,\n programId: this.programId,\n data: data\n });\n }\n /**\n * Generate a transaction instruction that assigns an account to a program\n */ static assign(params) {\n let data;\n let keys;\n if ('basePubkey' in params) {\n const type = $c3af9e523501759a$export$74bdf41d8d1e7108.AssignWithSeed;\n data = $c3af9e523501759a$var$encodeData(type, {\n base: $c3af9e523501759a$var$toBuffer(params.basePubkey.toBuffer()),\n seed: params.seed,\n programId: $c3af9e523501759a$var$toBuffer(params.programId.toBuffer())\n });\n keys = [\n {\n pubkey: params.accountPubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: params.basePubkey,\n isSigner: true,\n isWritable: false\n }\n ];\n } else {\n const type = $c3af9e523501759a$export$74bdf41d8d1e7108.Assign;\n data = $c3af9e523501759a$var$encodeData(type, {\n programId: $c3af9e523501759a$var$toBuffer(params.programId.toBuffer())\n });\n keys = [\n {\n pubkey: params.accountPubkey,\n isSigner: true,\n isWritable: true\n }\n ];\n }\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n keys: keys,\n programId: this.programId,\n data: data\n });\n }\n /**\n * Generate a transaction instruction that creates a new account at\n * an address generated with `from`, a seed, and programId\n */ static createAccountWithSeed(params) {\n const type = $c3af9e523501759a$export$74bdf41d8d1e7108.CreateWithSeed;\n const data = $c3af9e523501759a$var$encodeData(type, {\n base: $c3af9e523501759a$var$toBuffer(params.basePubkey.toBuffer()),\n seed: params.seed,\n lamports: params.lamports,\n space: params.space,\n programId: $c3af9e523501759a$var$toBuffer(params.programId.toBuffer())\n });\n let keys = [\n {\n pubkey: params.fromPubkey,\n isSigner: true,\n isWritable: true\n },\n {\n pubkey: params.newAccountPubkey,\n isSigner: false,\n isWritable: true\n }\n ];\n if (!params.basePubkey.equals(params.fromPubkey)) keys.push({\n pubkey: params.basePubkey,\n isSigner: true,\n isWritable: false\n });\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n keys: keys,\n programId: this.programId,\n data: data\n });\n }\n /**\n * Generate a transaction that creates a new Nonce account\n */ static createNonceAccount(params) {\n const transaction = new $c3af9e523501759a$export$febc5573c75cefb0();\n if ('basePubkey' in params && 'seed' in params) transaction.add($c3af9e523501759a$export$d8c4e17726848113.createAccountWithSeed({\n fromPubkey: params.fromPubkey,\n newAccountPubkey: params.noncePubkey,\n basePubkey: params.basePubkey,\n seed: params.seed,\n lamports: params.lamports,\n space: $c3af9e523501759a$export$7126250b6d8bd94a,\n programId: this.programId\n }));\n else transaction.add($c3af9e523501759a$export$d8c4e17726848113.createAccount({\n fromPubkey: params.fromPubkey,\n newAccountPubkey: params.noncePubkey,\n lamports: params.lamports,\n space: $c3af9e523501759a$export$7126250b6d8bd94a,\n programId: this.programId\n }));\n const initParams = {\n noncePubkey: params.noncePubkey,\n authorizedPubkey: params.authorizedPubkey\n };\n transaction.add(this.nonceInitialize(initParams));\n return transaction;\n }\n /**\n * Generate an instruction to initialize a Nonce account\n */ static nonceInitialize(params) {\n const type = $c3af9e523501759a$export$74bdf41d8d1e7108.InitializeNonceAccount;\n const data = $c3af9e523501759a$var$encodeData(type, {\n authorized: $c3af9e523501759a$var$toBuffer(params.authorizedPubkey.toBuffer())\n });\n const instructionData = {\n keys: [\n {\n pubkey: params.noncePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: $c3af9e523501759a$export$e74201139e9833db,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: $c3af9e523501759a$export$970d0190cdb3a8e9,\n isSigner: false,\n isWritable: false\n }\n ],\n programId: this.programId,\n data: data\n };\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59(instructionData);\n }\n /**\n * Generate an instruction to advance the nonce in a Nonce account\n */ static nonceAdvance(params) {\n const type = $c3af9e523501759a$export$74bdf41d8d1e7108.AdvanceNonceAccount;\n const data = $c3af9e523501759a$var$encodeData(type);\n const instructionData = {\n keys: [\n {\n pubkey: params.noncePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: $c3af9e523501759a$export$e74201139e9833db,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: params.authorizedPubkey,\n isSigner: true,\n isWritable: false\n }\n ],\n programId: this.programId,\n data: data\n };\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59(instructionData);\n }\n /**\n * Generate a transaction instruction that withdraws lamports from a Nonce account\n */ static nonceWithdraw(params) {\n const type = $c3af9e523501759a$export$74bdf41d8d1e7108.WithdrawNonceAccount;\n const data = $c3af9e523501759a$var$encodeData(type, {\n lamports: params.lamports\n });\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n keys: [\n {\n pubkey: params.noncePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: params.toPubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: $c3af9e523501759a$export$e74201139e9833db,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: $c3af9e523501759a$export$970d0190cdb3a8e9,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: params.authorizedPubkey,\n isSigner: true,\n isWritable: false\n }\n ],\n programId: this.programId,\n data: data\n });\n }\n /**\n * Generate a transaction instruction that authorizes a new PublicKey as the authority\n * on a Nonce account.\n */ static nonceAuthorize(params) {\n const type = $c3af9e523501759a$export$74bdf41d8d1e7108.AuthorizeNonceAccount;\n const data = $c3af9e523501759a$var$encodeData(type, {\n authorized: $c3af9e523501759a$var$toBuffer(params.newAuthorizedPubkey.toBuffer())\n });\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n keys: [\n {\n pubkey: params.noncePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: params.authorizedPubkey,\n isSigner: true,\n isWritable: false\n }\n ],\n programId: this.programId,\n data: data\n });\n }\n /**\n * Generate a transaction instruction that allocates space in an account without funding\n */ static allocate(params) {\n let data;\n let keys;\n if ('basePubkey' in params) {\n const type = $c3af9e523501759a$export$74bdf41d8d1e7108.AllocateWithSeed;\n data = $c3af9e523501759a$var$encodeData(type, {\n base: $c3af9e523501759a$var$toBuffer(params.basePubkey.toBuffer()),\n seed: params.seed,\n space: params.space,\n programId: $c3af9e523501759a$var$toBuffer(params.programId.toBuffer())\n });\n keys = [\n {\n pubkey: params.accountPubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: params.basePubkey,\n isSigner: true,\n isWritable: false\n }\n ];\n } else {\n const type = $c3af9e523501759a$export$74bdf41d8d1e7108.Allocate;\n data = $c3af9e523501759a$var$encodeData(type, {\n space: params.space\n });\n keys = [\n {\n pubkey: params.accountPubkey,\n isSigner: true,\n isWritable: true\n }\n ];\n }\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n keys: keys,\n programId: this.programId,\n data: data\n });\n }\n}\n$c3af9e523501759a$export$d8c4e17726848113.programId = new $c3af9e523501759a$export$ca8b6604d6ce14de('11111111111111111111111111111111');\n// Keep program chunks under PACKET_DATA_SIZE, leaving enough room for the\n// rest of the Transaction fields\n//\n// TODO: replace 300 with a proper constant for the size of the other\n// Transaction fields\nconst $c3af9e523501759a$var$CHUNK_SIZE = $c3af9e523501759a$export$4c6d5b89e1596f26 - 300;\n/**\n * Program loader interface\n */ class $c3af9e523501759a$export$3b0d6d7590275603 {\n /**\n * @internal\n */ constructor(){}\n /**\n * Amount of program data placed in each load Transaction\n */ /**\n * Minimum number of signatures required to load a program not including\n * retries\n *\n * Can be used to calculate transaction fees\n */ static getMinNumSignatures(dataLength) {\n return 2 * // Every transaction requires two signatures (payer + program)\n (Math.ceil(dataLength / $c3af9e523501759a$export$3b0d6d7590275603.chunkSize) + 1 + // Add one for Create transaction\n 1 // Add one for Finalize transaction\n );\n }\n /**\n * Loads a generic program\n *\n * @param connection The connection to use\n * @param payer System account that pays to load the program\n * @param program Account to load the program into\n * @param programId Public key that identifies the loader\n * @param data Program octets\n * @return true if program was loaded successfully, false if program was already loaded\n */ static async load(connection, payer, program, programId, data) {\n {\n const balanceNeeded = await connection.getMinimumBalanceForRentExemption(data.length);\n // Fetch program account info to check if it has already been created\n const programInfo = await connection.getAccountInfo(program.publicKey, 'confirmed');\n let transaction = null;\n if (programInfo !== null) {\n if (programInfo.executable) {\n console.error('Program load failed, account is already executable');\n return false;\n }\n if (programInfo.data.length !== data.length) {\n transaction = transaction || new $c3af9e523501759a$export$febc5573c75cefb0();\n transaction.add($c3af9e523501759a$export$d8c4e17726848113.allocate({\n accountPubkey: program.publicKey,\n space: data.length\n }));\n }\n if (!programInfo.owner.equals(programId)) {\n transaction = transaction || new $c3af9e523501759a$export$febc5573c75cefb0();\n transaction.add($c3af9e523501759a$export$d8c4e17726848113.assign({\n accountPubkey: program.publicKey,\n programId: programId\n }));\n }\n if (programInfo.lamports < balanceNeeded) {\n transaction = transaction || new $c3af9e523501759a$export$febc5573c75cefb0();\n transaction.add($c3af9e523501759a$export$d8c4e17726848113.transfer({\n fromPubkey: payer.publicKey,\n toPubkey: program.publicKey,\n lamports: balanceNeeded - programInfo.lamports\n }));\n }\n } else transaction = new $c3af9e523501759a$export$febc5573c75cefb0().add($c3af9e523501759a$export$d8c4e17726848113.createAccount({\n fromPubkey: payer.publicKey,\n newAccountPubkey: program.publicKey,\n lamports: balanceNeeded > 0 ? balanceNeeded : 1,\n space: data.length,\n programId: programId\n }));\n // If the account is already created correctly, skip this step\n // and proceed directly to loading instructions\n if (transaction !== null) await $c3af9e523501759a$export$4ad6fe6dae0b6bc3(connection, transaction, [\n payer,\n program\n ], {\n commitment: 'confirmed'\n });\n }\n const dataLayout = $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $Q02IV.u32('offset'),\n $Q02IV.u32('bytesLength'),\n $Q02IV.u32('bytesLengthPadding'),\n $Q02IV.seq($Q02IV.u8('byte'), $Q02IV.offset($Q02IV.u32(), -8), 'bytes')\n ]);\n const chunkSize = $c3af9e523501759a$export$3b0d6d7590275603.chunkSize;\n let offset = 0;\n let array = data;\n let transactions = [];\n while(array.length > 0){\n const bytes = array.slice(0, chunkSize);\n const data = (0, $6ZWSX.Buffer).alloc(chunkSize + 16);\n dataLayout.encode({\n instruction: 0,\n offset: // Load instruction\n offset,\n bytes: bytes,\n bytesLength: 0,\n bytesLengthPadding: 0\n }, data);\n const transaction = new $c3af9e523501759a$export$febc5573c75cefb0().add({\n keys: [\n {\n pubkey: program.publicKey,\n isSigner: true,\n isWritable: true\n }\n ],\n programId: programId,\n data: data\n });\n transactions.push($c3af9e523501759a$export$4ad6fe6dae0b6bc3(connection, transaction, [\n payer,\n program\n ], {\n commitment: 'confirmed'\n }));\n // Delay between sends in an attempt to reduce rate limit errors\n if (connection._rpcEndpoint.includes('solana.com')) {\n const REQUESTS_PER_SECOND = 4;\n await $c3af9e523501759a$var$sleep(1000 / REQUESTS_PER_SECOND);\n }\n offset += chunkSize;\n array = array.slice(chunkSize);\n }\n await Promise.all(transactions);\n // Finalize the account loaded with program data for execution\n {\n const dataLayout = $Q02IV.struct([\n $Q02IV.u32('instruction')\n ]);\n const data = (0, $6ZWSX.Buffer).alloc(dataLayout.span);\n dataLayout.encode({\n instruction: 1 // Finalize instruction\n }, data);\n const transaction = new $c3af9e523501759a$export$febc5573c75cefb0().add({\n keys: [\n {\n pubkey: program.publicKey,\n isSigner: true,\n isWritable: true\n },\n {\n pubkey: $c3af9e523501759a$export$970d0190cdb3a8e9,\n isSigner: false,\n isWritable: false\n }\n ],\n programId: programId,\n data: data\n });\n const deployCommitment = 'processed';\n const finalizeSignature = await connection.sendTransaction(transaction, [\n payer,\n program\n ], {\n preflightCommitment: deployCommitment\n });\n const { context: context, value: value } = await connection.confirmTransaction({\n signature: finalizeSignature,\n lastValidBlockHeight: transaction.lastValidBlockHeight,\n blockhash: transaction.recentBlockhash\n }, deployCommitment);\n if (value.err) throw new Error(`Transaction ${finalizeSignature} failed (${JSON.stringify(value)})`);\n // We prevent programs from being usable until the slot after their deployment.\n // See https://github.com/solana-labs/solana/pull/29654\n while(true // eslint-disable-line no-constant-condition\n ){\n try {\n const currentSlot = await connection.getSlot({\n commitment: deployCommitment\n });\n if (currentSlot > context.slot) break;\n } catch {\n /* empty */ }\n await new Promise((resolve)=>setTimeout(resolve, Math.round($c3af9e523501759a$var$MS_PER_SLOT / 2)));\n }\n }\n // success\n return true;\n }\n}\n$c3af9e523501759a$export$3b0d6d7590275603.chunkSize = $c3af9e523501759a$var$CHUNK_SIZE;\n/**\n * @deprecated Deprecated since Solana v1.17.20.\n */ const $c3af9e523501759a$export$59833422f998b937 = new $c3af9e523501759a$export$ca8b6604d6ce14de('BPFLoader2111111111111111111111111111111111');\n/**\n * Factory class for transactions to interact with a program loader\n *\n * @deprecated Deprecated since Solana v1.17.20.\n */ class $c3af9e523501759a$export$493be68e6a240d3b {\n /**\n * Minimum number of signatures required to load a program not including\n * retries\n *\n * Can be used to calculate transaction fees\n */ static getMinNumSignatures(dataLength) {\n return $c3af9e523501759a$export$3b0d6d7590275603.getMinNumSignatures(dataLength);\n }\n /**\n * Load a SBF program\n *\n * @param connection The connection to use\n * @param payer Account that will pay program loading fees\n * @param program Account to load the program into\n * @param elf The entire ELF containing the SBF program\n * @param loaderProgramId The program id of the BPF loader to use\n * @return true if program was loaded successfully, false if program was already loaded\n */ static load(connection, payer, program, elf, loaderProgramId) {\n return $c3af9e523501759a$export$3b0d6d7590275603.load(connection, payer, program, loaderProgramId, elf);\n }\n}\nfunction $c3af9e523501759a$var$getDefaultExportFromCjs(x) {\n return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\nvar $c3af9e523501759a$var$fastStableStringify$1;\nvar $c3af9e523501759a$var$hasRequiredFastStableStringify;\nfunction $c3af9e523501759a$var$requireFastStableStringify() {\n if ($c3af9e523501759a$var$hasRequiredFastStableStringify) return $c3af9e523501759a$var$fastStableStringify$1;\n $c3af9e523501759a$var$hasRequiredFastStableStringify = 1;\n var objToString = Object.prototype.toString;\n var objKeys = Object.keys || function(obj) {\n var keys = [];\n for(var name in obj)keys.push(name);\n return keys;\n };\n function stringify(val, isArrayProp) {\n var i, max, str, keys, key, propVal, toStr;\n if (val === true) return \"true\";\n if (val === false) return \"false\";\n switch(typeof val){\n case \"object\":\n if (val === null) return null;\n else if (val.toJSON && typeof val.toJSON === \"function\") return stringify(val.toJSON(), isArrayProp);\n else {\n toStr = objToString.call(val);\n if (toStr === \"[object Array]\") {\n str = '[';\n max = val.length - 1;\n for(i = 0; i < max; i++)str += stringify(val[i], true) + ',';\n if (max > -1) str += stringify(val[i], true);\n return str + ']';\n } else if (toStr === \"[object Object]\") {\n // only object is left\n keys = objKeys(val).sort();\n max = keys.length;\n str = \"\";\n i = 0;\n while(i < max){\n key = keys[i];\n propVal = stringify(val[key], false);\n if (propVal !== undefined) {\n if (str) str += ',';\n str += JSON.stringify(key) + ':' + propVal;\n }\n i++;\n }\n return '{' + str + '}';\n } else return JSON.stringify(val);\n }\n case \"function\":\n case \"undefined\":\n return isArrayProp ? null : undefined;\n case \"string\":\n return JSON.stringify(val);\n default:\n return isFinite(val) ? val : null;\n }\n }\n $c3af9e523501759a$var$fastStableStringify$1 = function(val) {\n var returnVal = stringify(val, false);\n if (returnVal !== undefined) return '' + returnVal;\n };\n return $c3af9e523501759a$var$fastStableStringify$1;\n}\nvar $c3af9e523501759a$var$fastStableStringifyExports = /*@__PURE__*/ $c3af9e523501759a$var$requireFastStableStringify();\nvar $c3af9e523501759a$var$fastStableStringify = /*@__PURE__*/ $c3af9e523501759a$var$getDefaultExportFromCjs($c3af9e523501759a$var$fastStableStringifyExports);\nconst $c3af9e523501759a$var$MINIMUM_SLOT_PER_EPOCH = 32;\n// Returns the number of trailing zeros in the binary representation of self.\nfunction $c3af9e523501759a$var$trailingZeros(n) {\n let trailingZeros = 0;\n while(n > 1){\n n /= 2;\n trailingZeros++;\n }\n return trailingZeros;\n}\n// Returns the smallest power of two greater than or equal to n\nfunction $c3af9e523501759a$var$nextPowerOfTwo(n) {\n if (n === 0) return 1;\n n--;\n n |= n >> 1;\n n |= n >> 2;\n n |= n >> 4;\n n |= n >> 8;\n n |= n >> 16;\n n |= n >> 32;\n return n + 1;\n}\n/**\n * Epoch schedule\n * (see https://docs.solana.com/terminology#epoch)\n * Can be retrieved with the {@link Connection.getEpochSchedule} method\n */ class $c3af9e523501759a$export$df8ed3e830b1d591 {\n constructor(slotsPerEpoch, leaderScheduleSlotOffset, warmup, firstNormalEpoch, firstNormalSlot){\n /** The maximum number of slots in each epoch */ this.slotsPerEpoch = void 0;\n /** The number of slots before beginning of an epoch to calculate a leader schedule for that epoch */ this.leaderScheduleSlotOffset = void 0;\n /** Indicates whether epochs start short and grow */ this.warmup = void 0;\n /** The first epoch with `slotsPerEpoch` slots */ this.firstNormalEpoch = void 0;\n /** The first slot of `firstNormalEpoch` */ this.firstNormalSlot = void 0;\n this.slotsPerEpoch = slotsPerEpoch;\n this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;\n this.warmup = warmup;\n this.firstNormalEpoch = firstNormalEpoch;\n this.firstNormalSlot = firstNormalSlot;\n }\n getEpoch(slot) {\n return this.getEpochAndSlotIndex(slot)[0];\n }\n getEpochAndSlotIndex(slot) {\n if (slot < this.firstNormalSlot) {\n const epoch = $c3af9e523501759a$var$trailingZeros($c3af9e523501759a$var$nextPowerOfTwo(slot + $c3af9e523501759a$var$MINIMUM_SLOT_PER_EPOCH + 1)) - $c3af9e523501759a$var$trailingZeros($c3af9e523501759a$var$MINIMUM_SLOT_PER_EPOCH) - 1;\n const epochLen = this.getSlotsInEpoch(epoch);\n const slotIndex = slot - (epochLen - $c3af9e523501759a$var$MINIMUM_SLOT_PER_EPOCH);\n return [\n epoch,\n slotIndex\n ];\n } else {\n const normalSlotIndex = slot - this.firstNormalSlot;\n const normalEpochIndex = Math.floor(normalSlotIndex / this.slotsPerEpoch);\n const epoch = this.firstNormalEpoch + normalEpochIndex;\n const slotIndex = normalSlotIndex % this.slotsPerEpoch;\n return [\n epoch,\n slotIndex\n ];\n }\n }\n getFirstSlotInEpoch(epoch) {\n if (epoch <= this.firstNormalEpoch) return (Math.pow(2, epoch) - 1) * $c3af9e523501759a$var$MINIMUM_SLOT_PER_EPOCH;\n else return (epoch - this.firstNormalEpoch) * this.slotsPerEpoch + this.firstNormalSlot;\n }\n getLastSlotInEpoch(epoch) {\n return this.getFirstSlotInEpoch(epoch) + this.getSlotsInEpoch(epoch) - 1;\n }\n getSlotsInEpoch(epoch) {\n if (epoch < this.firstNormalEpoch) return Math.pow(2, epoch + $c3af9e523501759a$var$trailingZeros($c3af9e523501759a$var$MINIMUM_SLOT_PER_EPOCH));\n else return this.slotsPerEpoch;\n }\n}\nvar $c3af9e523501759a$var$fetchImpl = globalThis.fetch;\nclass $c3af9e523501759a$var$RpcWebSocketClient extends (0, $ga6mf.CommonClient) {\n constructor(address, options, generate_request_id){\n const webSocketFactory = (url)=>{\n const rpc = (0, $ga6mf.WebSocket)(url, {\n autoconnect: true,\n max_reconnects: 5,\n reconnect: true,\n reconnect_interval: 1000,\n ...options\n });\n if ('socket' in rpc) this.underlyingSocket = rpc.socket;\n else this.underlyingSocket = rpc;\n return rpc;\n };\n super(webSocketFactory, address, options, generate_request_id);\n this.underlyingSocket = void 0;\n }\n call(...args) {\n const readyState = this.underlyingSocket?.readyState;\n if (readyState === 1 /* WebSocket.OPEN */ ) return super.call(...args);\n return Promise.reject(new Error('Tried to call a JSON-RPC method `' + args[0] + '` but the socket was not `CONNECTING` or `OPEN` (`readyState` was ' + readyState + ')'));\n }\n notify(...args) {\n const readyState = this.underlyingSocket?.readyState;\n if (readyState === 1 /* WebSocket.OPEN */ ) return super.notify(...args);\n return Promise.reject(new Error('Tried to send a JSON-RPC notification `' + args[0] + '` but the socket was not `CONNECTING` or `OPEN` (`readyState` was ' + readyState + ')'));\n }\n}\n/**\n * @internal\n */ /**\n * Decode account data buffer using an AccountType\n * @internal\n */ function $c3af9e523501759a$var$decodeData(type, data) {\n let decoded;\n try {\n decoded = type.layout.decode(data);\n } catch (err) {\n throw new Error('invalid instruction; ' + err);\n }\n if (decoded.typeIndex !== type.index) throw new Error(`invalid account data; account type mismatch ${decoded.typeIndex} != ${type.index}`);\n return decoded;\n}\n/// The serialized size of lookup table metadata\nconst $c3af9e523501759a$var$LOOKUP_TABLE_META_SIZE = 56;\nclass $c3af9e523501759a$export$5b2310da10e607da {\n constructor(args){\n this.key = void 0;\n this.state = void 0;\n this.key = args.key;\n this.state = args.state;\n }\n isActive() {\n const U64_MAX = BigInt('0xffffffffffffffff');\n return this.state.deactivationSlot === U64_MAX;\n }\n static deserialize(accountData) {\n const meta = $c3af9e523501759a$var$decodeData($c3af9e523501759a$var$LookupTableMetaLayout, accountData);\n const serializedAddressesLen = accountData.length - $c3af9e523501759a$var$LOOKUP_TABLE_META_SIZE;\n $c3af9e523501759a$var$assert(serializedAddressesLen >= 0, 'lookup table is invalid');\n $c3af9e523501759a$var$assert(serializedAddressesLen % 32 === 0, 'lookup table is invalid');\n const numSerializedAddresses = serializedAddressesLen / 32;\n const { addresses: addresses } = $Q02IV.struct([\n $Q02IV.seq($c3af9e523501759a$var$publicKey(), numSerializedAddresses, 'addresses')\n ]).decode(accountData.slice($c3af9e523501759a$var$LOOKUP_TABLE_META_SIZE));\n return {\n deactivationSlot: meta.deactivationSlot,\n lastExtendedSlot: meta.lastExtendedSlot,\n lastExtendedSlotStartIndex: meta.lastExtendedStartIndex,\n authority: meta.authority.length !== 0 ? new $c3af9e523501759a$export$ca8b6604d6ce14de(meta.authority[0]) : undefined,\n addresses: addresses.map((address)=>new $c3af9e523501759a$export$ca8b6604d6ce14de(address))\n };\n }\n}\nconst $c3af9e523501759a$var$LookupTableMetaLayout = {\n index: 1,\n layout: $Q02IV.struct([\n $Q02IV.u32('typeIndex'),\n $c3af9e523501759a$var$u64('deactivationSlot'),\n $Q02IV.nu64('lastExtendedSlot'),\n $Q02IV.u8('lastExtendedStartIndex'),\n $Q02IV.u8(),\n // option\n $Q02IV.seq($c3af9e523501759a$var$publicKey(), $Q02IV.offset($Q02IV.u8(), -1), 'authority')\n ])\n};\nconst $c3af9e523501759a$var$URL_RE = /^[^:]+:\\/\\/([^:[]+|\\[[^\\]]+\\])(:\\d+)?(.*)/i;\nfunction $c3af9e523501759a$var$makeWebsocketUrl(endpoint) {\n const matches = endpoint.match($c3af9e523501759a$var$URL_RE);\n if (matches == null) throw TypeError(`Failed to validate endpoint URL \\`${endpoint}\\``);\n const [_, // eslint-disable-line @typescript-eslint/no-unused-vars\n hostish, portWithColon, rest] = matches;\n const protocol = endpoint.startsWith('https:') ? 'wss:' : 'ws:';\n const startPort = portWithColon == null ? null : parseInt(portWithColon.slice(1), 10);\n const websocketPort = // Only shift the port by +1 as a convention for ws(s) only if given endpoint\n // is explicitly specifying the endpoint port (HTTP-based RPC), assuming\n // we're directly trying to connect to agave-validator's ws listening port.\n // When the endpoint omits the port, we're connecting to the protocol\n // default ports: http(80) or https(443) and it's assumed we're behind a reverse\n // proxy which manages WebSocket upgrade and backend port redirection.\n startPort == null ? '' : `:${startPort + 1}`;\n return `${protocol}//${hostish}${websocketPort}${rest}`;\n}\nconst $c3af9e523501759a$var$PublicKeyFromString = (0, $5DqgT.coerce)((0, $5DqgT.instance)($c3af9e523501759a$export$ca8b6604d6ce14de), (0, $5DqgT.string)(), (value)=>new $c3af9e523501759a$export$ca8b6604d6ce14de(value));\nconst $c3af9e523501759a$var$RawAccountDataResult = (0, $5DqgT.tuple)([\n (0, $5DqgT.string)(),\n (0, $5DqgT.literal)('base64')\n]);\nconst $c3af9e523501759a$var$BufferFromRawAccountData = (0, $5DqgT.coerce)((0, $5DqgT.instance)((0, $6ZWSX.Buffer)), $c3af9e523501759a$var$RawAccountDataResult, (value)=>(0, $6ZWSX.Buffer).from(value[0], 'base64'));\n/**\n * Attempt to use a recent blockhash for up to 30 seconds\n * @internal\n */ const $c3af9e523501759a$export$fcb705732fb5c597 = 30000;\n/**\n * HACK.\n * Copied from rpc-websockets/dist/lib/client.\n * Otherwise, `yarn build` fails with:\n * https://gist.github.com/steveluscher/c057eca81d479ef705cdb53162f9971d\n */ /** @internal */ /** @internal */ /** @internal */ /** @internal */ /** @internal */ /**\n * @internal\n * Every subscription contains the args used to open the subscription with\n * the server, and a list of callers interested in notifications.\n */ /**\n * @internal\n * A subscription may be in various states of connectedness. Only when it is\n * fully connected will it have a server subscription id associated with it.\n * This id can be returned to the server to unsubscribe the client entirely.\n */ /**\n * A type that encapsulates a subscription's RPC method\n * names and notification (callback) signature.\n */ /**\n * @internal\n * Utility type that keeps tagged unions intact while omitting properties.\n */ /**\n * @internal\n * This type represents a single subscribable 'topic.' It's made up of:\n *\n * - The args used to open the subscription with the server,\n * - The state of the subscription, in terms of its connectedness, and\n * - The set of callbacks to call when the server publishes notifications\n *\n * This record gets indexed by `SubscriptionConfigHash` and is used to\n * set up subscriptions, fan out notifications, and track subscription state.\n */ /**\n * @internal\n */ /**\n * Extra contextual information for RPC responses\n */ /**\n * Options for sending transactions\n */ /**\n * Options for confirming transactions\n */ /**\n * Options for getConfirmedSignaturesForAddress2\n */ /**\n * Options for getSignaturesForAddress\n */ /**\n * RPC Response with extra contextual information\n */ /**\n * A strategy for confirming transactions that uses the last valid\n * block height for a given blockhash to check for transaction expiration.\n */ /**\n * A strategy for confirming durable nonce transactions.\n */ /**\n * Properties shared by all transaction confirmation strategies\n */ /**\n * This type represents all transaction confirmation strategies\n */ /* @internal */ function $c3af9e523501759a$var$assertEndpointUrl(putativeUrl) {\n if (/^https?:/.test(putativeUrl) === false) throw new TypeError('Endpoint URL must start with `http:` or `https:`.');\n return putativeUrl;\n}\n/** @internal */ function $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig) {\n let commitment;\n let config;\n if (typeof commitmentOrConfig === 'string') commitment = commitmentOrConfig;\n else if (commitmentOrConfig) {\n const { commitment: specifiedCommitment, ...specifiedConfig } = commitmentOrConfig;\n commitment = specifiedCommitment;\n config = specifiedConfig;\n }\n return {\n commitment: commitment,\n config: config\n };\n}\n/**\n * @internal\n */ function $c3af9e523501759a$var$applyDefaultMemcmpEncodingToFilters(filters) {\n return filters.map((filter)=>'memcmp' in filter ? {\n ...filter,\n memcmp: {\n ...filter.memcmp,\n encoding: filter.memcmp.encoding ?? 'base58'\n }\n } : filter);\n}\n/**\n * @internal\n */ function $c3af9e523501759a$var$createRpcResult(result) {\n return (0, $5DqgT.union)([\n (0, $5DqgT.type)({\n jsonrpc: (0, $5DqgT.literal)('2.0'),\n id: (0, $5DqgT.string)(),\n result: result\n }),\n (0, $5DqgT.type)({\n jsonrpc: (0, $5DqgT.literal)('2.0'),\n id: (0, $5DqgT.string)(),\n error: (0, $5DqgT.type)({\n code: (0, $5DqgT.unknown)(),\n message: (0, $5DqgT.string)(),\n data: (0, $5DqgT.optional)((0, $5DqgT.any)())\n })\n })\n ]);\n}\nconst $c3af9e523501759a$var$UnknownRpcResult = $c3af9e523501759a$var$createRpcResult((0, $5DqgT.unknown)());\n/**\n * @internal\n */ function $c3af9e523501759a$var$jsonRpcResult(schema) {\n return (0, $5DqgT.coerce)($c3af9e523501759a$var$createRpcResult(schema), $c3af9e523501759a$var$UnknownRpcResult, (value)=>{\n if ('error' in value) return value;\n else return {\n ...value,\n result: (0, $5DqgT.create)(value.result, schema)\n };\n });\n}\n/**\n * @internal\n */ function $c3af9e523501759a$var$jsonRpcResultAndContext(value) {\n return $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.type)({\n context: (0, $5DqgT.type)({\n slot: (0, $5DqgT.number)()\n }),\n value: value\n }));\n}\n/**\n * @internal\n */ function $c3af9e523501759a$var$notificationResultAndContext(value) {\n return (0, $5DqgT.type)({\n context: (0, $5DqgT.type)({\n slot: (0, $5DqgT.number)()\n }),\n value: value\n });\n}\n/**\n * @internal\n */ function $c3af9e523501759a$var$versionedMessageFromResponse(version, response) {\n if (version === 0) return new $c3af9e523501759a$export$ee274c70e0fae590({\n header: response.header,\n staticAccountKeys: response.accountKeys.map((accountKey)=>new $c3af9e523501759a$export$ca8b6604d6ce14de(accountKey)),\n recentBlockhash: response.recentBlockhash,\n compiledInstructions: response.instructions.map((ix)=>({\n programIdIndex: ix.programIdIndex,\n accountKeyIndexes: ix.accounts,\n data: (0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).decode(ix.data)\n })),\n addressTableLookups: response.addressTableLookups\n });\n else return new $c3af9e523501759a$export$f69c19e57285b83a(response);\n}\n/**\n * The level of commitment desired when querying state\n *
\n *   'processed': Query the most recent block which has reached 1 confirmation by the connected node\n *   'confirmed': Query the most recent block which has reached 1 confirmation by the cluster\n *   'finalized': Query the most recent block which has been finalized by the cluster\n * 
\n */ // Deprecated as of v1.5.5\n/**\n * A subset of Commitment levels, which are at least optimistically confirmed\n *
\n *   'confirmed': Query the most recent block which has reached 1 confirmation by the cluster\n *   'finalized': Query the most recent block which has been finalized by the cluster\n * 
\n */ /**\n * Filter for largest accounts query\n *
\n *   'circulating':    Return the largest accounts that are part of the circulating supply\n *   'nonCirculating': Return the largest accounts that are not part of the circulating supply\n * 
\n */ /**\n * Configuration object for changing `getAccountInfo` query behavior\n */ /**\n * Configuration object for changing `getBalance` query behavior\n */ /**\n * Configuration object for changing `getBlock` query behavior\n */ /**\n * Configuration object for changing `getBlock` query behavior\n */ /**\n * Configuration object for changing `getStakeMinimumDelegation` query behavior\n */ /**\n * Configuration object for changing `getBlockHeight` query behavior\n */ /**\n * Configuration object for changing `getEpochInfo` query behavior\n */ /**\n * Configuration object for changing `getInflationReward` query behavior\n */ /**\n * Configuration object for changing `getLatestBlockhash` query behavior\n */ /**\n * Configuration object for changing `isBlockhashValid` query behavior\n */ /**\n * Configuration object for changing `getSlot` query behavior\n */ /**\n * Configuration object for changing `getSlotLeader` query behavior\n */ /**\n * Configuration object for changing `getTransaction` query behavior\n */ /**\n * Configuration object for changing `getTransaction` query behavior\n */ /**\n * Configuration object for changing `getLargestAccounts` query behavior\n */ /**\n * Configuration object for changing `getSupply` request behavior\n */ /**\n * Configuration object for changing query behavior\n */ /**\n * Information describing a cluster node\n */ /**\n * Information describing a vote account\n */ /**\n * A collection of cluster vote accounts\n */ /**\n * Network Inflation\n * (see https://docs.solana.com/implemented-proposals/ed_overview)\n */ const $c3af9e523501759a$var$GetInflationGovernorResult = (0, $5DqgT.type)({\n foundation: (0, $5DqgT.number)(),\n foundationTerm: (0, $5DqgT.number)(),\n initial: (0, $5DqgT.number)(),\n taper: (0, $5DqgT.number)(),\n terminal: (0, $5DqgT.number)()\n});\n/**\n * The inflation reward for an epoch\n */ /**\n * Expected JSON RPC response for the \"getInflationReward\" message\n */ const $c3af9e523501759a$var$GetInflationRewardResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.array)((0, $5DqgT.nullable)((0, $5DqgT.type)({\n epoch: (0, $5DqgT.number)(),\n effectiveSlot: (0, $5DqgT.number)(),\n amount: (0, $5DqgT.number)(),\n postBalance: (0, $5DqgT.number)(),\n commission: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.number)()))\n}))));\n/**\n * Configuration object for changing `getRecentPrioritizationFees` query behavior\n */ /**\n * Expected JSON RPC response for the \"getRecentPrioritizationFees\" message\n */ const $c3af9e523501759a$var$GetRecentPrioritizationFeesResult = (0, $5DqgT.array)((0, $5DqgT.type)({\n slot: (0, $5DqgT.number)(),\n prioritizationFee: (0, $5DqgT.number)()\n}));\n/**\n * Expected JSON RPC response for the \"getInflationRate\" message\n */ const $c3af9e523501759a$var$GetInflationRateResult = (0, $5DqgT.type)({\n total: (0, $5DqgT.number)(),\n validator: (0, $5DqgT.number)(),\n foundation: (0, $5DqgT.number)(),\n epoch: (0, $5DqgT.number)()\n});\n/**\n * Information about the current epoch\n */ const $c3af9e523501759a$var$GetEpochInfoResult = (0, $5DqgT.type)({\n epoch: (0, $5DqgT.number)(),\n slotIndex: (0, $5DqgT.number)(),\n slotsInEpoch: (0, $5DqgT.number)(),\n absoluteSlot: (0, $5DqgT.number)(),\n blockHeight: (0, $5DqgT.optional)((0, $5DqgT.number)()),\n transactionCount: (0, $5DqgT.optional)((0, $5DqgT.number)())\n});\nconst $c3af9e523501759a$var$GetEpochScheduleResult = (0, $5DqgT.type)({\n slotsPerEpoch: (0, $5DqgT.number)(),\n leaderScheduleSlotOffset: (0, $5DqgT.number)(),\n warmup: (0, $5DqgT.boolean)(),\n firstNormalEpoch: (0, $5DqgT.number)(),\n firstNormalSlot: (0, $5DqgT.number)()\n});\n/**\n * Leader schedule\n * (see https://docs.solana.com/terminology#leader-schedule)\n */ const $c3af9e523501759a$var$GetLeaderScheduleResult = (0, $5DqgT.record)((0, $5DqgT.string)(), (0, $5DqgT.array)((0, $5DqgT.number)()));\n/**\n * Transaction error or null\n */ const $c3af9e523501759a$var$TransactionErrorResult = (0, $5DqgT.nullable)((0, $5DqgT.union)([\n (0, $5DqgT.type)({}),\n (0, $5DqgT.string)()\n]));\n/**\n * Signature status for a transaction\n */ const $c3af9e523501759a$var$SignatureStatusResult = (0, $5DqgT.type)({\n err: $c3af9e523501759a$var$TransactionErrorResult\n});\n/**\n * Transaction signature received notification\n */ const $c3af9e523501759a$var$SignatureReceivedResult = (0, $5DqgT.literal)('receivedSignature');\n/**\n * Version info for a node\n */ const $c3af9e523501759a$var$VersionResult = (0, $5DqgT.type)({\n 'solana-core': (0, $5DqgT.string)(),\n 'feature-set': (0, $5DqgT.optional)((0, $5DqgT.number)())\n});\nconst $c3af9e523501759a$var$ParsedInstructionStruct = (0, $5DqgT.type)({\n program: (0, $5DqgT.string)(),\n programId: $c3af9e523501759a$var$PublicKeyFromString,\n parsed: (0, $5DqgT.unknown)()\n});\nconst $c3af9e523501759a$var$PartiallyDecodedInstructionStruct = (0, $5DqgT.type)({\n programId: $c3af9e523501759a$var$PublicKeyFromString,\n accounts: (0, $5DqgT.array)($c3af9e523501759a$var$PublicKeyFromString),\n data: (0, $5DqgT.string)()\n});\nconst $c3af9e523501759a$var$SimulatedTransactionResponseStruct = $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.type)({\n err: (0, $5DqgT.nullable)((0, $5DqgT.union)([\n (0, $5DqgT.type)({}),\n (0, $5DqgT.string)()\n ])),\n logs: (0, $5DqgT.nullable)((0, $5DqgT.array)((0, $5DqgT.string)())),\n accounts: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.array)((0, $5DqgT.nullable)((0, $5DqgT.type)({\n executable: (0, $5DqgT.boolean)(),\n owner: (0, $5DqgT.string)(),\n lamports: (0, $5DqgT.number)(),\n data: (0, $5DqgT.array)((0, $5DqgT.string)()),\n rentEpoch: (0, $5DqgT.optional)((0, $5DqgT.number)())\n }))))),\n unitsConsumed: (0, $5DqgT.optional)((0, $5DqgT.number)()),\n returnData: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.type)({\n programId: (0, $5DqgT.string)(),\n data: (0, $5DqgT.tuple)([\n (0, $5DqgT.string)(),\n (0, $5DqgT.literal)('base64')\n ])\n }))),\n innerInstructions: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.array)((0, $5DqgT.type)({\n index: (0, $5DqgT.number)(),\n instructions: (0, $5DqgT.array)((0, $5DqgT.union)([\n $c3af9e523501759a$var$ParsedInstructionStruct,\n $c3af9e523501759a$var$PartiallyDecodedInstructionStruct\n ]))\n }))))\n}));\n/**\n * Metadata for a parsed confirmed transaction on the ledger\n *\n * @deprecated Deprecated since RPC v1.8.0. Please use {@link ParsedTransactionMeta} instead.\n */ /**\n * Collection of addresses loaded by a transaction using address table lookups\n */ /**\n * Metadata for a parsed transaction on the ledger\n */ /**\n * Metadata for a confirmed transaction on the ledger\n */ /**\n * A processed transaction from the RPC API\n */ /**\n * A processed transaction from the RPC API\n */ /**\n * A processed transaction message from the RPC API\n */ /**\n * A confirmed transaction on the ledger\n *\n * @deprecated Deprecated since RPC v1.8.0.\n */ /**\n * A partially decoded transaction instruction\n */ /**\n * A parsed transaction message account\n */ /**\n * A parsed transaction instruction\n */ /**\n * A parsed address table lookup\n */ /**\n * A parsed transaction message\n */ /**\n * A parsed transaction\n */ /**\n * A parsed and confirmed transaction on the ledger\n *\n * @deprecated Deprecated since RPC v1.8.0. Please use {@link ParsedTransactionWithMeta} instead.\n */ /**\n * A parsed transaction on the ledger with meta\n */ /**\n * A processed block fetched from the RPC API\n */ /**\n * A processed block fetched from the RPC API where the `transactionDetails` mode is `accounts`\n */ /**\n * A processed block fetched from the RPC API where the `transactionDetails` mode is `none`\n */ /**\n * A block with parsed transactions\n */ /**\n * A block with parsed transactions where the `transactionDetails` mode is `accounts`\n */ /**\n * A block with parsed transactions where the `transactionDetails` mode is `none`\n */ /**\n * A processed block fetched from the RPC API\n */ /**\n * A processed block fetched from the RPC API where the `transactionDetails` mode is `accounts`\n */ /**\n * A processed block fetched from the RPC API where the `transactionDetails` mode is `none`\n */ /**\n * A confirmed block on the ledger\n *\n * @deprecated Deprecated since RPC v1.8.0.\n */ /**\n * A Block on the ledger with signatures only\n */ /**\n * recent block production information\n */ /**\n * Expected JSON RPC response for the \"getBlockProduction\" message\n */ const $c3af9e523501759a$var$BlockProductionResponseStruct = $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.type)({\n byIdentity: (0, $5DqgT.record)((0, $5DqgT.string)(), (0, $5DqgT.array)((0, $5DqgT.number)())),\n range: (0, $5DqgT.type)({\n firstSlot: (0, $5DqgT.number)(),\n lastSlot: (0, $5DqgT.number)()\n })\n}));\n/**\n * A performance sample\n */ function $c3af9e523501759a$var$createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent) {\n const fetch = customFetch ? customFetch : $c3af9e523501759a$var$fetchImpl;\n let agent;\n if (httpAgent != null) console.warn(\"You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.\");\n let fetchWithMiddleware;\n if (fetchMiddleware) fetchWithMiddleware = async (info, init)=>{\n const modifiedFetchArgs = await new Promise((resolve, reject)=>{\n try {\n fetchMiddleware(info, init, (modifiedInfo, modifiedInit)=>resolve([\n modifiedInfo,\n modifiedInit\n ]));\n } catch (error) {\n reject(error);\n }\n });\n return await fetch(...modifiedFetchArgs);\n };\n const clientBrowser = new (0, (/*@__PURE__*/$parcel$interopDefault($7pfXJ)))(async (request, callback)=>{\n const options = {\n method: 'POST',\n body: request,\n agent: agent,\n headers: Object.assign({\n 'Content-Type': 'application/json'\n }, httpHeaders || {}, $c3af9e523501759a$var$COMMON_HTTP_HEADERS)\n };\n try {\n let too_many_requests_retries = 5;\n let res;\n let waitTime = 500;\n for(;;){\n if (fetchWithMiddleware) res = await fetchWithMiddleware(url, options);\n else res = await fetch(url, options);\n if (res.status !== 429 /* Too many requests */ ) break;\n if (disableRetryOnRateLimit === true) break;\n too_many_requests_retries -= 1;\n if (too_many_requests_retries === 0) break;\n console.error(`Server responded with ${res.status} ${res.statusText}. Retrying after ${waitTime}ms delay...`);\n await $c3af9e523501759a$var$sleep(waitTime);\n waitTime *= 2;\n }\n const text = await res.text();\n if (res.ok) callback(null, text);\n else callback(new Error(`${res.status} ${res.statusText}: ${text}`));\n } catch (err) {\n if (err instanceof Error) callback(err);\n }\n }, {});\n return clientBrowser;\n}\nfunction $c3af9e523501759a$var$createRpcRequest(client) {\n return (method, args)=>{\n return new Promise((resolve, reject)=>{\n client.request(method, args, (err, response)=>{\n if (err) {\n reject(err);\n return;\n }\n resolve(response);\n });\n });\n };\n}\nfunction $c3af9e523501759a$var$createRpcBatchRequest(client) {\n return (requests)=>{\n return new Promise((resolve, reject)=>{\n // Do nothing if requests is empty\n if (requests.length === 0) resolve([]);\n const batch = requests.map((params)=>{\n return client.request(params.methodName, params.args);\n });\n client.request(batch, (err, response)=>{\n if (err) {\n reject(err);\n return;\n }\n resolve(response);\n });\n });\n };\n}\n/**\n * Expected JSON RPC response for the \"getInflationGovernor\" message\n */ const $c3af9e523501759a$var$GetInflationGovernorRpcResult = $c3af9e523501759a$var$jsonRpcResult($c3af9e523501759a$var$GetInflationGovernorResult);\n/**\n * Expected JSON RPC response for the \"getInflationRate\" message\n */ const $c3af9e523501759a$var$GetInflationRateRpcResult = $c3af9e523501759a$var$jsonRpcResult($c3af9e523501759a$var$GetInflationRateResult);\n/**\n * Expected JSON RPC response for the \"getRecentPrioritizationFees\" message\n */ const $c3af9e523501759a$var$GetRecentPrioritizationFeesRpcResult = $c3af9e523501759a$var$jsonRpcResult($c3af9e523501759a$var$GetRecentPrioritizationFeesResult);\n/**\n * Expected JSON RPC response for the \"getEpochInfo\" message\n */ const $c3af9e523501759a$var$GetEpochInfoRpcResult = $c3af9e523501759a$var$jsonRpcResult($c3af9e523501759a$var$GetEpochInfoResult);\n/**\n * Expected JSON RPC response for the \"getEpochSchedule\" message\n */ const $c3af9e523501759a$var$GetEpochScheduleRpcResult = $c3af9e523501759a$var$jsonRpcResult($c3af9e523501759a$var$GetEpochScheduleResult);\n/**\n * Expected JSON RPC response for the \"getLeaderSchedule\" message\n */ const $c3af9e523501759a$var$GetLeaderScheduleRpcResult = $c3af9e523501759a$var$jsonRpcResult($c3af9e523501759a$var$GetLeaderScheduleResult);\n/**\n * Expected JSON RPC response for the \"minimumLedgerSlot\" and \"getFirstAvailableBlock\" messages\n */ const $c3af9e523501759a$var$SlotRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.number)());\n/**\n * Supply\n */ /**\n * Expected JSON RPC response for the \"getSupply\" message\n */ const $c3af9e523501759a$var$GetSupplyRpcResult = $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.type)({\n total: (0, $5DqgT.number)(),\n circulating: (0, $5DqgT.number)(),\n nonCirculating: (0, $5DqgT.number)(),\n nonCirculatingAccounts: (0, $5DqgT.array)($c3af9e523501759a$var$PublicKeyFromString)\n}));\n/**\n * Token amount object which returns a token amount in different formats\n * for various client use cases.\n */ /**\n * Expected JSON RPC structure for token amounts\n */ const $c3af9e523501759a$var$TokenAmountResult = (0, $5DqgT.type)({\n amount: (0, $5DqgT.string)(),\n uiAmount: (0, $5DqgT.nullable)((0, $5DqgT.number)()),\n decimals: (0, $5DqgT.number)(),\n uiAmountString: (0, $5DqgT.optional)((0, $5DqgT.string)())\n});\n/**\n * Token address and balance.\n */ /**\n * Expected JSON RPC response for the \"getTokenLargestAccounts\" message\n */ const $c3af9e523501759a$var$GetTokenLargestAccountsResult = $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.array)((0, $5DqgT.type)({\n address: $c3af9e523501759a$var$PublicKeyFromString,\n amount: (0, $5DqgT.string)(),\n uiAmount: (0, $5DqgT.nullable)((0, $5DqgT.number)()),\n decimals: (0, $5DqgT.number)(),\n uiAmountString: (0, $5DqgT.optional)((0, $5DqgT.string)())\n})));\n/**\n * Expected JSON RPC response for the \"getTokenAccountsByOwner\" message\n */ const $c3af9e523501759a$var$GetTokenAccountsByOwner = $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.array)((0, $5DqgT.type)({\n pubkey: $c3af9e523501759a$var$PublicKeyFromString,\n account: (0, $5DqgT.type)({\n executable: (0, $5DqgT.boolean)(),\n owner: $c3af9e523501759a$var$PublicKeyFromString,\n lamports: (0, $5DqgT.number)(),\n data: $c3af9e523501759a$var$BufferFromRawAccountData,\n rentEpoch: (0, $5DqgT.number)()\n })\n})));\nconst $c3af9e523501759a$var$ParsedAccountDataResult = (0, $5DqgT.type)({\n program: (0, $5DqgT.string)(),\n parsed: (0, $5DqgT.unknown)(),\n space: (0, $5DqgT.number)()\n});\n/**\n * Expected JSON RPC response for the \"getTokenAccountsByOwner\" message with parsed data\n */ const $c3af9e523501759a$var$GetParsedTokenAccountsByOwner = $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.array)((0, $5DqgT.type)({\n pubkey: $c3af9e523501759a$var$PublicKeyFromString,\n account: (0, $5DqgT.type)({\n executable: (0, $5DqgT.boolean)(),\n owner: $c3af9e523501759a$var$PublicKeyFromString,\n lamports: (0, $5DqgT.number)(),\n data: $c3af9e523501759a$var$ParsedAccountDataResult,\n rentEpoch: (0, $5DqgT.number)()\n })\n})));\n/**\n * Pair of an account address and its balance\n */ /**\n * Expected JSON RPC response for the \"getLargestAccounts\" message\n */ const $c3af9e523501759a$var$GetLargestAccountsRpcResult = $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.array)((0, $5DqgT.type)({\n lamports: (0, $5DqgT.number)(),\n address: $c3af9e523501759a$var$PublicKeyFromString\n})));\n/**\n * @internal\n */ const $c3af9e523501759a$var$AccountInfoResult = (0, $5DqgT.type)({\n executable: (0, $5DqgT.boolean)(),\n owner: $c3af9e523501759a$var$PublicKeyFromString,\n lamports: (0, $5DqgT.number)(),\n data: $c3af9e523501759a$var$BufferFromRawAccountData,\n rentEpoch: (0, $5DqgT.number)()\n});\n/**\n * @internal\n */ const $c3af9e523501759a$var$KeyedAccountInfoResult = (0, $5DqgT.type)({\n pubkey: $c3af9e523501759a$var$PublicKeyFromString,\n account: $c3af9e523501759a$var$AccountInfoResult\n});\nconst $c3af9e523501759a$var$ParsedOrRawAccountData = (0, $5DqgT.coerce)((0, $5DqgT.union)([\n (0, $5DqgT.instance)((0, $6ZWSX.Buffer)),\n $c3af9e523501759a$var$ParsedAccountDataResult\n]), (0, $5DqgT.union)([\n $c3af9e523501759a$var$RawAccountDataResult,\n $c3af9e523501759a$var$ParsedAccountDataResult\n]), (value)=>{\n if (Array.isArray(value)) return (0, $5DqgT.create)(value, $c3af9e523501759a$var$BufferFromRawAccountData);\n else return value;\n});\n/**\n * @internal\n */ const $c3af9e523501759a$var$ParsedAccountInfoResult = (0, $5DqgT.type)({\n executable: (0, $5DqgT.boolean)(),\n owner: $c3af9e523501759a$var$PublicKeyFromString,\n lamports: (0, $5DqgT.number)(),\n data: $c3af9e523501759a$var$ParsedOrRawAccountData,\n rentEpoch: (0, $5DqgT.number)()\n});\nconst $c3af9e523501759a$var$KeyedParsedAccountInfoResult = (0, $5DqgT.type)({\n pubkey: $c3af9e523501759a$var$PublicKeyFromString,\n account: $c3af9e523501759a$var$ParsedAccountInfoResult\n});\n/**\n * @internal\n */ const $c3af9e523501759a$var$StakeActivationResult = (0, $5DqgT.type)({\n state: (0, $5DqgT.union)([\n (0, $5DqgT.literal)('active'),\n (0, $5DqgT.literal)('inactive'),\n (0, $5DqgT.literal)('activating'),\n (0, $5DqgT.literal)('deactivating')\n ]),\n active: (0, $5DqgT.number)(),\n inactive: (0, $5DqgT.number)()\n});\n/**\n * Expected JSON RPC response for the \"getConfirmedSignaturesForAddress2\" message\n */ const $c3af9e523501759a$var$GetConfirmedSignaturesForAddress2RpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.array)((0, $5DqgT.type)({\n signature: (0, $5DqgT.string)(),\n slot: (0, $5DqgT.number)(),\n err: $c3af9e523501759a$var$TransactionErrorResult,\n memo: (0, $5DqgT.nullable)((0, $5DqgT.string)()),\n blockTime: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.number)()))\n})));\n/**\n * Expected JSON RPC response for the \"getSignaturesForAddress\" message\n */ const $c3af9e523501759a$var$GetSignaturesForAddressRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.array)((0, $5DqgT.type)({\n signature: (0, $5DqgT.string)(),\n slot: (0, $5DqgT.number)(),\n err: $c3af9e523501759a$var$TransactionErrorResult,\n memo: (0, $5DqgT.nullable)((0, $5DqgT.string)()),\n blockTime: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.number)()))\n})));\n/***\n * Expected JSON RPC response for the \"accountNotification\" message\n */ const $c3af9e523501759a$var$AccountNotificationResult = (0, $5DqgT.type)({\n subscription: (0, $5DqgT.number)(),\n result: $c3af9e523501759a$var$notificationResultAndContext($c3af9e523501759a$var$AccountInfoResult)\n});\n/**\n * @internal\n */ const $c3af9e523501759a$var$ProgramAccountInfoResult = (0, $5DqgT.type)({\n pubkey: $c3af9e523501759a$var$PublicKeyFromString,\n account: $c3af9e523501759a$var$AccountInfoResult\n});\n/***\n * Expected JSON RPC response for the \"programNotification\" message\n */ const $c3af9e523501759a$var$ProgramAccountNotificationResult = (0, $5DqgT.type)({\n subscription: (0, $5DqgT.number)(),\n result: $c3af9e523501759a$var$notificationResultAndContext($c3af9e523501759a$var$ProgramAccountInfoResult)\n});\n/**\n * @internal\n */ const $c3af9e523501759a$var$SlotInfoResult = (0, $5DqgT.type)({\n parent: (0, $5DqgT.number)(),\n slot: (0, $5DqgT.number)(),\n root: (0, $5DqgT.number)()\n});\n/**\n * Expected JSON RPC response for the \"slotNotification\" message\n */ const $c3af9e523501759a$var$SlotNotificationResult = (0, $5DqgT.type)({\n subscription: (0, $5DqgT.number)(),\n result: $c3af9e523501759a$var$SlotInfoResult\n});\n/**\n * Slot updates which can be used for tracking the live progress of a cluster.\n * - `\"firstShredReceived\"`: connected node received the first shred of a block.\n * Indicates that a new block that is being produced.\n * - `\"completed\"`: connected node has received all shreds of a block. Indicates\n * a block was recently produced.\n * - `\"optimisticConfirmation\"`: block was optimistically confirmed by the\n * cluster. It is not guaranteed that an optimistic confirmation notification\n * will be sent for every finalized blocks.\n * - `\"root\"`: the connected node rooted this block.\n * - `\"createdBank\"`: the connected node has started validating this block.\n * - `\"frozen\"`: the connected node has validated this block.\n * - `\"dead\"`: the connected node failed to validate this block.\n */ /**\n * @internal\n */ const $c3af9e523501759a$var$SlotUpdateResult = (0, $5DqgT.union)([\n (0, $5DqgT.type)({\n type: (0, $5DqgT.union)([\n (0, $5DqgT.literal)('firstShredReceived'),\n (0, $5DqgT.literal)('completed'),\n (0, $5DqgT.literal)('optimisticConfirmation'),\n (0, $5DqgT.literal)('root')\n ]),\n slot: (0, $5DqgT.number)(),\n timestamp: (0, $5DqgT.number)()\n }),\n (0, $5DqgT.type)({\n type: (0, $5DqgT.literal)('createdBank'),\n parent: (0, $5DqgT.number)(),\n slot: (0, $5DqgT.number)(),\n timestamp: (0, $5DqgT.number)()\n }),\n (0, $5DqgT.type)({\n type: (0, $5DqgT.literal)('frozen'),\n slot: (0, $5DqgT.number)(),\n timestamp: (0, $5DqgT.number)(),\n stats: (0, $5DqgT.type)({\n numTransactionEntries: (0, $5DqgT.number)(),\n numSuccessfulTransactions: (0, $5DqgT.number)(),\n numFailedTransactions: (0, $5DqgT.number)(),\n maxTransactionsPerEntry: (0, $5DqgT.number)()\n })\n }),\n (0, $5DqgT.type)({\n type: (0, $5DqgT.literal)('dead'),\n slot: (0, $5DqgT.number)(),\n timestamp: (0, $5DqgT.number)(),\n err: (0, $5DqgT.string)()\n })\n]);\n/**\n * Expected JSON RPC response for the \"slotsUpdatesNotification\" message\n */ const $c3af9e523501759a$var$SlotUpdateNotificationResult = (0, $5DqgT.type)({\n subscription: (0, $5DqgT.number)(),\n result: $c3af9e523501759a$var$SlotUpdateResult\n});\n/**\n * Expected JSON RPC response for the \"signatureNotification\" message\n */ const $c3af9e523501759a$var$SignatureNotificationResult = (0, $5DqgT.type)({\n subscription: (0, $5DqgT.number)(),\n result: $c3af9e523501759a$var$notificationResultAndContext((0, $5DqgT.union)([\n $c3af9e523501759a$var$SignatureStatusResult,\n $c3af9e523501759a$var$SignatureReceivedResult\n ]))\n});\n/**\n * Expected JSON RPC response for the \"rootNotification\" message\n */ const $c3af9e523501759a$var$RootNotificationResult = (0, $5DqgT.type)({\n subscription: (0, $5DqgT.number)(),\n result: (0, $5DqgT.number)()\n});\nconst $c3af9e523501759a$var$ContactInfoResult = (0, $5DqgT.type)({\n pubkey: (0, $5DqgT.string)(),\n gossip: (0, $5DqgT.nullable)((0, $5DqgT.string)()),\n tpu: (0, $5DqgT.nullable)((0, $5DqgT.string)()),\n rpc: (0, $5DqgT.nullable)((0, $5DqgT.string)()),\n version: (0, $5DqgT.nullable)((0, $5DqgT.string)())\n});\nconst $c3af9e523501759a$var$VoteAccountInfoResult = (0, $5DqgT.type)({\n votePubkey: (0, $5DqgT.string)(),\n nodePubkey: (0, $5DqgT.string)(),\n activatedStake: (0, $5DqgT.number)(),\n epochVoteAccount: (0, $5DqgT.boolean)(),\n epochCredits: (0, $5DqgT.array)((0, $5DqgT.tuple)([\n (0, $5DqgT.number)(),\n (0, $5DqgT.number)(),\n (0, $5DqgT.number)()\n ])),\n commission: (0, $5DqgT.number)(),\n lastVote: (0, $5DqgT.number)(),\n rootSlot: (0, $5DqgT.nullable)((0, $5DqgT.number)())\n});\n/**\n * Expected JSON RPC response for the \"getVoteAccounts\" message\n */ const $c3af9e523501759a$var$GetVoteAccounts = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.type)({\n current: (0, $5DqgT.array)($c3af9e523501759a$var$VoteAccountInfoResult),\n delinquent: (0, $5DqgT.array)($c3af9e523501759a$var$VoteAccountInfoResult)\n}));\nconst $c3af9e523501759a$var$ConfirmationStatus = (0, $5DqgT.union)([\n (0, $5DqgT.literal)('processed'),\n (0, $5DqgT.literal)('confirmed'),\n (0, $5DqgT.literal)('finalized')\n]);\nconst $c3af9e523501759a$var$SignatureStatusResponse = (0, $5DqgT.type)({\n slot: (0, $5DqgT.number)(),\n confirmations: (0, $5DqgT.nullable)((0, $5DqgT.number)()),\n err: $c3af9e523501759a$var$TransactionErrorResult,\n confirmationStatus: (0, $5DqgT.optional)($c3af9e523501759a$var$ConfirmationStatus)\n});\n/**\n * Expected JSON RPC response for the \"getSignatureStatuses\" message\n */ const $c3af9e523501759a$var$GetSignatureStatusesRpcResult = $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.array)((0, $5DqgT.nullable)($c3af9e523501759a$var$SignatureStatusResponse)));\n/**\n * Expected JSON RPC response for the \"getMinimumBalanceForRentExemption\" message\n */ const $c3af9e523501759a$var$GetMinimumBalanceForRentExemptionRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.number)());\nconst $c3af9e523501759a$var$AddressTableLookupStruct = (0, $5DqgT.type)({\n accountKey: $c3af9e523501759a$var$PublicKeyFromString,\n writableIndexes: (0, $5DqgT.array)((0, $5DqgT.number)()),\n readonlyIndexes: (0, $5DqgT.array)((0, $5DqgT.number)())\n});\nconst $c3af9e523501759a$var$ConfirmedTransactionResult = (0, $5DqgT.type)({\n signatures: (0, $5DqgT.array)((0, $5DqgT.string)()),\n message: (0, $5DqgT.type)({\n accountKeys: (0, $5DqgT.array)((0, $5DqgT.string)()),\n header: (0, $5DqgT.type)({\n numRequiredSignatures: (0, $5DqgT.number)(),\n numReadonlySignedAccounts: (0, $5DqgT.number)(),\n numReadonlyUnsignedAccounts: (0, $5DqgT.number)()\n }),\n instructions: (0, $5DqgT.array)((0, $5DqgT.type)({\n accounts: (0, $5DqgT.array)((0, $5DqgT.number)()),\n data: (0, $5DqgT.string)(),\n programIdIndex: (0, $5DqgT.number)()\n })),\n recentBlockhash: (0, $5DqgT.string)(),\n addressTableLookups: (0, $5DqgT.optional)((0, $5DqgT.array)($c3af9e523501759a$var$AddressTableLookupStruct))\n })\n});\nconst $c3af9e523501759a$var$AnnotatedAccountKey = (0, $5DqgT.type)({\n pubkey: $c3af9e523501759a$var$PublicKeyFromString,\n signer: (0, $5DqgT.boolean)(),\n writable: (0, $5DqgT.boolean)(),\n source: (0, $5DqgT.optional)((0, $5DqgT.union)([\n (0, $5DqgT.literal)('transaction'),\n (0, $5DqgT.literal)('lookupTable')\n ]))\n});\nconst $c3af9e523501759a$var$ConfirmedTransactionAccountsModeResult = (0, $5DqgT.type)({\n accountKeys: (0, $5DqgT.array)($c3af9e523501759a$var$AnnotatedAccountKey),\n signatures: (0, $5DqgT.array)((0, $5DqgT.string)())\n});\nconst $c3af9e523501759a$var$ParsedInstructionResult = (0, $5DqgT.type)({\n parsed: (0, $5DqgT.unknown)(),\n program: (0, $5DqgT.string)(),\n programId: $c3af9e523501759a$var$PublicKeyFromString\n});\nconst $c3af9e523501759a$var$RawInstructionResult = (0, $5DqgT.type)({\n accounts: (0, $5DqgT.array)($c3af9e523501759a$var$PublicKeyFromString),\n data: (0, $5DqgT.string)(),\n programId: $c3af9e523501759a$var$PublicKeyFromString\n});\nconst $c3af9e523501759a$var$InstructionResult = (0, $5DqgT.union)([\n $c3af9e523501759a$var$RawInstructionResult,\n $c3af9e523501759a$var$ParsedInstructionResult\n]);\nconst $c3af9e523501759a$var$UnknownInstructionResult = (0, $5DqgT.union)([\n (0, $5DqgT.type)({\n parsed: (0, $5DqgT.unknown)(),\n program: (0, $5DqgT.string)(),\n programId: (0, $5DqgT.string)()\n }),\n (0, $5DqgT.type)({\n accounts: (0, $5DqgT.array)((0, $5DqgT.string)()),\n data: (0, $5DqgT.string)(),\n programId: (0, $5DqgT.string)()\n })\n]);\nconst $c3af9e523501759a$var$ParsedOrRawInstruction = (0, $5DqgT.coerce)($c3af9e523501759a$var$InstructionResult, $c3af9e523501759a$var$UnknownInstructionResult, (value)=>{\n if ('accounts' in value) return (0, $5DqgT.create)(value, $c3af9e523501759a$var$RawInstructionResult);\n else return (0, $5DqgT.create)(value, $c3af9e523501759a$var$ParsedInstructionResult);\n});\n/**\n * @internal\n */ const $c3af9e523501759a$var$ParsedConfirmedTransactionResult = (0, $5DqgT.type)({\n signatures: (0, $5DqgT.array)((0, $5DqgT.string)()),\n message: (0, $5DqgT.type)({\n accountKeys: (0, $5DqgT.array)($c3af9e523501759a$var$AnnotatedAccountKey),\n instructions: (0, $5DqgT.array)($c3af9e523501759a$var$ParsedOrRawInstruction),\n recentBlockhash: (0, $5DqgT.string)(),\n addressTableLookups: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.array)($c3af9e523501759a$var$AddressTableLookupStruct)))\n })\n});\nconst $c3af9e523501759a$var$TokenBalanceResult = (0, $5DqgT.type)({\n accountIndex: (0, $5DqgT.number)(),\n mint: (0, $5DqgT.string)(),\n owner: (0, $5DqgT.optional)((0, $5DqgT.string)()),\n programId: (0, $5DqgT.optional)((0, $5DqgT.string)()),\n uiTokenAmount: $c3af9e523501759a$var$TokenAmountResult\n});\nconst $c3af9e523501759a$var$LoadedAddressesResult = (0, $5DqgT.type)({\n writable: (0, $5DqgT.array)($c3af9e523501759a$var$PublicKeyFromString),\n readonly: (0, $5DqgT.array)($c3af9e523501759a$var$PublicKeyFromString)\n});\n/**\n * @internal\n */ const $c3af9e523501759a$var$ConfirmedTransactionMetaResult = (0, $5DqgT.type)({\n err: $c3af9e523501759a$var$TransactionErrorResult,\n fee: (0, $5DqgT.number)(),\n innerInstructions: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.array)((0, $5DqgT.type)({\n index: (0, $5DqgT.number)(),\n instructions: (0, $5DqgT.array)((0, $5DqgT.type)({\n accounts: (0, $5DqgT.array)((0, $5DqgT.number)()),\n data: (0, $5DqgT.string)(),\n programIdIndex: (0, $5DqgT.number)()\n }))\n })))),\n preBalances: (0, $5DqgT.array)((0, $5DqgT.number)()),\n postBalances: (0, $5DqgT.array)((0, $5DqgT.number)()),\n logMessages: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.array)((0, $5DqgT.string)()))),\n preTokenBalances: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.array)($c3af9e523501759a$var$TokenBalanceResult))),\n postTokenBalances: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.array)($c3af9e523501759a$var$TokenBalanceResult))),\n loadedAddresses: (0, $5DqgT.optional)($c3af9e523501759a$var$LoadedAddressesResult),\n computeUnitsConsumed: (0, $5DqgT.optional)((0, $5DqgT.number)())\n});\n/**\n * @internal\n */ const $c3af9e523501759a$var$ParsedConfirmedTransactionMetaResult = (0, $5DqgT.type)({\n err: $c3af9e523501759a$var$TransactionErrorResult,\n fee: (0, $5DqgT.number)(),\n innerInstructions: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.array)((0, $5DqgT.type)({\n index: (0, $5DqgT.number)(),\n instructions: (0, $5DqgT.array)($c3af9e523501759a$var$ParsedOrRawInstruction)\n })))),\n preBalances: (0, $5DqgT.array)((0, $5DqgT.number)()),\n postBalances: (0, $5DqgT.array)((0, $5DqgT.number)()),\n logMessages: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.array)((0, $5DqgT.string)()))),\n preTokenBalances: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.array)($c3af9e523501759a$var$TokenBalanceResult))),\n postTokenBalances: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.array)($c3af9e523501759a$var$TokenBalanceResult))),\n loadedAddresses: (0, $5DqgT.optional)($c3af9e523501759a$var$LoadedAddressesResult),\n computeUnitsConsumed: (0, $5DqgT.optional)((0, $5DqgT.number)())\n});\nconst $c3af9e523501759a$var$TransactionVersionStruct = (0, $5DqgT.union)([\n (0, $5DqgT.literal)(0),\n (0, $5DqgT.literal)('legacy')\n]);\n/** @internal */ const $c3af9e523501759a$var$RewardsResult = (0, $5DqgT.type)({\n pubkey: (0, $5DqgT.string)(),\n lamports: (0, $5DqgT.number)(),\n postBalance: (0, $5DqgT.nullable)((0, $5DqgT.number)()),\n rewardType: (0, $5DqgT.nullable)((0, $5DqgT.string)()),\n commission: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.number)()))\n});\n/**\n * Expected JSON RPC response for the \"getBlock\" message\n */ const $c3af9e523501759a$var$GetBlockRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.nullable)((0, $5DqgT.type)({\n blockhash: (0, $5DqgT.string)(),\n previousBlockhash: (0, $5DqgT.string)(),\n parentSlot: (0, $5DqgT.number)(),\n transactions: (0, $5DqgT.array)((0, $5DqgT.type)({\n transaction: $c3af9e523501759a$var$ConfirmedTransactionResult,\n meta: (0, $5DqgT.nullable)($c3af9e523501759a$var$ConfirmedTransactionMetaResult),\n version: (0, $5DqgT.optional)($c3af9e523501759a$var$TransactionVersionStruct)\n })),\n rewards: (0, $5DqgT.optional)((0, $5DqgT.array)($c3af9e523501759a$var$RewardsResult)),\n blockTime: (0, $5DqgT.nullable)((0, $5DqgT.number)()),\n blockHeight: (0, $5DqgT.nullable)((0, $5DqgT.number)())\n})));\n/**\n * Expected JSON RPC response for the \"getBlock\" message when `transactionDetails` is `none`\n */ const $c3af9e523501759a$var$GetNoneModeBlockRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.nullable)((0, $5DqgT.type)({\n blockhash: (0, $5DqgT.string)(),\n previousBlockhash: (0, $5DqgT.string)(),\n parentSlot: (0, $5DqgT.number)(),\n rewards: (0, $5DqgT.optional)((0, $5DqgT.array)($c3af9e523501759a$var$RewardsResult)),\n blockTime: (0, $5DqgT.nullable)((0, $5DqgT.number)()),\n blockHeight: (0, $5DqgT.nullable)((0, $5DqgT.number)())\n})));\n/**\n * Expected JSON RPC response for the \"getBlock\" message when `transactionDetails` is `accounts`\n */ const $c3af9e523501759a$var$GetAccountsModeBlockRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.nullable)((0, $5DqgT.type)({\n blockhash: (0, $5DqgT.string)(),\n previousBlockhash: (0, $5DqgT.string)(),\n parentSlot: (0, $5DqgT.number)(),\n transactions: (0, $5DqgT.array)((0, $5DqgT.type)({\n transaction: $c3af9e523501759a$var$ConfirmedTransactionAccountsModeResult,\n meta: (0, $5DqgT.nullable)($c3af9e523501759a$var$ConfirmedTransactionMetaResult),\n version: (0, $5DqgT.optional)($c3af9e523501759a$var$TransactionVersionStruct)\n })),\n rewards: (0, $5DqgT.optional)((0, $5DqgT.array)($c3af9e523501759a$var$RewardsResult)),\n blockTime: (0, $5DqgT.nullable)((0, $5DqgT.number)()),\n blockHeight: (0, $5DqgT.nullable)((0, $5DqgT.number)())\n})));\n/**\n * Expected parsed JSON RPC response for the \"getBlock\" message\n */ const $c3af9e523501759a$var$GetParsedBlockRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.nullable)((0, $5DqgT.type)({\n blockhash: (0, $5DqgT.string)(),\n previousBlockhash: (0, $5DqgT.string)(),\n parentSlot: (0, $5DqgT.number)(),\n transactions: (0, $5DqgT.array)((0, $5DqgT.type)({\n transaction: $c3af9e523501759a$var$ParsedConfirmedTransactionResult,\n meta: (0, $5DqgT.nullable)($c3af9e523501759a$var$ParsedConfirmedTransactionMetaResult),\n version: (0, $5DqgT.optional)($c3af9e523501759a$var$TransactionVersionStruct)\n })),\n rewards: (0, $5DqgT.optional)((0, $5DqgT.array)($c3af9e523501759a$var$RewardsResult)),\n blockTime: (0, $5DqgT.nullable)((0, $5DqgT.number)()),\n blockHeight: (0, $5DqgT.nullable)((0, $5DqgT.number)())\n})));\n/**\n * Expected parsed JSON RPC response for the \"getBlock\" message when `transactionDetails` is `accounts`\n */ const $c3af9e523501759a$var$GetParsedAccountsModeBlockRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.nullable)((0, $5DqgT.type)({\n blockhash: (0, $5DqgT.string)(),\n previousBlockhash: (0, $5DqgT.string)(),\n parentSlot: (0, $5DqgT.number)(),\n transactions: (0, $5DqgT.array)((0, $5DqgT.type)({\n transaction: $c3af9e523501759a$var$ConfirmedTransactionAccountsModeResult,\n meta: (0, $5DqgT.nullable)($c3af9e523501759a$var$ParsedConfirmedTransactionMetaResult),\n version: (0, $5DqgT.optional)($c3af9e523501759a$var$TransactionVersionStruct)\n })),\n rewards: (0, $5DqgT.optional)((0, $5DqgT.array)($c3af9e523501759a$var$RewardsResult)),\n blockTime: (0, $5DqgT.nullable)((0, $5DqgT.number)()),\n blockHeight: (0, $5DqgT.nullable)((0, $5DqgT.number)())\n})));\n/**\n * Expected parsed JSON RPC response for the \"getBlock\" message when `transactionDetails` is `none`\n */ const $c3af9e523501759a$var$GetParsedNoneModeBlockRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.nullable)((0, $5DqgT.type)({\n blockhash: (0, $5DqgT.string)(),\n previousBlockhash: (0, $5DqgT.string)(),\n parentSlot: (0, $5DqgT.number)(),\n rewards: (0, $5DqgT.optional)((0, $5DqgT.array)($c3af9e523501759a$var$RewardsResult)),\n blockTime: (0, $5DqgT.nullable)((0, $5DqgT.number)()),\n blockHeight: (0, $5DqgT.nullable)((0, $5DqgT.number)())\n})));\n/**\n * Expected JSON RPC response for the \"getConfirmedBlock\" message\n *\n * @deprecated Deprecated since RPC v1.8.0. Please use {@link GetBlockRpcResult} instead.\n */ const $c3af9e523501759a$var$GetConfirmedBlockRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.nullable)((0, $5DqgT.type)({\n blockhash: (0, $5DqgT.string)(),\n previousBlockhash: (0, $5DqgT.string)(),\n parentSlot: (0, $5DqgT.number)(),\n transactions: (0, $5DqgT.array)((0, $5DqgT.type)({\n transaction: $c3af9e523501759a$var$ConfirmedTransactionResult,\n meta: (0, $5DqgT.nullable)($c3af9e523501759a$var$ConfirmedTransactionMetaResult)\n })),\n rewards: (0, $5DqgT.optional)((0, $5DqgT.array)($c3af9e523501759a$var$RewardsResult)),\n blockTime: (0, $5DqgT.nullable)((0, $5DqgT.number)())\n})));\n/**\n * Expected JSON RPC response for the \"getBlock\" message\n */ const $c3af9e523501759a$var$GetBlockSignaturesRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.nullable)((0, $5DqgT.type)({\n blockhash: (0, $5DqgT.string)(),\n previousBlockhash: (0, $5DqgT.string)(),\n parentSlot: (0, $5DqgT.number)(),\n signatures: (0, $5DqgT.array)((0, $5DqgT.string)()),\n blockTime: (0, $5DqgT.nullable)((0, $5DqgT.number)())\n})));\n/**\n * Expected JSON RPC response for the \"getTransaction\" message\n */ const $c3af9e523501759a$var$GetTransactionRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.nullable)((0, $5DqgT.type)({\n slot: (0, $5DqgT.number)(),\n meta: (0, $5DqgT.nullable)($c3af9e523501759a$var$ConfirmedTransactionMetaResult),\n blockTime: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.number)())),\n transaction: $c3af9e523501759a$var$ConfirmedTransactionResult,\n version: (0, $5DqgT.optional)($c3af9e523501759a$var$TransactionVersionStruct)\n})));\n/**\n * Expected parsed JSON RPC response for the \"getTransaction\" message\n */ const $c3af9e523501759a$var$GetParsedTransactionRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.nullable)((0, $5DqgT.type)({\n slot: (0, $5DqgT.number)(),\n transaction: $c3af9e523501759a$var$ParsedConfirmedTransactionResult,\n meta: (0, $5DqgT.nullable)($c3af9e523501759a$var$ParsedConfirmedTransactionMetaResult),\n blockTime: (0, $5DqgT.optional)((0, $5DqgT.nullable)((0, $5DqgT.number)())),\n version: (0, $5DqgT.optional)($c3af9e523501759a$var$TransactionVersionStruct)\n})));\n/**\n * Expected JSON RPC response for the \"getLatestBlockhash\" message\n */ const $c3af9e523501759a$var$GetLatestBlockhashRpcResult = $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.type)({\n blockhash: (0, $5DqgT.string)(),\n lastValidBlockHeight: (0, $5DqgT.number)()\n}));\n/**\n * Expected JSON RPC response for the \"isBlockhashValid\" message\n */ const $c3af9e523501759a$var$IsBlockhashValidRpcResult = $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.boolean)());\nconst $c3af9e523501759a$var$PerfSampleResult = (0, $5DqgT.type)({\n slot: (0, $5DqgT.number)(),\n numTransactions: (0, $5DqgT.number)(),\n numSlots: (0, $5DqgT.number)(),\n samplePeriodSecs: (0, $5DqgT.number)()\n});\n/*\n * Expected JSON RPC response for \"getRecentPerformanceSamples\" message\n */ const $c3af9e523501759a$var$GetRecentPerformanceSamplesRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.array)($c3af9e523501759a$var$PerfSampleResult));\n/**\n * Expected JSON RPC response for the \"getFeeCalculatorForBlockhash\" message\n */ const $c3af9e523501759a$var$GetFeeCalculatorRpcResult = $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.nullable)((0, $5DqgT.type)({\n feeCalculator: (0, $5DqgT.type)({\n lamportsPerSignature: (0, $5DqgT.number)()\n })\n})));\n/**\n * Expected JSON RPC response for the \"requestAirdrop\" message\n */ const $c3af9e523501759a$var$RequestAirdropRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.string)());\n/**\n * Expected JSON RPC response for the \"sendTransaction\" message\n */ const $c3af9e523501759a$var$SendTransactionRpcResult = $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.string)());\n/**\n * Information about the latest slot being processed by a node\n */ /**\n * Parsed account data\n */ /**\n * Stake Activation data\n */ /**\n * Data slice argument for getProgramAccounts\n */ /**\n * Memory comparison filter for getProgramAccounts\n */ /**\n * Data size comparison filter for getProgramAccounts\n */ /**\n * A filter object for getProgramAccounts\n */ /**\n * Configuration object for getProgramAccounts requests\n */ /**\n * Configuration object for getParsedProgramAccounts\n */ /**\n * Configuration object for getMultipleAccounts\n */ /**\n * Configuration object for `getStakeActivation`\n */ /**\n * Configuration object for `getStakeActivation`\n */ /**\n * Configuration object for `getStakeActivation`\n */ /**\n * Configuration object for `getNonce`\n */ /**\n * Configuration object for `getNonceAndContext`\n */ /**\n * Information describing an account\n */ /**\n * Account information identified by pubkey\n */ /**\n * Callback function for account change notifications\n */ /**\n * Callback function for program account change notifications\n */ /**\n * Callback function for slot change notifications\n */ /**\n * Callback function for slot update notifications\n */ /**\n * Callback function for signature status notifications\n */ /**\n * Signature status notification with transaction result\n */ /**\n * Signature received notification\n */ /**\n * Callback function for signature notifications\n */ /**\n * Signature subscription options\n */ /**\n * Callback function for root change notifications\n */ /**\n * @internal\n */ const $c3af9e523501759a$var$LogsResult = (0, $5DqgT.type)({\n err: $c3af9e523501759a$var$TransactionErrorResult,\n logs: (0, $5DqgT.array)((0, $5DqgT.string)()),\n signature: (0, $5DqgT.string)()\n});\n/**\n * Logs result.\n */ /**\n * Expected JSON RPC response for the \"logsNotification\" message.\n */ const $c3af9e523501759a$var$LogsNotificationResult = (0, $5DqgT.type)({\n result: $c3af9e523501759a$var$notificationResultAndContext($c3af9e523501759a$var$LogsResult),\n subscription: (0, $5DqgT.number)()\n});\n/**\n * Filter for log subscriptions.\n */ /**\n * Callback function for log notifications.\n */ /**\n * Signature result\n */ /**\n * Transaction error\n */ /**\n * Transaction confirmation status\n *
\n *   'processed': Transaction landed in a block which has reached 1 confirmation by the connected node\n *   'confirmed': Transaction landed in a block which has reached 1 confirmation by the cluster\n *   'finalized': Transaction landed in a block which has been finalized by the cluster\n * 
\n */ /**\n * Signature status\n */ /**\n * A confirmed signature with its status\n */ /**\n * An object defining headers to be passed to the RPC server\n */ /**\n * The type of the JavaScript `fetch()` API\n */ /**\n * A callback used to augment the outgoing HTTP request\n */ /**\n * Configuration for instantiating a Connection\n */ /** @internal */ const $c3af9e523501759a$var$COMMON_HTTP_HEADERS = {\n 'solana-client': `js/${\"1.0.0-maintenance\"}`\n};\n/**\n * A connection to a fullnode JSON RPC endpoint\n */ class $c3af9e523501759a$export$98b66c25bb38499d {\n /**\n * Establish a JSON RPC connection\n *\n * @param endpoint URL to the fullnode JSON RPC endpoint\n * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object\n */ constructor(endpoint, _commitmentOrConfig){\n /** @internal */ this._commitment = void 0;\n /** @internal */ this._confirmTransactionInitialTimeout = void 0;\n /** @internal */ this._rpcEndpoint = void 0;\n /** @internal */ this._rpcWsEndpoint = void 0;\n /** @internal */ this._rpcClient = void 0;\n /** @internal */ this._rpcRequest = void 0;\n /** @internal */ this._rpcBatchRequest = void 0;\n /** @internal */ this._rpcWebSocket = void 0;\n /** @internal */ this._rpcWebSocketConnected = false;\n /** @internal */ this._rpcWebSocketHeartbeat = null;\n /** @internal */ this._rpcWebSocketIdleTimeout = null;\n /** @internal\n * A number that we increment every time an active connection closes.\n * Used to determine whether the same socket connection that was open\n * when an async operation started is the same one that's active when\n * its continuation fires.\n *\n */ this._rpcWebSocketGeneration = 0;\n /** @internal */ this._disableBlockhashCaching = false;\n /** @internal */ this._pollingBlockhash = false;\n /** @internal */ this._blockhashInfo = {\n latestBlockhash: null,\n lastFetch: 0,\n transactionSignatures: [],\n simulatedSignatures: []\n };\n /** @internal */ this._nextClientSubscriptionId = 0;\n /** @internal */ this._subscriptionDisposeFunctionsByClientSubscriptionId = {};\n /** @internal */ this._subscriptionHashByClientSubscriptionId = {};\n /** @internal */ this._subscriptionStateChangeCallbacksByHash = {};\n /** @internal */ this._subscriptionCallbacksByServerSubscriptionId = {};\n /** @internal */ this._subscriptionsByHash = {};\n /**\n * Special case.\n * After a signature is processed, RPCs automatically dispose of the\n * subscription on the server side. We need to track which of these\n * subscriptions have been disposed in such a way, so that we know\n * whether the client is dealing with a not-yet-processed signature\n * (in which case we must tear down the server subscription) or an\n * already-processed signature (in which case the client can simply\n * clear out the subscription locally without telling the server).\n *\n * NOTE: There is a proposal to eliminate this special case, here:\n * https://github.com/solana-labs/solana/issues/18892\n */ /** @internal */ this._subscriptionsAutoDisposedByRpc = new Set();\n /*\n * Returns the current block height of the node\n */ this.getBlockHeight = (()=>{\n const requestPromises = {};\n return async (commitmentOrConfig)=>{\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([], commitment, undefined /* encoding */ , config);\n const requestHash = $c3af9e523501759a$var$fastStableStringify(args);\n requestPromises[requestHash] = requestPromises[requestHash] ?? (async ()=>{\n try {\n const unsafeRes = await this._rpcRequest('getBlockHeight', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.number)()));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get block height information');\n return res.result;\n } finally{\n delete requestPromises[requestHash];\n }\n })();\n return await requestPromises[requestHash];\n };\n })();\n let wsEndpoint;\n let httpHeaders;\n let fetch;\n let fetchMiddleware;\n let disableRetryOnRateLimit;\n let httpAgent;\n if (_commitmentOrConfig && typeof _commitmentOrConfig === 'string') this._commitment = _commitmentOrConfig;\n else if (_commitmentOrConfig) {\n this._commitment = _commitmentOrConfig.commitment;\n this._confirmTransactionInitialTimeout = _commitmentOrConfig.confirmTransactionInitialTimeout;\n wsEndpoint = _commitmentOrConfig.wsEndpoint;\n httpHeaders = _commitmentOrConfig.httpHeaders;\n fetch = _commitmentOrConfig.fetch;\n fetchMiddleware = _commitmentOrConfig.fetchMiddleware;\n disableRetryOnRateLimit = _commitmentOrConfig.disableRetryOnRateLimit;\n httpAgent = _commitmentOrConfig.httpAgent;\n }\n this._rpcEndpoint = $c3af9e523501759a$var$assertEndpointUrl(endpoint);\n this._rpcWsEndpoint = wsEndpoint || $c3af9e523501759a$var$makeWebsocketUrl(endpoint);\n this._rpcClient = $c3af9e523501759a$var$createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent);\n this._rpcRequest = $c3af9e523501759a$var$createRpcRequest(this._rpcClient);\n this._rpcBatchRequest = $c3af9e523501759a$var$createRpcBatchRequest(this._rpcClient);\n this._rpcWebSocket = new $c3af9e523501759a$var$RpcWebSocketClient(this._rpcWsEndpoint, {\n autoconnect: false,\n max_reconnects: Infinity\n });\n this._rpcWebSocket.on('open', this._wsOnOpen.bind(this));\n this._rpcWebSocket.on('error', this._wsOnError.bind(this));\n this._rpcWebSocket.on('close', this._wsOnClose.bind(this));\n this._rpcWebSocket.on('accountNotification', this._wsOnAccountNotification.bind(this));\n this._rpcWebSocket.on('programNotification', this._wsOnProgramAccountNotification.bind(this));\n this._rpcWebSocket.on('slotNotification', this._wsOnSlotNotification.bind(this));\n this._rpcWebSocket.on('slotsUpdatesNotification', this._wsOnSlotUpdatesNotification.bind(this));\n this._rpcWebSocket.on('signatureNotification', this._wsOnSignatureNotification.bind(this));\n this._rpcWebSocket.on('rootNotification', this._wsOnRootNotification.bind(this));\n this._rpcWebSocket.on('logsNotification', this._wsOnLogsNotification.bind(this));\n }\n /**\n * The default commitment used for requests\n */ get commitment() {\n return this._commitment;\n }\n /**\n * The RPC endpoint\n */ get rpcEndpoint() {\n return this._rpcEndpoint;\n }\n /**\n * Fetch the balance for the specified public key, return with context\n */ async getBalanceAndContext(publicKey, commitmentOrConfig) {\n /** @internal */ const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([\n publicKey.toBase58()\n ], commitment, undefined /* encoding */ , config);\n const unsafeRes = await this._rpcRequest('getBalance', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.number)()));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, `failed to get balance for ${publicKey.toBase58()}`);\n return res.result;\n }\n /**\n * Fetch the balance for the specified public key\n */ async getBalance(publicKey, commitmentOrConfig) {\n return await this.getBalanceAndContext(publicKey, commitmentOrConfig).then((x)=>x.value).catch((e)=>{\n throw new Error('failed to get balance of account ' + publicKey.toBase58() + ': ' + e);\n });\n }\n /**\n * Fetch the estimated production time of a block\n */ async getBlockTime(slot) {\n const unsafeRes = await this._rpcRequest('getBlockTime', [\n slot\n ]);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.nullable)((0, $5DqgT.number)())));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, `failed to get block time for slot ${slot}`);\n return res.result;\n }\n /**\n * Fetch the lowest slot that the node has information about in its ledger.\n * This value may increase over time if the node is configured to purge older ledger data\n */ async getMinimumLedgerSlot() {\n const unsafeRes = await this._rpcRequest('minimumLedgerSlot', []);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.number)()));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get minimum ledger slot');\n return res.result;\n }\n /**\n * Fetch the slot of the lowest confirmed block that has not been purged from the ledger\n */ async getFirstAvailableBlock() {\n const unsafeRes = await this._rpcRequest('getFirstAvailableBlock', []);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$SlotRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get first available block');\n return res.result;\n }\n /**\n * Fetch information about the current supply\n */ async getSupply(config) {\n let configArg = {};\n if (typeof config === 'string') configArg = {\n commitment: config\n };\n else if (config) configArg = {\n ...config,\n commitment: config && config.commitment || this.commitment\n };\n else configArg = {\n commitment: this.commitment\n };\n const unsafeRes = await this._rpcRequest('getSupply', [\n configArg\n ]);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetSupplyRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get supply');\n return res.result;\n }\n /**\n * Fetch the current supply of a token mint\n */ async getTokenSupply(tokenMintAddress, commitment) {\n const args = this._buildArgs([\n tokenMintAddress.toBase58()\n ], commitment);\n const unsafeRes = await this._rpcRequest('getTokenSupply', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResultAndContext($c3af9e523501759a$var$TokenAmountResult));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get token supply');\n return res.result;\n }\n /**\n * Fetch the current balance of a token account\n */ async getTokenAccountBalance(tokenAddress, commitment) {\n const args = this._buildArgs([\n tokenAddress.toBase58()\n ], commitment);\n const unsafeRes = await this._rpcRequest('getTokenAccountBalance', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResultAndContext($c3af9e523501759a$var$TokenAmountResult));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get token account balance');\n return res.result;\n }\n /**\n * Fetch all the token accounts owned by the specified account\n *\n * @return {Promise}\n */ async getTokenAccountsByOwner(ownerAddress, filter, commitmentOrConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n let _args = [\n ownerAddress.toBase58()\n ];\n if ('mint' in filter) _args.push({\n mint: filter.mint.toBase58()\n });\n else _args.push({\n programId: filter.programId.toBase58()\n });\n const args = this._buildArgs(_args, commitment, 'base64', config);\n const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetTokenAccountsByOwner);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);\n return res.result;\n }\n /**\n * Fetch parsed token accounts owned by the specified account\n *\n * @return {Promise}>>>}\n */ async getParsedTokenAccountsByOwner(ownerAddress, filter, commitment) {\n let _args = [\n ownerAddress.toBase58()\n ];\n if ('mint' in filter) _args.push({\n mint: filter.mint.toBase58()\n });\n else _args.push({\n programId: filter.programId.toBase58()\n });\n const args = this._buildArgs(_args, commitment, 'jsonParsed');\n const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetParsedTokenAccountsByOwner);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);\n return res.result;\n }\n /**\n * Fetch the 20 largest accounts with their current balances\n */ async getLargestAccounts(config) {\n const arg = {\n ...config,\n commitment: config && config.commitment || this.commitment\n };\n const args = arg.filter || arg.commitment ? [\n arg\n ] : [];\n const unsafeRes = await this._rpcRequest('getLargestAccounts', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetLargestAccountsRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get largest accounts');\n return res.result;\n }\n /**\n * Fetch the 20 largest token accounts with their current balances\n * for a given mint.\n */ async getTokenLargestAccounts(mintAddress, commitment) {\n const args = this._buildArgs([\n mintAddress.toBase58()\n ], commitment);\n const unsafeRes = await this._rpcRequest('getTokenLargestAccounts', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetTokenLargestAccountsResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get token largest accounts');\n return res.result;\n }\n /**\n * Fetch all the account info for the specified public key, return with context\n */ async getAccountInfoAndContext(publicKey, commitmentOrConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([\n publicKey.toBase58()\n ], commitment, 'base64', config);\n const unsafeRes = await this._rpcRequest('getAccountInfo', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.nullable)($c3af9e523501759a$var$AccountInfoResult)));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, `failed to get info about account ${publicKey.toBase58()}`);\n return res.result;\n }\n /**\n * Fetch parsed account info for the specified public key\n */ async getParsedAccountInfo(publicKey, commitmentOrConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([\n publicKey.toBase58()\n ], commitment, 'jsonParsed', config);\n const unsafeRes = await this._rpcRequest('getAccountInfo', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.nullable)($c3af9e523501759a$var$ParsedAccountInfoResult)));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, `failed to get info about account ${publicKey.toBase58()}`);\n return res.result;\n }\n /**\n * Fetch all the account info for the specified public key\n */ async getAccountInfo(publicKey, commitmentOrConfig) {\n try {\n const res = await this.getAccountInfoAndContext(publicKey, commitmentOrConfig);\n return res.value;\n } catch (e) {\n throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + e);\n }\n }\n /**\n * Fetch all the account info for multiple accounts specified by an array of public keys, return with context\n */ async getMultipleParsedAccounts(publicKeys, rawConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(rawConfig);\n const keys = publicKeys.map((key)=>key.toBase58());\n const args = this._buildArgs([\n keys\n ], commitment, 'jsonParsed', config);\n const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.array)((0, $5DqgT.nullable)($c3af9e523501759a$var$ParsedAccountInfoResult))));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, `failed to get info for accounts ${keys}`);\n return res.result;\n }\n /**\n * Fetch all the account info for multiple accounts specified by an array of public keys, return with context\n */ async getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const keys = publicKeys.map((key)=>key.toBase58());\n const args = this._buildArgs([\n keys\n ], commitment, 'base64', config);\n const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.array)((0, $5DqgT.nullable)($c3af9e523501759a$var$AccountInfoResult))));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, `failed to get info for accounts ${keys}`);\n return res.result;\n }\n /**\n * Fetch all the account info for multiple accounts specified by an array of public keys\n */ async getMultipleAccountsInfo(publicKeys, commitmentOrConfig) {\n const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig);\n return res.value;\n }\n /**\n * Returns epoch activation information for a stake account that has been delegated\n *\n * @deprecated Deprecated since RPC v1.18; will be removed in a future version.\n */ async getStakeActivation(publicKey, commitmentOrConfig, epoch) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([\n publicKey.toBase58()\n ], commitment, undefined /* encoding */ , {\n ...config,\n epoch: epoch != null ? epoch : config?.epoch\n });\n const unsafeRes = await this._rpcRequest('getStakeActivation', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResult($c3af9e523501759a$var$StakeActivationResult));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, `failed to get Stake Activation ${publicKey.toBase58()}`);\n return res.result;\n }\n /**\n * Fetch all the accounts owned by the specified program id\n *\n * @return {Promise}>>}\n */ // eslint-disable-next-line no-dupe-class-members\n // eslint-disable-next-line no-dupe-class-members\n async getProgramAccounts(programId, configOrCommitment) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(configOrCommitment);\n const { encoding: encoding, ...configWithoutEncoding } = config || {};\n const args = this._buildArgs([\n programId.toBase58()\n ], commitment, encoding || 'base64', {\n ...configWithoutEncoding,\n ...configWithoutEncoding.filters ? {\n filters: $c3af9e523501759a$var$applyDefaultMemcmpEncodingToFilters(configWithoutEncoding.filters)\n } : null\n });\n const unsafeRes = await this._rpcRequest('getProgramAccounts', args);\n const baseSchema = (0, $5DqgT.array)($c3af9e523501759a$var$KeyedAccountInfoResult);\n const res = configWithoutEncoding.withContext === true ? (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResultAndContext(baseSchema)) : (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResult(baseSchema));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);\n return res.result;\n }\n /**\n * Fetch and parse all the accounts owned by the specified program id\n *\n * @return {Promise}>>}\n */ async getParsedProgramAccounts(programId, configOrCommitment) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(configOrCommitment);\n const args = this._buildArgs([\n programId.toBase58()\n ], commitment, 'jsonParsed', config);\n const unsafeRes = await this._rpcRequest('getProgramAccounts', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.array)($c3af9e523501759a$var$KeyedParsedAccountInfoResult)));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);\n return res.result;\n }\n /** @deprecated Instead, call `confirmTransaction` and pass in {@link TransactionConfirmationStrategy} */ // eslint-disable-next-line no-dupe-class-members\n // eslint-disable-next-line no-dupe-class-members\n async confirmTransaction(strategy, commitment) {\n let rawSignature;\n if (typeof strategy == 'string') rawSignature = strategy;\n else {\n const config = strategy;\n if (config.abortSignal?.aborted) return Promise.reject(config.abortSignal.reason);\n rawSignature = config.signature;\n }\n let decodedSignature;\n try {\n decodedSignature = (0, (/*@__PURE__*/$parcel$interopDefault($bYkMz))).decode(rawSignature);\n } catch (err) {\n throw new Error('signature must be base58 encoded: ' + rawSignature);\n }\n $c3af9e523501759a$var$assert(decodedSignature.length === 64, 'signature has invalid length');\n if (typeof strategy === 'string') return await this.confirmTransactionUsingLegacyTimeoutStrategy({\n commitment: commitment || this.commitment,\n signature: rawSignature\n });\n else if ('lastValidBlockHeight' in strategy) return await this.confirmTransactionUsingBlockHeightExceedanceStrategy({\n commitment: commitment || this.commitment,\n strategy: strategy\n });\n else return await this.confirmTransactionUsingDurableNonceStrategy({\n commitment: commitment || this.commitment,\n strategy: strategy\n });\n }\n getCancellationPromise(signal) {\n return new Promise((_, reject)=>{\n if (signal == null) return;\n if (signal.aborted) reject(signal.reason);\n else signal.addEventListener('abort', ()=>{\n reject(signal.reason);\n });\n });\n }\n getTransactionConfirmationPromise({ commitment: commitment, signature: signature }) {\n let signatureSubscriptionId;\n let disposeSignatureSubscriptionStateChangeObserver;\n let done = false;\n const confirmationPromise = new Promise((resolve, reject)=>{\n try {\n signatureSubscriptionId = this.onSignature(signature, (result, context)=>{\n signatureSubscriptionId = undefined;\n const response = {\n context: context,\n value: result\n };\n resolve({\n __type: $c3af9e523501759a$export$7c391bd3b61d2374.PROCESSED,\n response: response\n });\n }, commitment);\n const subscriptionSetupPromise = new Promise((resolveSubscriptionSetup)=>{\n if (signatureSubscriptionId == null) resolveSubscriptionSetup();\n else disposeSignatureSubscriptionStateChangeObserver = this._onSubscriptionStateChange(signatureSubscriptionId, (nextState)=>{\n if (nextState === 'subscribed') resolveSubscriptionSetup();\n });\n });\n (async ()=>{\n await subscriptionSetupPromise;\n if (done) return;\n const response = await this.getSignatureStatus(signature);\n if (done) return;\n if (response == null) return;\n const { context: context, value: value } = response;\n if (value == null) return;\n if (value?.err) reject(value.err);\n else {\n switch(commitment){\n case 'confirmed':\n case 'single':\n case 'singleGossip':\n if (value.confirmationStatus === 'processed') return;\n break;\n case 'finalized':\n case 'max':\n case 'root':\n if (value.confirmationStatus === 'processed' || value.confirmationStatus === 'confirmed') return;\n break;\n // exhaust enums to ensure full coverage\n case 'processed':\n case 'recent':\n }\n done = true;\n resolve({\n __type: $c3af9e523501759a$export$7c391bd3b61d2374.PROCESSED,\n response: {\n context: context,\n value: value\n }\n });\n }\n })();\n } catch (err) {\n reject(err);\n }\n });\n const abortConfirmation = ()=>{\n if (disposeSignatureSubscriptionStateChangeObserver) {\n disposeSignatureSubscriptionStateChangeObserver();\n disposeSignatureSubscriptionStateChangeObserver = undefined;\n }\n if (signatureSubscriptionId != null) {\n this.removeSignatureListener(signatureSubscriptionId);\n signatureSubscriptionId = undefined;\n }\n };\n return {\n abortConfirmation: abortConfirmation,\n confirmationPromise: confirmationPromise\n };\n }\n async confirmTransactionUsingBlockHeightExceedanceStrategy({ commitment: commitment, strategy: { abortSignal: abortSignal, lastValidBlockHeight: lastValidBlockHeight, signature: signature } }) {\n let done = false;\n const expiryPromise = new Promise((resolve)=>{\n const checkBlockHeight = async ()=>{\n try {\n const blockHeight = await this.getBlockHeight(commitment);\n return blockHeight;\n } catch (_e) {\n return -1;\n }\n };\n (async ()=>{\n let currentBlockHeight = await checkBlockHeight();\n if (done) return;\n while(currentBlockHeight <= lastValidBlockHeight){\n await $c3af9e523501759a$var$sleep(1000);\n if (done) return;\n currentBlockHeight = await checkBlockHeight();\n if (done) return;\n }\n resolve({\n __type: $c3af9e523501759a$export$7c391bd3b61d2374.BLOCKHEIGHT_EXCEEDED\n });\n })();\n });\n const { abortConfirmation: abortConfirmation, confirmationPromise: confirmationPromise } = this.getTransactionConfirmationPromise({\n commitment: commitment,\n signature: signature\n });\n const cancellationPromise = this.getCancellationPromise(abortSignal);\n let result;\n try {\n const outcome = await Promise.race([\n cancellationPromise,\n confirmationPromise,\n expiryPromise\n ]);\n if (outcome.__type === $c3af9e523501759a$export$7c391bd3b61d2374.PROCESSED) result = outcome.response;\n else throw new $c3af9e523501759a$export$718fcd78527f88ed(signature);\n } finally{\n done = true;\n abortConfirmation();\n }\n return result;\n }\n async confirmTransactionUsingDurableNonceStrategy({ commitment: commitment, strategy: { abortSignal: abortSignal, minContextSlot: minContextSlot, nonceAccountPubkey: nonceAccountPubkey, nonceValue: nonceValue, signature: signature } }) {\n let done = false;\n const expiryPromise = new Promise((resolve)=>{\n let currentNonceValue = nonceValue;\n let lastCheckedSlot = null;\n const getCurrentNonceValue = async ()=>{\n try {\n const { context: context, value: nonceAccount } = await this.getNonceAndContext(nonceAccountPubkey, {\n commitment: commitment,\n minContextSlot: minContextSlot\n });\n lastCheckedSlot = context.slot;\n return nonceAccount?.nonce;\n } catch (e) {\n // If for whatever reason we can't reach/read the nonce\n // account, just keep using the last-known value.\n return currentNonceValue;\n }\n };\n (async ()=>{\n currentNonceValue = await getCurrentNonceValue();\n if (done) return;\n while(true // eslint-disable-line no-constant-condition\n ){\n if (nonceValue !== currentNonceValue) {\n resolve({\n __type: $c3af9e523501759a$export$7c391bd3b61d2374.NONCE_INVALID,\n slotInWhichNonceDidAdvance: lastCheckedSlot\n });\n return;\n }\n await $c3af9e523501759a$var$sleep(2000);\n if (done) return;\n currentNonceValue = await getCurrentNonceValue();\n if (done) return;\n }\n })();\n });\n const { abortConfirmation: abortConfirmation, confirmationPromise: confirmationPromise } = this.getTransactionConfirmationPromise({\n commitment: commitment,\n signature: signature\n });\n const cancellationPromise = this.getCancellationPromise(abortSignal);\n let result;\n try {\n const outcome = await Promise.race([\n cancellationPromise,\n confirmationPromise,\n expiryPromise\n ]);\n if (outcome.__type === $c3af9e523501759a$export$7c391bd3b61d2374.PROCESSED) result = outcome.response;\n else {\n // Double check that the transaction is indeed unconfirmed.\n let signatureStatus;\n while(true // eslint-disable-line no-constant-condition\n ){\n const status = await this.getSignatureStatus(signature);\n if (status == null) break;\n if (status.context.slot < (outcome.slotInWhichNonceDidAdvance ?? minContextSlot)) {\n await $c3af9e523501759a$var$sleep(400);\n continue;\n }\n signatureStatus = status;\n break;\n }\n if (signatureStatus?.value) {\n const commitmentForStatus = commitment || 'finalized';\n const { confirmationStatus: confirmationStatus } = signatureStatus.value;\n switch(commitmentForStatus){\n case 'processed':\n case 'recent':\n if (confirmationStatus !== 'processed' && confirmationStatus !== 'confirmed' && confirmationStatus !== 'finalized') throw new $c3af9e523501759a$export$a3e7565a95f5a1e5(signature);\n break;\n case 'confirmed':\n case 'single':\n case 'singleGossip':\n if (confirmationStatus !== 'confirmed' && confirmationStatus !== 'finalized') throw new $c3af9e523501759a$export$a3e7565a95f5a1e5(signature);\n break;\n case 'finalized':\n case 'max':\n case 'root':\n if (confirmationStatus !== 'finalized') throw new $c3af9e523501759a$export$a3e7565a95f5a1e5(signature);\n break;\n default:\n // Exhaustive switch.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ((_)=>{})(commitmentForStatus);\n }\n result = {\n context: signatureStatus.context,\n value: {\n err: signatureStatus.value.err\n }\n };\n } else throw new $c3af9e523501759a$export$a3e7565a95f5a1e5(signature);\n }\n } finally{\n done = true;\n abortConfirmation();\n }\n return result;\n }\n async confirmTransactionUsingLegacyTimeoutStrategy({ commitment: commitment, signature: signature }) {\n let timeoutId;\n const expiryPromise = new Promise((resolve)=>{\n let timeoutMs = this._confirmTransactionInitialTimeout || 60000;\n switch(commitment){\n case 'processed':\n case 'recent':\n case 'single':\n case 'confirmed':\n case 'singleGossip':\n timeoutMs = this._confirmTransactionInitialTimeout || 30000;\n break;\n }\n timeoutId = setTimeout(()=>resolve({\n __type: $c3af9e523501759a$export$7c391bd3b61d2374.TIMED_OUT,\n timeoutMs: timeoutMs\n }), timeoutMs);\n });\n const { abortConfirmation: abortConfirmation, confirmationPromise: confirmationPromise } = this.getTransactionConfirmationPromise({\n commitment: commitment,\n signature: signature\n });\n let result;\n try {\n const outcome = await Promise.race([\n confirmationPromise,\n expiryPromise\n ]);\n if (outcome.__type === $c3af9e523501759a$export$7c391bd3b61d2374.PROCESSED) result = outcome.response;\n else throw new $c3af9e523501759a$export$b822204c22e46bdf(signature, outcome.timeoutMs / 1000);\n } finally{\n clearTimeout(timeoutId);\n abortConfirmation();\n }\n return result;\n }\n /**\n * Return the list of nodes that are currently participating in the cluster\n */ async getClusterNodes() {\n const unsafeRes = await this._rpcRequest('getClusterNodes', []);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.array)($c3af9e523501759a$var$ContactInfoResult)));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get cluster nodes');\n return res.result;\n }\n /**\n * Return the list of nodes that are currently participating in the cluster\n */ async getVoteAccounts(commitment) {\n const args = this._buildArgs([], commitment);\n const unsafeRes = await this._rpcRequest('getVoteAccounts', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetVoteAccounts);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get vote accounts');\n return res.result;\n }\n /**\n * Fetch the current slot that the node is processing\n */ async getSlot(commitmentOrConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([], commitment, undefined /* encoding */ , config);\n const unsafeRes = await this._rpcRequest('getSlot', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.number)()));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get slot');\n return res.result;\n }\n /**\n * Fetch the current slot leader of the cluster\n */ async getSlotLeader(commitmentOrConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([], commitment, undefined /* encoding */ , config);\n const unsafeRes = await this._rpcRequest('getSlotLeader', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.string)()));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get slot leader');\n return res.result;\n }\n /**\n * Fetch `limit` number of slot leaders starting from `startSlot`\n *\n * @param startSlot fetch slot leaders starting from this slot\n * @param limit number of slot leaders to return\n */ async getSlotLeaders(startSlot, limit) {\n const args = [\n startSlot,\n limit\n ];\n const unsafeRes = await this._rpcRequest('getSlotLeaders', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.array)($c3af9e523501759a$var$PublicKeyFromString)));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get slot leaders');\n return res.result;\n }\n /**\n * Fetch the current status of a signature\n */ async getSignatureStatus(signature, config) {\n const { context: context, value: values } = await this.getSignatureStatuses([\n signature\n ], config);\n $c3af9e523501759a$var$assert(values.length === 1);\n const value = values[0];\n return {\n context: context,\n value: value\n };\n }\n /**\n * Fetch the current statuses of a batch of signatures\n */ async getSignatureStatuses(signatures, config) {\n const params = [\n signatures\n ];\n if (config) params.push(config);\n const unsafeRes = await this._rpcRequest('getSignatureStatuses', params);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetSignatureStatusesRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get signature status');\n return res.result;\n }\n /**\n * Fetch the current transaction count of the cluster\n */ async getTransactionCount(commitmentOrConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([], commitment, undefined /* encoding */ , config);\n const unsafeRes = await this._rpcRequest('getTransactionCount', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.number)()));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get transaction count');\n return res.result;\n }\n /**\n * Fetch the current total currency supply of the cluster in lamports\n *\n * @deprecated Deprecated since RPC v1.2.8. Please use {@link getSupply} instead.\n */ async getTotalSupply(commitment) {\n const result = await this.getSupply({\n commitment: commitment,\n excludeNonCirculatingAccountsList: true\n });\n return result.value.total;\n }\n /**\n * Fetch the cluster InflationGovernor parameters\n */ async getInflationGovernor(commitment) {\n const args = this._buildArgs([], commitment);\n const unsafeRes = await this._rpcRequest('getInflationGovernor', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetInflationGovernorRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get inflation');\n return res.result;\n }\n /**\n * Fetch the inflation reward for a list of addresses for an epoch\n */ async getInflationReward(addresses, epoch, commitmentOrConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([\n addresses.map((pubkey)=>pubkey.toBase58())\n ], commitment, undefined /* encoding */ , {\n ...config,\n epoch: epoch != null ? epoch : config?.epoch\n });\n const unsafeRes = await this._rpcRequest('getInflationReward', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetInflationRewardResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get inflation reward');\n return res.result;\n }\n /**\n * Fetch the specific inflation values for the current epoch\n */ async getInflationRate() {\n const unsafeRes = await this._rpcRequest('getInflationRate', []);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetInflationRateRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get inflation rate');\n return res.result;\n }\n /**\n * Fetch the Epoch Info parameters\n */ async getEpochInfo(commitmentOrConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([], commitment, undefined /* encoding */ , config);\n const unsafeRes = await this._rpcRequest('getEpochInfo', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetEpochInfoRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get epoch info');\n return res.result;\n }\n /**\n * Fetch the Epoch Schedule parameters\n */ async getEpochSchedule() {\n const unsafeRes = await this._rpcRequest('getEpochSchedule', []);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetEpochScheduleRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get epoch schedule');\n const epochSchedule = res.result;\n return new $c3af9e523501759a$export$df8ed3e830b1d591(epochSchedule.slotsPerEpoch, epochSchedule.leaderScheduleSlotOffset, epochSchedule.warmup, epochSchedule.firstNormalEpoch, epochSchedule.firstNormalSlot);\n }\n /**\n * Fetch the leader schedule for the current epoch\n * @return {Promise>}\n */ async getLeaderSchedule() {\n const unsafeRes = await this._rpcRequest('getLeaderSchedule', []);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetLeaderScheduleRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get leader schedule');\n return res.result;\n }\n /**\n * Fetch the minimum balance needed to exempt an account of `dataLength`\n * size from rent\n */ async getMinimumBalanceForRentExemption(dataLength, commitment) {\n const args = this._buildArgs([\n dataLength\n ], commitment);\n const unsafeRes = await this._rpcRequest('getMinimumBalanceForRentExemption', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetMinimumBalanceForRentExemptionRpcResult);\n if ('error' in res) {\n console.warn('Unable to fetch minimum balance for rent exemption');\n return 0;\n }\n return res.result;\n }\n /**\n * Fetch a recent blockhash from the cluster, return with context\n * @return {Promise>}\n *\n * @deprecated Deprecated since RPC v1.9.0. Please use {@link getLatestBlockhash} instead.\n */ async getRecentBlockhashAndContext(commitment) {\n const { context: context, value: { blockhash: blockhash } } = await this.getLatestBlockhashAndContext(commitment);\n const feeCalculator = {\n get lamportsPerSignature () {\n throw new Error(\"The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.\");\n },\n toJSON () {\n return {};\n }\n };\n return {\n context: context,\n value: {\n blockhash: blockhash,\n feeCalculator: feeCalculator\n }\n };\n }\n /**\n * Fetch recent performance samples\n * @return {Promise>}\n */ async getRecentPerformanceSamples(limit) {\n const unsafeRes = await this._rpcRequest('getRecentPerformanceSamples', limit ? [\n limit\n ] : []);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetRecentPerformanceSamplesRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get recent performance samples');\n return res.result;\n }\n /**\n * Fetch the fee calculator for a recent blockhash from the cluster, return with context\n *\n * @deprecated Deprecated since RPC v1.9.0. Please use {@link getFeeForMessage} instead.\n */ async getFeeCalculatorForBlockhash(blockhash, commitment) {\n const args = this._buildArgs([\n blockhash\n ], commitment);\n const unsafeRes = await this._rpcRequest('getFeeCalculatorForBlockhash', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetFeeCalculatorRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get fee calculator');\n const { context: context, value: value } = res.result;\n return {\n context: context,\n value: value !== null ? value.feeCalculator : null\n };\n }\n /**\n * Fetch the fee for a message from the cluster, return with context\n */ async getFeeForMessage(message, commitment) {\n const wireMessage = $c3af9e523501759a$var$toBuffer(message.serialize()).toString('base64');\n const args = this._buildArgs([\n wireMessage\n ], commitment);\n const unsafeRes = await this._rpcRequest('getFeeForMessage', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.nullable)((0, $5DqgT.number)())));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get fee for message');\n if (res.result === null) throw new Error('invalid blockhash');\n return res.result;\n }\n /**\n * Fetch a list of prioritization fees from recent blocks.\n */ async getRecentPrioritizationFees(config) {\n const accounts = config?.lockedWritableAccounts?.map((key)=>key.toBase58());\n const args = accounts?.length ? [\n accounts\n ] : [];\n const unsafeRes = await this._rpcRequest('getRecentPrioritizationFees', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetRecentPrioritizationFeesRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get recent prioritization fees');\n return res.result;\n }\n /**\n * Fetch a recent blockhash from the cluster\n * @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}\n *\n * @deprecated Deprecated since RPC v1.8.0. Please use {@link getLatestBlockhash} instead.\n */ async getRecentBlockhash(commitment) {\n try {\n const res = await this.getRecentBlockhashAndContext(commitment);\n return res.value;\n } catch (e) {\n throw new Error('failed to get recent blockhash: ' + e);\n }\n }\n /**\n * Fetch the latest blockhash from the cluster\n * @return {Promise}\n */ async getLatestBlockhash(commitmentOrConfig) {\n try {\n const res = await this.getLatestBlockhashAndContext(commitmentOrConfig);\n return res.value;\n } catch (e) {\n throw new Error('failed to get recent blockhash: ' + e);\n }\n }\n /**\n * Fetch the latest blockhash from the cluster\n * @return {Promise}\n */ async getLatestBlockhashAndContext(commitmentOrConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([], commitment, undefined /* encoding */ , config);\n const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetLatestBlockhashRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get latest blockhash');\n return res.result;\n }\n /**\n * Returns whether a blockhash is still valid or not\n */ async isBlockhashValid(blockhash, rawConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(rawConfig);\n const args = this._buildArgs([\n blockhash\n ], commitment, undefined /* encoding */ , config);\n const unsafeRes = await this._rpcRequest('isBlockhashValid', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$IsBlockhashValidRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to determine if the blockhash `' + blockhash + '`is valid');\n return res.result;\n }\n /**\n * Fetch the node version\n */ async getVersion() {\n const unsafeRes = await this._rpcRequest('getVersion', []);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResult($c3af9e523501759a$var$VersionResult));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get version');\n return res.result;\n }\n /**\n * Fetch the genesis hash\n */ async getGenesisHash() {\n const unsafeRes = await this._rpcRequest('getGenesisHash', []);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.string)()));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get genesis hash');\n return res.result;\n }\n /**\n * Fetch a processed block from the cluster.\n *\n * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by\n * setting the `maxSupportedTransactionVersion` property.\n */ /**\n * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by\n * setting the `maxSupportedTransactionVersion` property.\n */ // eslint-disable-next-line no-dupe-class-members\n /**\n * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by\n * setting the `maxSupportedTransactionVersion` property.\n */ // eslint-disable-next-line no-dupe-class-members\n /**\n * Fetch a processed block from the cluster.\n */ // eslint-disable-next-line no-dupe-class-members\n // eslint-disable-next-line no-dupe-class-members\n // eslint-disable-next-line no-dupe-class-members\n /**\n * Fetch a processed block from the cluster.\n */ // eslint-disable-next-line no-dupe-class-members\n async getBlock(slot, rawConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(rawConfig);\n const args = this._buildArgsAtLeastConfirmed([\n slot\n ], commitment, undefined /* encoding */ , config);\n const unsafeRes = await this._rpcRequest('getBlock', args);\n try {\n switch(config?.transactionDetails){\n case 'accounts':\n {\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetAccountsModeBlockRpcResult);\n if ('error' in res) throw res.error;\n return res.result;\n }\n case 'none':\n {\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetNoneModeBlockRpcResult);\n if ('error' in res) throw res.error;\n return res.result;\n }\n default:\n {\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetBlockRpcResult);\n if ('error' in res) throw res.error;\n const { result: result } = res;\n return result ? {\n ...result,\n transactions: result.transactions.map(({ transaction: transaction, meta: meta, version: version })=>({\n meta: meta,\n transaction: {\n ...transaction,\n message: $c3af9e523501759a$var$versionedMessageFromResponse(version, transaction.message)\n },\n version: version\n }))\n } : null;\n }\n }\n } catch (e) {\n throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(e, 'failed to get confirmed block');\n }\n }\n /**\n * Fetch parsed transaction details for a confirmed or finalized block\n */ // eslint-disable-next-line no-dupe-class-members\n // eslint-disable-next-line no-dupe-class-members\n // eslint-disable-next-line no-dupe-class-members\n async getParsedBlock(slot, rawConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(rawConfig);\n const args = this._buildArgsAtLeastConfirmed([\n slot\n ], commitment, 'jsonParsed', config);\n const unsafeRes = await this._rpcRequest('getBlock', args);\n try {\n switch(config?.transactionDetails){\n case 'accounts':\n {\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetParsedAccountsModeBlockRpcResult);\n if ('error' in res) throw res.error;\n return res.result;\n }\n case 'none':\n {\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetParsedNoneModeBlockRpcResult);\n if ('error' in res) throw res.error;\n return res.result;\n }\n default:\n {\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetParsedBlockRpcResult);\n if ('error' in res) throw res.error;\n return res.result;\n }\n }\n } catch (e) {\n throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(e, 'failed to get block');\n }\n }\n /*\n * Returns recent block production information from the current or previous epoch\n */ async getBlockProduction(configOrCommitment) {\n let extra;\n let commitment;\n if (typeof configOrCommitment === 'string') commitment = configOrCommitment;\n else if (configOrCommitment) {\n const { commitment: c, ...rest } = configOrCommitment;\n commitment = c;\n extra = rest;\n }\n const args = this._buildArgs([], commitment, 'base64', extra);\n const unsafeRes = await this._rpcRequest('getBlockProduction', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$BlockProductionResponseStruct);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get block production information');\n return res.result;\n }\n /**\n * Fetch a confirmed or finalized transaction from the cluster.\n *\n * @deprecated Instead, call `getTransaction` using a\n * `GetVersionedTransactionConfig` by setting the\n * `maxSupportedTransactionVersion` property.\n */ /**\n * Fetch a confirmed or finalized transaction from the cluster.\n */ // eslint-disable-next-line no-dupe-class-members\n /**\n * Fetch a confirmed or finalized transaction from the cluster.\n */ // eslint-disable-next-line no-dupe-class-members\n async getTransaction(signature, rawConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(rawConfig);\n const args = this._buildArgsAtLeastConfirmed([\n signature\n ], commitment, undefined /* encoding */ , config);\n const unsafeRes = await this._rpcRequest('getTransaction', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetTransactionRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get transaction');\n const result = res.result;\n if (!result) return result;\n return {\n ...result,\n transaction: {\n ...result.transaction,\n message: $c3af9e523501759a$var$versionedMessageFromResponse(result.version, result.transaction.message)\n }\n };\n }\n /**\n * Fetch parsed transaction details for a confirmed or finalized transaction\n */ async getParsedTransaction(signature, commitmentOrConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgsAtLeastConfirmed([\n signature\n ], commitment, 'jsonParsed', config);\n const unsafeRes = await this._rpcRequest('getTransaction', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetParsedTransactionRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get transaction');\n return res.result;\n }\n /**\n * Fetch parsed transaction details for a batch of confirmed transactions\n */ async getParsedTransactions(signatures, commitmentOrConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const batch = signatures.map((signature)=>{\n const args = this._buildArgsAtLeastConfirmed([\n signature\n ], commitment, 'jsonParsed', config);\n return {\n methodName: 'getTransaction',\n args: args\n };\n });\n const unsafeRes = await this._rpcBatchRequest(batch);\n const res = unsafeRes.map((unsafeRes)=>{\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetParsedTransactionRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get transactions');\n return res.result;\n });\n return res;\n }\n /**\n * Fetch transaction details for a batch of confirmed transactions.\n * Similar to {@link getParsedTransactions} but returns a {@link TransactionResponse}.\n *\n * @deprecated Instead, call `getTransactions` using a\n * `GetVersionedTransactionConfig` by setting the\n * `maxSupportedTransactionVersion` property.\n */ /**\n * Fetch transaction details for a batch of confirmed transactions.\n * Similar to {@link getParsedTransactions} but returns a {@link\n * VersionedTransactionResponse}.\n */ // eslint-disable-next-line no-dupe-class-members\n /**\n * Fetch transaction details for a batch of confirmed transactions.\n * Similar to {@link getParsedTransactions} but returns a {@link\n * VersionedTransactionResponse}.\n */ // eslint-disable-next-line no-dupe-class-members\n async getTransactions(signatures, commitmentOrConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const batch = signatures.map((signature)=>{\n const args = this._buildArgsAtLeastConfirmed([\n signature\n ], commitment, undefined /* encoding */ , config);\n return {\n methodName: 'getTransaction',\n args: args\n };\n });\n const unsafeRes = await this._rpcBatchRequest(batch);\n const res = unsafeRes.map((unsafeRes)=>{\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetTransactionRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get transactions');\n const result = res.result;\n if (!result) return result;\n return {\n ...result,\n transaction: {\n ...result.transaction,\n message: $c3af9e523501759a$var$versionedMessageFromResponse(result.version, result.transaction.message)\n }\n };\n });\n return res;\n }\n /**\n * Fetch a list of Transactions and transaction statuses from the cluster\n * for a confirmed block.\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getBlock} instead.\n */ async getConfirmedBlock(slot, commitment) {\n const args = this._buildArgsAtLeastConfirmed([\n slot\n ], commitment);\n const unsafeRes = await this._rpcRequest('getBlock', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetConfirmedBlockRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get confirmed block');\n const result = res.result;\n if (!result) throw new Error('Confirmed block ' + slot + ' not found');\n const block = {\n ...result,\n transactions: result.transactions.map(({ transaction: transaction, meta: meta })=>{\n const message = new $c3af9e523501759a$export$f69c19e57285b83a(transaction.message);\n return {\n meta: meta,\n transaction: {\n ...transaction,\n message: message\n }\n };\n })\n };\n return {\n ...block,\n transactions: block.transactions.map(({ transaction: transaction, meta: meta })=>{\n return {\n meta: meta,\n transaction: $c3af9e523501759a$export$febc5573c75cefb0.populate(transaction.message, transaction.signatures)\n };\n })\n };\n }\n /**\n * Fetch confirmed blocks between two slots\n */ async getBlocks(startSlot, endSlot, commitment) {\n const args = this._buildArgsAtLeastConfirmed(endSlot !== undefined ? [\n startSlot,\n endSlot\n ] : [\n startSlot\n ], commitment);\n const unsafeRes = await this._rpcRequest('getBlocks', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResult((0, $5DqgT.array)((0, $5DqgT.number)())));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get blocks');\n return res.result;\n }\n /**\n * Fetch a list of Signatures from the cluster for a block, excluding rewards\n */ async getBlockSignatures(slot, commitment) {\n const args = this._buildArgsAtLeastConfirmed([\n slot\n ], commitment, undefined, {\n transactionDetails: 'signatures',\n rewards: false\n });\n const unsafeRes = await this._rpcRequest('getBlock', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetBlockSignaturesRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get block');\n const result = res.result;\n if (!result) throw new Error('Block ' + slot + ' not found');\n return result;\n }\n /**\n * Fetch a list of Signatures from the cluster for a confirmed block, excluding rewards\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getBlockSignatures} instead.\n */ async getConfirmedBlockSignatures(slot, commitment) {\n const args = this._buildArgsAtLeastConfirmed([\n slot\n ], commitment, undefined, {\n transactionDetails: 'signatures',\n rewards: false\n });\n const unsafeRes = await this._rpcRequest('getBlock', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetBlockSignaturesRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get confirmed block');\n const result = res.result;\n if (!result) throw new Error('Confirmed block ' + slot + ' not found');\n return result;\n }\n /**\n * Fetch a transaction details for a confirmed transaction\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getTransaction} instead.\n */ async getConfirmedTransaction(signature, commitment) {\n const args = this._buildArgsAtLeastConfirmed([\n signature\n ], commitment);\n const unsafeRes = await this._rpcRequest('getTransaction', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetTransactionRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get transaction');\n const result = res.result;\n if (!result) return result;\n const message = new $c3af9e523501759a$export$f69c19e57285b83a(result.transaction.message);\n const signatures = result.transaction.signatures;\n return {\n ...result,\n transaction: $c3af9e523501759a$export$febc5573c75cefb0.populate(message, signatures)\n };\n }\n /**\n * Fetch parsed transaction details for a confirmed transaction\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getParsedTransaction} instead.\n */ async getParsedConfirmedTransaction(signature, commitment) {\n const args = this._buildArgsAtLeastConfirmed([\n signature\n ], commitment, 'jsonParsed');\n const unsafeRes = await this._rpcRequest('getTransaction', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetParsedTransactionRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get confirmed transaction');\n return res.result;\n }\n /**\n * Fetch parsed transaction details for a batch of confirmed transactions\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getParsedTransactions} instead.\n */ async getParsedConfirmedTransactions(signatures, commitment) {\n const batch = signatures.map((signature)=>{\n const args = this._buildArgsAtLeastConfirmed([\n signature\n ], commitment, 'jsonParsed');\n return {\n methodName: 'getTransaction',\n args: args\n };\n });\n const unsafeRes = await this._rpcBatchRequest(batch);\n const res = unsafeRes.map((unsafeRes)=>{\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetParsedTransactionRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get confirmed transactions');\n return res.result;\n });\n return res;\n }\n /**\n * Fetch a list of all the confirmed signatures for transactions involving an address\n * within a specified slot range. Max range allowed is 10,000 slots.\n *\n * @deprecated Deprecated since RPC v1.3. Please use {@link getConfirmedSignaturesForAddress2} instead.\n *\n * @param address queried address\n * @param startSlot start slot, inclusive\n * @param endSlot end slot, inclusive\n */ async getConfirmedSignaturesForAddress(address, startSlot, endSlot) {\n let options = {};\n let firstAvailableBlock = await this.getFirstAvailableBlock();\n while(!('until' in options)){\n startSlot--;\n if (startSlot <= 0 || startSlot < firstAvailableBlock) break;\n try {\n const block = await this.getConfirmedBlockSignatures(startSlot, 'finalized');\n if (block.signatures.length > 0) options.until = block.signatures[block.signatures.length - 1].toString();\n } catch (err) {\n if (err instanceof Error && err.message.includes('skipped')) continue;\n else throw err;\n }\n }\n let highestConfirmedRoot = await this.getSlot('finalized');\n while(!('before' in options)){\n endSlot++;\n if (endSlot > highestConfirmedRoot) break;\n try {\n const block = await this.getConfirmedBlockSignatures(endSlot);\n if (block.signatures.length > 0) options.before = block.signatures[block.signatures.length - 1].toString();\n } catch (err) {\n if (err instanceof Error && err.message.includes('skipped')) continue;\n else throw err;\n }\n }\n const confirmedSignatureInfo = await this.getConfirmedSignaturesForAddress2(address, options);\n return confirmedSignatureInfo.map((info)=>info.signature);\n }\n /**\n * Returns confirmed signatures for transactions involving an\n * address backwards in time from the provided signature or most recent confirmed block\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getSignaturesForAddress} instead.\n */ async getConfirmedSignaturesForAddress2(address, options, commitment) {\n const args = this._buildArgsAtLeastConfirmed([\n address.toBase58()\n ], commitment, undefined, options);\n const unsafeRes = await this._rpcRequest('getConfirmedSignaturesForAddress2', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetConfirmedSignaturesForAddress2RpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get confirmed signatures for address');\n return res.result;\n }\n /**\n * Returns confirmed signatures for transactions involving an\n * address backwards in time from the provided signature or most recent confirmed block\n *\n *\n * @param address queried address\n * @param options\n */ async getSignaturesForAddress(address, options, commitment) {\n const args = this._buildArgsAtLeastConfirmed([\n address.toBase58()\n ], commitment, undefined, options);\n const unsafeRes = await this._rpcRequest('getSignaturesForAddress', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$GetSignaturesForAddressRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, 'failed to get signatures for address');\n return res.result;\n }\n async getAddressLookupTable(accountKey, config) {\n const { context: context, value: accountInfo } = await this.getAccountInfoAndContext(accountKey, config);\n let value = null;\n if (accountInfo !== null) value = new $c3af9e523501759a$export$5b2310da10e607da({\n key: accountKey,\n state: $c3af9e523501759a$export$5b2310da10e607da.deserialize(accountInfo.data)\n });\n return {\n context: context,\n value: value\n };\n }\n /**\n * Fetch the contents of a Nonce account from the cluster, return with context\n */ async getNonceAndContext(nonceAccount, commitmentOrConfig) {\n const { context: context, value: accountInfo } = await this.getAccountInfoAndContext(nonceAccount, commitmentOrConfig);\n let value = null;\n if (accountInfo !== null) value = $c3af9e523501759a$export$ed1c2356ce604759.fromAccountData(accountInfo.data);\n return {\n context: context,\n value: value\n };\n }\n /**\n * Fetch the contents of a Nonce account from the cluster\n */ async getNonce(nonceAccount, commitmentOrConfig) {\n return await this.getNonceAndContext(nonceAccount, commitmentOrConfig).then((x)=>x.value).catch((e)=>{\n throw new Error('failed to get nonce for account ' + nonceAccount.toBase58() + ': ' + e);\n });\n }\n /**\n * Request an allocation of lamports to the specified address\n *\n * ```typescript\n * import { Connection, PublicKey, LAMPORTS_PER_SOL } from \"@solana/web3.js\";\n *\n * (async () => {\n * const connection = new Connection(\"https://api.testnet.solana.com\", \"confirmed\");\n * const myAddress = new PublicKey(\"2nr1bHFT86W9tGnyvmYW4vcHKsQB3sVQfnddasz4kExM\");\n * const signature = await connection.requestAirdrop(myAddress, LAMPORTS_PER_SOL);\n * await connection.confirmTransaction(signature);\n * })();\n * ```\n */ async requestAirdrop(to, lamports) {\n const unsafeRes = await this._rpcRequest('requestAirdrop', [\n to.toBase58(),\n lamports\n ]);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$RequestAirdropRpcResult);\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, `airdrop to ${to.toBase58()} failed`);\n return res.result;\n }\n /**\n * @internal\n */ async _blockhashWithExpiryBlockHeight(disableCache) {\n if (!disableCache) {\n // Wait for polling to finish\n while(this._pollingBlockhash)await $c3af9e523501759a$var$sleep(100);\n const timeSinceFetch = Date.now() - this._blockhashInfo.lastFetch;\n const expired = timeSinceFetch >= $c3af9e523501759a$export$fcb705732fb5c597;\n if (this._blockhashInfo.latestBlockhash !== null && !expired) return this._blockhashInfo.latestBlockhash;\n }\n return await this._pollNewBlockhash();\n }\n /**\n * @internal\n */ async _pollNewBlockhash() {\n this._pollingBlockhash = true;\n try {\n const startTime = Date.now();\n const cachedLatestBlockhash = this._blockhashInfo.latestBlockhash;\n const cachedBlockhash = cachedLatestBlockhash ? cachedLatestBlockhash.blockhash : null;\n for(let i = 0; i < 50; i++){\n const latestBlockhash = await this.getLatestBlockhash('finalized');\n if (cachedBlockhash !== latestBlockhash.blockhash) {\n this._blockhashInfo = {\n latestBlockhash: latestBlockhash,\n lastFetch: Date.now(),\n transactionSignatures: [],\n simulatedSignatures: []\n };\n return latestBlockhash;\n }\n // Sleep for approximately half a slot\n await $c3af9e523501759a$var$sleep($c3af9e523501759a$var$MS_PER_SLOT / 2);\n }\n throw new Error(`Unable to obtain a new blockhash after ${Date.now() - startTime}ms`);\n } finally{\n this._pollingBlockhash = false;\n }\n }\n /**\n * get the stake minimum delegation\n */ async getStakeMinimumDelegation(config) {\n const { commitment: commitment, config: configArg } = $c3af9e523501759a$var$extractCommitmentFromConfig(config);\n const args = this._buildArgs([], commitment, 'base64', configArg);\n const unsafeRes = await this._rpcRequest('getStakeMinimumDelegation', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$jsonRpcResultAndContext((0, $5DqgT.number)()));\n if ('error' in res) throw new $c3af9e523501759a$export$ea1b1a1bba5c14ad(res.error, `failed to get stake minimum delegation`);\n return res.result;\n }\n /**\n * Simulate a transaction\n *\n * @deprecated Instead, call {@link simulateTransaction} with {@link\n * VersionedTransaction} and {@link SimulateTransactionConfig} parameters\n */ /**\n * Simulate a transaction\n */ // eslint-disable-next-line no-dupe-class-members\n /**\n * Simulate a transaction\n */ // eslint-disable-next-line no-dupe-class-members\n async simulateTransaction(transactionOrMessage, configOrSigners, includeAccounts) {\n if ('message' in transactionOrMessage) {\n const versionedTx = transactionOrMessage;\n const wireTransaction = versionedTx.serialize();\n const encodedTransaction = (0, $6ZWSX.Buffer).from(wireTransaction).toString('base64');\n if (Array.isArray(configOrSigners) || includeAccounts !== undefined) throw new Error('Invalid arguments');\n const config = configOrSigners || {};\n config.encoding = 'base64';\n if (!('commitment' in config)) config.commitment = this.commitment;\n if (configOrSigners && typeof configOrSigners === 'object' && 'innerInstructions' in configOrSigners) config.innerInstructions = configOrSigners.innerInstructions;\n const args = [\n encodedTransaction,\n config\n ];\n const unsafeRes = await this._rpcRequest('simulateTransaction', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$SimulatedTransactionResponseStruct);\n if ('error' in res) throw new Error('failed to simulate transaction: ' + res.error.message);\n return res.result;\n }\n let transaction;\n if (transactionOrMessage instanceof $c3af9e523501759a$export$febc5573c75cefb0) {\n let originalTx = transactionOrMessage;\n transaction = new $c3af9e523501759a$export$febc5573c75cefb0();\n transaction.feePayer = originalTx.feePayer;\n transaction.instructions = transactionOrMessage.instructions;\n transaction.nonceInfo = originalTx.nonceInfo;\n transaction.signatures = originalTx.signatures;\n } else {\n transaction = $c3af9e523501759a$export$febc5573c75cefb0.populate(transactionOrMessage);\n // HACK: this function relies on mutating the populated transaction\n transaction._message = transaction._json = undefined;\n }\n if (configOrSigners !== undefined && !Array.isArray(configOrSigners)) throw new Error('Invalid arguments');\n const signers = configOrSigners;\n if (transaction.nonceInfo && signers) transaction.sign(...signers);\n else {\n let disableCache = this._disableBlockhashCaching;\n for(;;){\n const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);\n transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;\n transaction.recentBlockhash = latestBlockhash.blockhash;\n if (!signers) break;\n transaction.sign(...signers);\n if (!transaction.signature) throw new Error('!signature'); // should never happen\n const signature = transaction.signature.toString('base64');\n if (!this._blockhashInfo.simulatedSignatures.includes(signature) && !this._blockhashInfo.transactionSignatures.includes(signature)) {\n // The signature of this transaction has not been seen before with the\n // current recentBlockhash, all done. Let's break\n this._blockhashInfo.simulatedSignatures.push(signature);\n break;\n } else // This transaction would be treated as duplicate (its derived signature\n // matched to one of already recorded signatures).\n // So, we must fetch a new blockhash for a different signature by disabling\n // our cache not to wait for the cache expiration (BLOCKHASH_CACHE_TIMEOUT_MS).\n disableCache = true;\n }\n }\n const message = transaction._compile();\n const signData = message.serialize();\n const wireTransaction = transaction._serialize(signData);\n const encodedTransaction = wireTransaction.toString('base64');\n const config = {\n encoding: 'base64',\n commitment: this.commitment\n };\n if (includeAccounts) {\n const addresses = (Array.isArray(includeAccounts) ? includeAccounts : message.nonProgramIds()).map((key)=>key.toBase58());\n config['accounts'] = {\n encoding: 'base64',\n addresses: addresses\n };\n }\n if (signers) config.sigVerify = true;\n if (configOrSigners && typeof configOrSigners === 'object' && 'innerInstructions' in configOrSigners) config.innerInstructions = configOrSigners.innerInstructions;\n const args = [\n encodedTransaction,\n config\n ];\n const unsafeRes = await this._rpcRequest('simulateTransaction', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$SimulatedTransactionResponseStruct);\n if ('error' in res) {\n let logs;\n if ('data' in res.error) {\n logs = res.error.data.logs;\n if (logs && Array.isArray(logs)) {\n const traceIndent = '\\n ';\n const logTrace = traceIndent + logs.join(traceIndent);\n console.error(res.error.message, logTrace);\n }\n }\n throw new $c3af9e523501759a$export$121e803f723b3045({\n action: 'simulate',\n signature: '',\n transactionMessage: res.error.message,\n logs: logs\n });\n }\n return res.result;\n }\n /**\n * Sign and send a transaction\n *\n * @deprecated Instead, call {@link sendTransaction} with a {@link\n * VersionedTransaction}\n */ /**\n * Send a signed transaction\n */ // eslint-disable-next-line no-dupe-class-members\n /**\n * Sign and send a transaction\n */ // eslint-disable-next-line no-dupe-class-members\n async sendTransaction(transaction, signersOrOptions, options) {\n if ('version' in transaction) {\n if (signersOrOptions && Array.isArray(signersOrOptions)) throw new Error('Invalid arguments');\n const wireTransaction = transaction.serialize();\n return await this.sendRawTransaction(wireTransaction, signersOrOptions);\n }\n if (signersOrOptions === undefined || !Array.isArray(signersOrOptions)) throw new Error('Invalid arguments');\n const signers = signersOrOptions;\n if (transaction.nonceInfo) transaction.sign(...signers);\n else {\n let disableCache = this._disableBlockhashCaching;\n for(;;){\n const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);\n transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;\n transaction.recentBlockhash = latestBlockhash.blockhash;\n transaction.sign(...signers);\n if (!transaction.signature) throw new Error('!signature'); // should never happen\n const signature = transaction.signature.toString('base64');\n if (!this._blockhashInfo.transactionSignatures.includes(signature)) {\n // The signature of this transaction has not been seen before with the\n // current recentBlockhash, all done. Let's break\n this._blockhashInfo.transactionSignatures.push(signature);\n break;\n } else // This transaction would be treated as duplicate (its derived signature\n // matched to one of already recorded signatures).\n // So, we must fetch a new blockhash for a different signature by disabling\n // our cache not to wait for the cache expiration (BLOCKHASH_CACHE_TIMEOUT_MS).\n disableCache = true;\n }\n }\n const wireTransaction = transaction.serialize();\n return await this.sendRawTransaction(wireTransaction, options);\n }\n /**\n * Send a transaction that has already been signed and serialized into the\n * wire format\n */ async sendRawTransaction(rawTransaction, options) {\n const encodedTransaction = $c3af9e523501759a$var$toBuffer(rawTransaction).toString('base64');\n const result = await this.sendEncodedTransaction(encodedTransaction, options);\n return result;\n }\n /**\n * Send a transaction that has already been signed, serialized into the\n * wire format, and encoded as a base64 string\n */ async sendEncodedTransaction(encodedTransaction, options) {\n const config = {\n encoding: 'base64'\n };\n const skipPreflight = options && options.skipPreflight;\n const preflightCommitment = skipPreflight === true ? 'processed' // FIXME Remove when https://github.com/anza-xyz/agave/pull/483 is deployed.\n : options && options.preflightCommitment || this.commitment;\n if (options && options.maxRetries != null) config.maxRetries = options.maxRetries;\n if (options && options.minContextSlot != null) config.minContextSlot = options.minContextSlot;\n if (skipPreflight) config.skipPreflight = skipPreflight;\n if (preflightCommitment) config.preflightCommitment = preflightCommitment;\n const args = [\n encodedTransaction,\n config\n ];\n const unsafeRes = await this._rpcRequest('sendTransaction', args);\n const res = (0, $5DqgT.create)(unsafeRes, $c3af9e523501759a$var$SendTransactionRpcResult);\n if ('error' in res) {\n let logs = undefined;\n if ('data' in res.error) logs = res.error.data.logs;\n throw new $c3af9e523501759a$export$121e803f723b3045({\n action: skipPreflight ? 'send' : 'simulate',\n signature: '',\n transactionMessage: res.error.message,\n logs: logs\n });\n }\n return res.result;\n }\n /**\n * @internal\n */ _wsOnOpen() {\n this._rpcWebSocketConnected = true;\n this._rpcWebSocketHeartbeat = setInterval(()=>{\n // Ping server every 5s to prevent idle timeouts\n (async ()=>{\n try {\n await this._rpcWebSocket.notify('ping');\n // eslint-disable-next-line no-empty\n } catch {}\n })();\n }, 5000);\n this._updateSubscriptions();\n }\n /**\n * @internal\n */ _wsOnError(err) {\n this._rpcWebSocketConnected = false;\n console.error('ws error:', err.message);\n }\n /**\n * @internal\n */ _wsOnClose(code) {\n this._rpcWebSocketConnected = false;\n this._rpcWebSocketGeneration = (this._rpcWebSocketGeneration + 1) % Number.MAX_SAFE_INTEGER;\n if (this._rpcWebSocketIdleTimeout) {\n clearTimeout(this._rpcWebSocketIdleTimeout);\n this._rpcWebSocketIdleTimeout = null;\n }\n if (this._rpcWebSocketHeartbeat) {\n clearInterval(this._rpcWebSocketHeartbeat);\n this._rpcWebSocketHeartbeat = null;\n }\n if (code === 1000) {\n // explicit close, check if any subscriptions have been made since close\n this._updateSubscriptions();\n return;\n }\n // implicit close, prepare subscriptions for auto-reconnect\n this._subscriptionCallbacksByServerSubscriptionId = {};\n Object.entries(this._subscriptionsByHash).forEach(([hash, subscription])=>{\n this._setSubscription(hash, {\n ...subscription,\n state: 'pending'\n });\n });\n }\n /**\n * @internal\n */ _setSubscription(hash, nextSubscription) {\n const prevState = this._subscriptionsByHash[hash]?.state;\n this._subscriptionsByHash[hash] = nextSubscription;\n if (prevState !== nextSubscription.state) {\n const stateChangeCallbacks = this._subscriptionStateChangeCallbacksByHash[hash];\n if (stateChangeCallbacks) stateChangeCallbacks.forEach((cb)=>{\n try {\n cb(nextSubscription.state);\n // eslint-disable-next-line no-empty\n } catch {}\n });\n }\n }\n /**\n * @internal\n */ _onSubscriptionStateChange(clientSubscriptionId, callback) {\n const hash = this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];\n if (hash == null) return ()=>{};\n const stateChangeCallbacks = this._subscriptionStateChangeCallbacksByHash[hash] ||= new Set();\n stateChangeCallbacks.add(callback);\n return ()=>{\n stateChangeCallbacks.delete(callback);\n if (stateChangeCallbacks.size === 0) delete this._subscriptionStateChangeCallbacksByHash[hash];\n };\n }\n /**\n * @internal\n */ async _updateSubscriptions() {\n if (Object.keys(this._subscriptionsByHash).length === 0) {\n if (this._rpcWebSocketConnected) {\n this._rpcWebSocketConnected = false;\n this._rpcWebSocketIdleTimeout = setTimeout(()=>{\n this._rpcWebSocketIdleTimeout = null;\n try {\n this._rpcWebSocket.close();\n } catch (err) {\n // swallow error if socket has already been closed.\n if (err instanceof Error) console.log(`Error when closing socket connection: ${err.message}`);\n }\n }, 500);\n }\n return;\n }\n if (this._rpcWebSocketIdleTimeout !== null) {\n clearTimeout(this._rpcWebSocketIdleTimeout);\n this._rpcWebSocketIdleTimeout = null;\n this._rpcWebSocketConnected = true;\n }\n if (!this._rpcWebSocketConnected) {\n this._rpcWebSocket.connect();\n return;\n }\n const activeWebSocketGeneration = this._rpcWebSocketGeneration;\n const isCurrentConnectionStillActive = ()=>{\n return activeWebSocketGeneration === this._rpcWebSocketGeneration;\n };\n await Promise.all(// Don't be tempted to change this to `Object.entries`. We call\n // `_updateSubscriptions` recursively when processing the state,\n // so it's important that we look up the *current* version of\n // each subscription, every time we process a hash.\n Object.keys(this._subscriptionsByHash).map(async (hash)=>{\n const subscription = this._subscriptionsByHash[hash];\n if (subscription === undefined) // This entry has since been deleted. Skip.\n return;\n switch(subscription.state){\n case 'pending':\n case 'unsubscribed':\n if (subscription.callbacks.size === 0) {\n /**\n * You can end up here when:\n *\n * - a subscription has recently unsubscribed\n * without having new callbacks added to it\n * while the unsubscribe was in flight, or\n * - when a pending subscription has its\n * listeners removed before a request was\n * sent to the server.\n *\n * Being that nobody is interested in this\n * subscription any longer, delete it.\n */ delete this._subscriptionsByHash[hash];\n if (subscription.state === 'unsubscribed') delete this._subscriptionCallbacksByServerSubscriptionId[subscription.serverSubscriptionId];\n await this._updateSubscriptions();\n return;\n }\n await (async ()=>{\n const { args: args, method: method } = subscription;\n try {\n this._setSubscription(hash, {\n ...subscription,\n state: 'subscribing'\n });\n const serverSubscriptionId = await this._rpcWebSocket.call(method, args);\n this._setSubscription(hash, {\n ...subscription,\n serverSubscriptionId: serverSubscriptionId,\n state: 'subscribed'\n });\n this._subscriptionCallbacksByServerSubscriptionId[serverSubscriptionId] = subscription.callbacks;\n await this._updateSubscriptions();\n } catch (e) {\n console.error(`Received ${e instanceof Error ? '' : 'JSON-RPC '}error calling \\`${method}\\``, {\n args: args,\n error: e\n });\n if (!isCurrentConnectionStillActive()) return;\n // TODO: Maybe add an 'errored' state or a retry limit?\n this._setSubscription(hash, {\n ...subscription,\n state: 'pending'\n });\n await this._updateSubscriptions();\n }\n })();\n break;\n case 'subscribed':\n if (subscription.callbacks.size === 0) // By the time we successfully set up a subscription\n // with the server, the client stopped caring about it.\n // Tear it down now.\n await (async ()=>{\n const { serverSubscriptionId: serverSubscriptionId, unsubscribeMethod: unsubscribeMethod } = subscription;\n if (this._subscriptionsAutoDisposedByRpc.has(serverSubscriptionId)) /**\n * Special case.\n * If we're dealing with a subscription that has been auto-\n * disposed by the RPC, then we can skip the RPC call to\n * tear down the subscription here.\n *\n * NOTE: There is a proposal to eliminate this special case, here:\n * https://github.com/solana-labs/solana/issues/18892\n */ this._subscriptionsAutoDisposedByRpc.delete(serverSubscriptionId);\n else {\n this._setSubscription(hash, {\n ...subscription,\n state: 'unsubscribing'\n });\n this._setSubscription(hash, {\n ...subscription,\n state: 'unsubscribing'\n });\n try {\n await this._rpcWebSocket.call(unsubscribeMethod, [\n serverSubscriptionId\n ]);\n } catch (e) {\n if (e instanceof Error) console.error(`${unsubscribeMethod} error:`, e.message);\n if (!isCurrentConnectionStillActive()) return;\n // TODO: Maybe add an 'errored' state or a retry limit?\n this._setSubscription(hash, {\n ...subscription,\n state: 'subscribed'\n });\n await this._updateSubscriptions();\n return;\n }\n }\n this._setSubscription(hash, {\n ...subscription,\n state: 'unsubscribed'\n });\n await this._updateSubscriptions();\n })();\n break;\n }\n }));\n }\n /**\n * @internal\n */ _handleServerNotification(serverSubscriptionId, callbackArgs) {\n const callbacks = this._subscriptionCallbacksByServerSubscriptionId[serverSubscriptionId];\n if (callbacks === undefined) return;\n callbacks.forEach((cb)=>{\n try {\n cb(// I failed to find a way to convince TypeScript that `cb` is of type\n // `TCallback` which is certainly compatible with `Parameters`.\n // See https://github.com/microsoft/TypeScript/issues/47615\n // @ts-ignore\n ...callbackArgs);\n } catch (e) {\n console.error(e);\n }\n });\n }\n /**\n * @internal\n */ _wsOnAccountNotification(notification) {\n const { result: result, subscription: subscription } = (0, $5DqgT.create)(notification, $c3af9e523501759a$var$AccountNotificationResult);\n this._handleServerNotification(subscription, [\n result.value,\n result.context\n ]);\n }\n /**\n * @internal\n */ _makeSubscription(subscriptionConfig, /**\n * When preparing `args` for a call to `_makeSubscription`, be sure\n * to carefully apply a default `commitment` property, if necessary.\n *\n * - If the user supplied a `commitment` use that.\n * - Otherwise, if the `Connection::commitment` is set, use that.\n * - Otherwise, set it to the RPC server default: `finalized`.\n *\n * This is extremely important to ensure that these two fundamentally\n * identical subscriptions produce the same identifying hash:\n *\n * - A subscription made without specifying a commitment.\n * - A subscription made where the commitment specified is the same\n * as the default applied to the subscription above.\n *\n * Example; these two subscriptions must produce the same hash:\n *\n * - An `accountSubscribe` subscription for `'PUBKEY'`\n * - An `accountSubscribe` subscription for `'PUBKEY'` with commitment\n * `'finalized'`.\n *\n * See the 'making a subscription with defaulted params omitted' test\n * in `connection-subscriptions.ts` for more.\n */ args) {\n const clientSubscriptionId = this._nextClientSubscriptionId++;\n const hash = $c3af9e523501759a$var$fastStableStringify([\n subscriptionConfig.method,\n args\n ]);\n const existingSubscription = this._subscriptionsByHash[hash];\n if (existingSubscription === undefined) this._subscriptionsByHash[hash] = {\n ...subscriptionConfig,\n args: args,\n callbacks: new Set([\n subscriptionConfig.callback\n ]),\n state: 'pending'\n };\n else existingSubscription.callbacks.add(subscriptionConfig.callback);\n this._subscriptionHashByClientSubscriptionId[clientSubscriptionId] = hash;\n this._subscriptionDisposeFunctionsByClientSubscriptionId[clientSubscriptionId] = async ()=>{\n delete this._subscriptionDisposeFunctionsByClientSubscriptionId[clientSubscriptionId];\n delete this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];\n const subscription = this._subscriptionsByHash[hash];\n $c3af9e523501759a$var$assert(subscription !== undefined, `Could not find a \\`Subscription\\` when tearing down client subscription #${clientSubscriptionId}`);\n subscription.callbacks.delete(subscriptionConfig.callback);\n await this._updateSubscriptions();\n };\n this._updateSubscriptions();\n return clientSubscriptionId;\n }\n /**\n * Register a callback to be invoked whenever the specified account changes\n *\n * @param publicKey Public key of the account to monitor\n * @param callback Function to invoke whenever the account is changed\n * @param config\n * @return subscription id\n */ /** @deprecated Instead, pass in an {@link AccountSubscriptionConfig} */ // eslint-disable-next-line no-dupe-class-members\n // eslint-disable-next-line no-dupe-class-members\n onAccountChange(publicKey, callback, commitmentOrConfig) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([\n publicKey.toBase58()\n ], commitment || this._commitment || 'finalized', // Apply connection/server default.\n 'base64', config);\n return this._makeSubscription({\n callback: callback,\n method: 'accountSubscribe',\n unsubscribeMethod: 'accountUnsubscribe'\n }, args);\n }\n /**\n * Deregister an account notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */ async removeAccountChangeListener(clientSubscriptionId) {\n await this._unsubscribeClientSubscription(clientSubscriptionId, 'account change');\n }\n /**\n * @internal\n */ _wsOnProgramAccountNotification(notification) {\n const { result: result, subscription: subscription } = (0, $5DqgT.create)(notification, $c3af9e523501759a$var$ProgramAccountNotificationResult);\n this._handleServerNotification(subscription, [\n {\n accountId: result.value.pubkey,\n accountInfo: result.value.account\n },\n result.context\n ]);\n }\n /**\n * Register a callback to be invoked whenever accounts owned by the\n * specified program change\n *\n * @param programId Public key of the program to monitor\n * @param callback Function to invoke whenever the account is changed\n * @param config\n * @return subscription id\n */ /** @deprecated Instead, pass in a {@link ProgramAccountSubscriptionConfig} */ // eslint-disable-next-line no-dupe-class-members\n // eslint-disable-next-line no-dupe-class-members\n onProgramAccountChange(programId, callback, commitmentOrConfig, maybeFilters) {\n const { commitment: commitment, config: config } = $c3af9e523501759a$var$extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([\n programId.toBase58()\n ], commitment || this._commitment || 'finalized', // Apply connection/server default.\n 'base64' /* encoding */ , config ? config : maybeFilters ? {\n filters: $c3af9e523501759a$var$applyDefaultMemcmpEncodingToFilters(maybeFilters)\n } : undefined /* extra */ );\n return this._makeSubscription({\n callback: callback,\n method: 'programSubscribe',\n unsubscribeMethod: 'programUnsubscribe'\n }, args);\n }\n /**\n * Deregister an account notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */ async removeProgramAccountChangeListener(clientSubscriptionId) {\n await this._unsubscribeClientSubscription(clientSubscriptionId, 'program account change');\n }\n /**\n * Registers a callback to be invoked whenever logs are emitted.\n */ onLogs(filter, callback, commitment) {\n const args = this._buildArgs([\n typeof filter === 'object' ? {\n mentions: [\n filter.toString()\n ]\n } : filter\n ], commitment || this._commitment || 'finalized' // Apply connection/server default.\n );\n return this._makeSubscription({\n callback: callback,\n method: 'logsSubscribe',\n unsubscribeMethod: 'logsUnsubscribe'\n }, args);\n }\n /**\n * Deregister a logs callback.\n *\n * @param clientSubscriptionId client subscription id to deregister.\n */ async removeOnLogsListener(clientSubscriptionId) {\n await this._unsubscribeClientSubscription(clientSubscriptionId, 'logs');\n }\n /**\n * @internal\n */ _wsOnLogsNotification(notification) {\n const { result: result, subscription: subscription } = (0, $5DqgT.create)(notification, $c3af9e523501759a$var$LogsNotificationResult);\n this._handleServerNotification(subscription, [\n result.value,\n result.context\n ]);\n }\n /**\n * @internal\n */ _wsOnSlotNotification(notification) {\n const { result: result, subscription: subscription } = (0, $5DqgT.create)(notification, $c3af9e523501759a$var$SlotNotificationResult);\n this._handleServerNotification(subscription, [\n result\n ]);\n }\n /**\n * Register a callback to be invoked upon slot changes\n *\n * @param callback Function to invoke whenever the slot changes\n * @return subscription id\n */ onSlotChange(callback) {\n return this._makeSubscription({\n callback: callback,\n method: 'slotSubscribe',\n unsubscribeMethod: 'slotUnsubscribe'\n }, []);\n }\n /**\n * Deregister a slot notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */ async removeSlotChangeListener(clientSubscriptionId) {\n await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot change');\n }\n /**\n * @internal\n */ _wsOnSlotUpdatesNotification(notification) {\n const { result: result, subscription: subscription } = (0, $5DqgT.create)(notification, $c3af9e523501759a$var$SlotUpdateNotificationResult);\n this._handleServerNotification(subscription, [\n result\n ]);\n }\n /**\n * Register a callback to be invoked upon slot updates. {@link SlotUpdate}'s\n * may be useful to track live progress of a cluster.\n *\n * @param callback Function to invoke whenever the slot updates\n * @return subscription id\n */ onSlotUpdate(callback) {\n return this._makeSubscription({\n callback: callback,\n method: 'slotsUpdatesSubscribe',\n unsubscribeMethod: 'slotsUpdatesUnsubscribe'\n }, []);\n }\n /**\n * Deregister a slot update notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */ async removeSlotUpdateListener(clientSubscriptionId) {\n await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot update');\n }\n /**\n * @internal\n */ async _unsubscribeClientSubscription(clientSubscriptionId, subscriptionName) {\n const dispose = this._subscriptionDisposeFunctionsByClientSubscriptionId[clientSubscriptionId];\n if (dispose) await dispose();\n else console.warn('Ignored unsubscribe request because an active subscription with id ' + `\\`${clientSubscriptionId}\\` for '${subscriptionName}' events ` + 'could not be found.');\n }\n _buildArgs(args, override, encoding, extra) {\n const commitment = override || this._commitment;\n if (commitment || encoding || extra) {\n let options = {};\n if (encoding) options.encoding = encoding;\n if (commitment) options.commitment = commitment;\n if (extra) options = Object.assign(options, extra);\n args.push(options);\n }\n return args;\n }\n /**\n * @internal\n */ _buildArgsAtLeastConfirmed(args, override, encoding, extra) {\n const commitment = override || this._commitment;\n if (commitment && ![\n 'confirmed',\n 'finalized'\n ].includes(commitment)) throw new Error('Using Connection with default commitment: `' + this._commitment + '`, but method requires at least `confirmed`');\n return this._buildArgs(args, override, encoding, extra);\n }\n /**\n * @internal\n */ _wsOnSignatureNotification(notification) {\n const { result: result, subscription: subscription } = (0, $5DqgT.create)(notification, $c3af9e523501759a$var$SignatureNotificationResult);\n if (result.value !== 'receivedSignature') /**\n * Special case.\n * After a signature is processed, RPCs automatically dispose of the\n * subscription on the server side. We need to track which of these\n * subscriptions have been disposed in such a way, so that we know\n * whether the client is dealing with a not-yet-processed signature\n * (in which case we must tear down the server subscription) or an\n * already-processed signature (in which case the client can simply\n * clear out the subscription locally without telling the server).\n *\n * NOTE: There is a proposal to eliminate this special case, here:\n * https://github.com/solana-labs/solana/issues/18892\n */ this._subscriptionsAutoDisposedByRpc.add(subscription);\n this._handleServerNotification(subscription, result.value === 'receivedSignature' ? [\n {\n type: 'received'\n },\n result.context\n ] : [\n {\n type: 'status',\n result: result.value\n },\n result.context\n ]);\n }\n /**\n * Register a callback to be invoked upon signature updates\n *\n * @param signature Transaction signature string in base 58\n * @param callback Function to invoke on signature notifications\n * @param commitment Specify the commitment level signature must reach before notification\n * @return subscription id\n */ onSignature(signature, callback, commitment) {\n const args = this._buildArgs([\n signature\n ], commitment || this._commitment || 'finalized' // Apply connection/server default.\n );\n const clientSubscriptionId = this._makeSubscription({\n callback: (notification, context)=>{\n if (notification.type === 'status') {\n callback(notification.result, context);\n // Signatures subscriptions are auto-removed by the RPC service\n // so no need to explicitly send an unsubscribe message.\n try {\n this.removeSignatureListener(clientSubscriptionId);\n // eslint-disable-next-line no-empty\n } catch (_err) {\n // Already removed.\n }\n }\n },\n method: 'signatureSubscribe',\n unsubscribeMethod: 'signatureUnsubscribe'\n }, args);\n return clientSubscriptionId;\n }\n /**\n * Register a callback to be invoked when a transaction is\n * received and/or processed.\n *\n * @param signature Transaction signature string in base 58\n * @param callback Function to invoke on signature notifications\n * @param options Enable received notifications and set the commitment\n * level that signature must reach before notification\n * @return subscription id\n */ onSignatureWithOptions(signature, callback, options) {\n const { commitment: commitment, ...extra } = {\n ...options,\n commitment: options && options.commitment || this._commitment || 'finalized' // Apply connection/server default.\n };\n const args = this._buildArgs([\n signature\n ], commitment, undefined /* encoding */ , extra);\n const clientSubscriptionId = this._makeSubscription({\n callback: (notification, context)=>{\n callback(notification, context);\n // Signatures subscriptions are auto-removed by the RPC service\n // so no need to explicitly send an unsubscribe message.\n try {\n this.removeSignatureListener(clientSubscriptionId);\n // eslint-disable-next-line no-empty\n } catch (_err) {\n // Already removed.\n }\n },\n method: 'signatureSubscribe',\n unsubscribeMethod: 'signatureUnsubscribe'\n }, args);\n return clientSubscriptionId;\n }\n /**\n * Deregister a signature notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */ async removeSignatureListener(clientSubscriptionId) {\n await this._unsubscribeClientSubscription(clientSubscriptionId, 'signature result');\n }\n /**\n * @internal\n */ _wsOnRootNotification(notification) {\n const { result: result, subscription: subscription } = (0, $5DqgT.create)(notification, $c3af9e523501759a$var$RootNotificationResult);\n this._handleServerNotification(subscription, [\n result\n ]);\n }\n /**\n * Register a callback to be invoked upon root changes\n *\n * @param callback Function to invoke whenever the root changes\n * @return subscription id\n */ onRootChange(callback) {\n return this._makeSubscription({\n callback: callback,\n method: 'rootSubscribe',\n unsubscribeMethod: 'rootUnsubscribe'\n }, []);\n }\n /**\n * Deregister a root notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */ async removeRootChangeListener(clientSubscriptionId) {\n await this._unsubscribeClientSubscription(clientSubscriptionId, 'root change');\n }\n}\n/**\n * Keypair signer interface\n */ /**\n * An account keypair used for signing transactions.\n */ class $c3af9e523501759a$export$c53bca448cf33676 {\n /**\n * Create a new keypair instance.\n * Generate random keypair if no {@link Ed25519Keypair} is provided.\n *\n * @param {Ed25519Keypair} keypair ed25519 keypair\n */ constructor(keypair){\n this._keypair = void 0;\n this._keypair = keypair ?? $c3af9e523501759a$var$generateKeypair();\n }\n /**\n * Generate a new random keypair\n *\n * @returns {Keypair} Keypair\n */ static generate() {\n return new $c3af9e523501759a$export$c53bca448cf33676($c3af9e523501759a$var$generateKeypair());\n }\n /**\n * Create a keypair from a raw secret key byte array.\n *\n * This method should only be used to recreate a keypair from a previously\n * generated secret key. Generating keypairs from a random seed should be done\n * with the {@link Keypair.fromSeed} method.\n *\n * @throws error if the provided secret key is invalid and validation is not skipped.\n *\n * @param secretKey secret key byte array\n * @param options skip secret key validation\n *\n * @returns {Keypair} Keypair\n */ static fromSecretKey(secretKey, options) {\n if (secretKey.byteLength !== 64) throw new Error('bad secret key size');\n const publicKey = secretKey.slice(32, 64);\n if (!options || !options.skipValidation) {\n const privateScalar = secretKey.slice(0, 32);\n const computedPublicKey = $c3af9e523501759a$var$getPublicKey(privateScalar);\n for(let ii = 0; ii < 32; ii++){\n if (publicKey[ii] !== computedPublicKey[ii]) throw new Error('provided secretKey is invalid');\n }\n }\n return new $c3af9e523501759a$export$c53bca448cf33676({\n publicKey: publicKey,\n secretKey: secretKey\n });\n }\n /**\n * Generate a keypair from a 32 byte seed.\n *\n * @param seed seed byte array\n *\n * @returns {Keypair} Keypair\n */ static fromSeed(seed) {\n const publicKey = $c3af9e523501759a$var$getPublicKey(seed);\n const secretKey = new Uint8Array(64);\n secretKey.set(seed);\n secretKey.set(publicKey, 32);\n return new $c3af9e523501759a$export$c53bca448cf33676({\n publicKey: publicKey,\n secretKey: secretKey\n });\n }\n /**\n * The public key for this keypair\n *\n * @returns {PublicKey} PublicKey\n */ get publicKey() {\n return new $c3af9e523501759a$export$ca8b6604d6ce14de(this._keypair.publicKey);\n }\n /**\n * The raw secret key for this keypair\n * @returns {Uint8Array} Secret key in an array of Uint8 bytes\n */ get secretKey() {\n return new Uint8Array(this._keypair.secretKey);\n }\n}\n/**\n * An enumeration of valid LookupTableInstructionType's\n */ /**\n * An enumeration of valid address lookup table InstructionType's\n * @internal\n */ const $c3af9e523501759a$export$7d102200c3a357d6 = Object.freeze({\n CreateLookupTable: {\n index: 0,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$u64('recentSlot'),\n $Q02IV.u8('bumpSeed')\n ])\n },\n FreezeLookupTable: {\n index: 1,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction')\n ])\n },\n ExtendLookupTable: {\n index: 2,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$u64(),\n $Q02IV.seq($c3af9e523501759a$var$publicKey(), $Q02IV.offset($Q02IV.u32(), -8), 'addresses')\n ])\n },\n DeactivateLookupTable: {\n index: 3,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction')\n ])\n },\n CloseLookupTable: {\n index: 4,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction')\n ])\n }\n});\nclass $c3af9e523501759a$export$3ab2b24d551f0dc2 {\n /**\n * @internal\n */ constructor(){}\n static decodeInstructionType(instruction) {\n this.checkProgramId(instruction.programId);\n const instructionTypeLayout = $Q02IV.u32('instruction');\n const index = instructionTypeLayout.decode(instruction.data);\n let type;\n for (const [layoutType, layout] of Object.entries($c3af9e523501759a$export$7d102200c3a357d6))if (layout.index == index) {\n type = layoutType;\n break;\n }\n if (!type) throw new Error('Invalid Instruction. Should be a LookupTable Instruction');\n return type;\n }\n static decodeCreateLookupTable(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeysLength(instruction.keys, 4);\n const { recentSlot: recentSlot } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$7d102200c3a357d6.CreateLookupTable, instruction.data);\n return {\n authority: instruction.keys[1].pubkey,\n payer: instruction.keys[2].pubkey,\n recentSlot: Number(recentSlot)\n };\n }\n static decodeExtendLookupTable(instruction) {\n this.checkProgramId(instruction.programId);\n if (instruction.keys.length < 2) throw new Error(`invalid instruction; found ${instruction.keys.length} keys, expected at least 2`);\n const { addresses: addresses } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$7d102200c3a357d6.ExtendLookupTable, instruction.data);\n return {\n lookupTable: instruction.keys[0].pubkey,\n authority: instruction.keys[1].pubkey,\n payer: instruction.keys.length > 2 ? instruction.keys[2].pubkey : undefined,\n addresses: addresses.map((buffer)=>new $c3af9e523501759a$export$ca8b6604d6ce14de(buffer))\n };\n }\n static decodeCloseLookupTable(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeysLength(instruction.keys, 3);\n return {\n lookupTable: instruction.keys[0].pubkey,\n authority: instruction.keys[1].pubkey,\n recipient: instruction.keys[2].pubkey\n };\n }\n static decodeFreezeLookupTable(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeysLength(instruction.keys, 2);\n return {\n lookupTable: instruction.keys[0].pubkey,\n authority: instruction.keys[1].pubkey\n };\n }\n static decodeDeactivateLookupTable(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeysLength(instruction.keys, 2);\n return {\n lookupTable: instruction.keys[0].pubkey,\n authority: instruction.keys[1].pubkey\n };\n }\n /**\n * @internal\n */ static checkProgramId(programId) {\n if (!programId.equals($c3af9e523501759a$export$5147a345798de168.programId)) throw new Error('invalid instruction; programId is not AddressLookupTable Program');\n }\n /**\n * @internal\n */ static checkKeysLength(keys, expectedLength) {\n if (keys.length < expectedLength) throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);\n }\n}\nclass $c3af9e523501759a$export$5147a345798de168 {\n /**\n * @internal\n */ constructor(){}\n static createLookupTable(params) {\n const [lookupTableAddress, bumpSeed] = $c3af9e523501759a$export$ca8b6604d6ce14de.findProgramAddressSync([\n params.authority.toBuffer(),\n (0, $gyRuj.toBufferLE)(BigInt(params.recentSlot), 8)\n ], this.programId);\n const type = $c3af9e523501759a$export$7d102200c3a357d6.CreateLookupTable;\n const data = $c3af9e523501759a$var$encodeData(type, {\n recentSlot: BigInt(params.recentSlot),\n bumpSeed: bumpSeed\n });\n const keys = [\n {\n pubkey: lookupTableAddress,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: params.authority,\n isSigner: true,\n isWritable: false\n },\n {\n pubkey: params.payer,\n isSigner: true,\n isWritable: true\n },\n {\n pubkey: $c3af9e523501759a$export$d8c4e17726848113.programId,\n isSigner: false,\n isWritable: false\n }\n ];\n return [\n new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n programId: this.programId,\n keys: keys,\n data: data\n }),\n lookupTableAddress\n ];\n }\n static freezeLookupTable(params) {\n const type = $c3af9e523501759a$export$7d102200c3a357d6.FreezeLookupTable;\n const data = $c3af9e523501759a$var$encodeData(type);\n const keys = [\n {\n pubkey: params.lookupTable,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: params.authority,\n isSigner: true,\n isWritable: false\n }\n ];\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n programId: this.programId,\n keys: keys,\n data: data\n });\n }\n static extendLookupTable(params) {\n const type = $c3af9e523501759a$export$7d102200c3a357d6.ExtendLookupTable;\n const data = $c3af9e523501759a$var$encodeData(type, {\n addresses: params.addresses.map((addr)=>addr.toBytes())\n });\n const keys = [\n {\n pubkey: params.lookupTable,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: params.authority,\n isSigner: true,\n isWritable: false\n }\n ];\n if (params.payer) keys.push({\n pubkey: params.payer,\n isSigner: true,\n isWritable: true\n }, {\n pubkey: $c3af9e523501759a$export$d8c4e17726848113.programId,\n isSigner: false,\n isWritable: false\n });\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n programId: this.programId,\n keys: keys,\n data: data\n });\n }\n static deactivateLookupTable(params) {\n const type = $c3af9e523501759a$export$7d102200c3a357d6.DeactivateLookupTable;\n const data = $c3af9e523501759a$var$encodeData(type);\n const keys = [\n {\n pubkey: params.lookupTable,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: params.authority,\n isSigner: true,\n isWritable: false\n }\n ];\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n programId: this.programId,\n keys: keys,\n data: data\n });\n }\n static closeLookupTable(params) {\n const type = $c3af9e523501759a$export$7d102200c3a357d6.CloseLookupTable;\n const data = $c3af9e523501759a$var$encodeData(type);\n const keys = [\n {\n pubkey: params.lookupTable,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: params.authority,\n isSigner: true,\n isWritable: false\n },\n {\n pubkey: params.recipient,\n isSigner: false,\n isWritable: true\n }\n ];\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n programId: this.programId,\n keys: keys,\n data: data\n });\n }\n}\n$c3af9e523501759a$export$5147a345798de168.programId = new $c3af9e523501759a$export$ca8b6604d6ce14de('AddressLookupTab1e1111111111111111111111111');\n/**\n * Compute Budget Instruction class\n */ class $c3af9e523501759a$export$bc4776847c641a67 {\n /**\n * @internal\n */ constructor(){}\n /**\n * Decode a compute budget instruction and retrieve the instruction type.\n */ static decodeInstructionType(instruction) {\n this.checkProgramId(instruction.programId);\n const instructionTypeLayout = $Q02IV.u8('instruction');\n const typeIndex = instructionTypeLayout.decode(instruction.data);\n let type;\n for (const [ixType, layout] of Object.entries($c3af9e523501759a$export$b7c79c50764da3d6))if (layout.index == typeIndex) {\n type = ixType;\n break;\n }\n if (!type) throw new Error('Instruction type incorrect; not a ComputeBudgetInstruction');\n return type;\n }\n /**\n * Decode request units compute budget instruction and retrieve the instruction params.\n */ static decodeRequestUnits(instruction) {\n this.checkProgramId(instruction.programId);\n const { units: units, additionalFee: additionalFee } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$b7c79c50764da3d6.RequestUnits, instruction.data);\n return {\n units: units,\n additionalFee: additionalFee\n };\n }\n /**\n * Decode request heap frame compute budget instruction and retrieve the instruction params.\n */ static decodeRequestHeapFrame(instruction) {\n this.checkProgramId(instruction.programId);\n const { bytes: bytes } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$b7c79c50764da3d6.RequestHeapFrame, instruction.data);\n return {\n bytes: bytes\n };\n }\n /**\n * Decode set compute unit limit compute budget instruction and retrieve the instruction params.\n */ static decodeSetComputeUnitLimit(instruction) {\n this.checkProgramId(instruction.programId);\n const { units: units } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$b7c79c50764da3d6.SetComputeUnitLimit, instruction.data);\n return {\n units: units\n };\n }\n /**\n * Decode set compute unit price compute budget instruction and retrieve the instruction params.\n */ static decodeSetComputeUnitPrice(instruction) {\n this.checkProgramId(instruction.programId);\n const { microLamports: microLamports } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$b7c79c50764da3d6.SetComputeUnitPrice, instruction.data);\n return {\n microLamports: microLamports\n };\n }\n /**\n * @internal\n */ static checkProgramId(programId) {\n if (!programId.equals($c3af9e523501759a$export$11585db5942bcdb7.programId)) throw new Error('invalid instruction; programId is not ComputeBudgetProgram');\n }\n}\n/**\n * An enumeration of valid ComputeBudgetInstructionType's\n */ /**\n * Request units instruction params\n */ /**\n * Request heap frame instruction params\n */ /**\n * Set compute unit limit instruction params\n */ /**\n * Set compute unit price instruction params\n */ /**\n * An enumeration of valid ComputeBudget InstructionType's\n * @internal\n */ const $c3af9e523501759a$export$b7c79c50764da3d6 = Object.freeze({\n RequestUnits: {\n index: 0,\n layout: $Q02IV.struct([\n $Q02IV.u8('instruction'),\n $Q02IV.u32('units'),\n $Q02IV.u32('additionalFee')\n ])\n },\n RequestHeapFrame: {\n index: 1,\n layout: $Q02IV.struct([\n $Q02IV.u8('instruction'),\n $Q02IV.u32('bytes')\n ])\n },\n SetComputeUnitLimit: {\n index: 2,\n layout: $Q02IV.struct([\n $Q02IV.u8('instruction'),\n $Q02IV.u32('units')\n ])\n },\n SetComputeUnitPrice: {\n index: 3,\n layout: $Q02IV.struct([\n $Q02IV.u8('instruction'),\n $c3af9e523501759a$var$u64('microLamports')\n ])\n }\n});\n/**\n * Factory class for transaction instructions to interact with the Compute Budget program\n */ class $c3af9e523501759a$export$11585db5942bcdb7 {\n /**\n * @internal\n */ constructor(){}\n /**\n * Public key that identifies the Compute Budget program\n */ /**\n * @deprecated Instead, call {@link setComputeUnitLimit} and/or {@link setComputeUnitPrice}\n */ static requestUnits(params) {\n const type = $c3af9e523501759a$export$b7c79c50764da3d6.RequestUnits;\n const data = $c3af9e523501759a$var$encodeData(type, params);\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n keys: [],\n programId: this.programId,\n data: data\n });\n }\n static requestHeapFrame(params) {\n const type = $c3af9e523501759a$export$b7c79c50764da3d6.RequestHeapFrame;\n const data = $c3af9e523501759a$var$encodeData(type, params);\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n keys: [],\n programId: this.programId,\n data: data\n });\n }\n static setComputeUnitLimit(params) {\n const type = $c3af9e523501759a$export$b7c79c50764da3d6.SetComputeUnitLimit;\n const data = $c3af9e523501759a$var$encodeData(type, params);\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n keys: [],\n programId: this.programId,\n data: data\n });\n }\n static setComputeUnitPrice(params) {\n const type = $c3af9e523501759a$export$b7c79c50764da3d6.SetComputeUnitPrice;\n const data = $c3af9e523501759a$var$encodeData(type, {\n microLamports: BigInt(params.microLamports)\n });\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n keys: [],\n programId: this.programId,\n data: data\n });\n }\n}\n$c3af9e523501759a$export$11585db5942bcdb7.programId = new $c3af9e523501759a$export$ca8b6604d6ce14de('ComputeBudget111111111111111111111111111111');\nconst $c3af9e523501759a$var$PRIVATE_KEY_BYTES$1 = 64;\nconst $c3af9e523501759a$var$PUBLIC_KEY_BYTES$1 = 32;\nconst $c3af9e523501759a$var$SIGNATURE_BYTES = 64;\n/**\n * Params for creating an ed25519 instruction using a public key\n */ /**\n * Params for creating an ed25519 instruction using a private key\n */ const $c3af9e523501759a$var$ED25519_INSTRUCTION_LAYOUT = $Q02IV.struct([\n $Q02IV.u8('numSignatures'),\n $Q02IV.u8('padding'),\n $Q02IV.u16('signatureOffset'),\n $Q02IV.u16('signatureInstructionIndex'),\n $Q02IV.u16('publicKeyOffset'),\n $Q02IV.u16('publicKeyInstructionIndex'),\n $Q02IV.u16('messageDataOffset'),\n $Q02IV.u16('messageDataSize'),\n $Q02IV.u16('messageInstructionIndex')\n]);\nclass $c3af9e523501759a$export$e5087aea02631e {\n /**\n * @internal\n */ constructor(){}\n /**\n * Public key that identifies the ed25519 program\n */ /**\n * Create an ed25519 instruction with a public key and signature. The\n * public key must be a buffer that is 32 bytes long, and the signature\n * must be a buffer of 64 bytes.\n */ static createInstructionWithPublicKey(params) {\n const { publicKey: publicKey, message: message, signature: signature, instructionIndex: instructionIndex } = params;\n $c3af9e523501759a$var$assert(publicKey.length === $c3af9e523501759a$var$PUBLIC_KEY_BYTES$1, `Public Key must be ${$c3af9e523501759a$var$PUBLIC_KEY_BYTES$1} bytes but received ${publicKey.length} bytes`);\n $c3af9e523501759a$var$assert(signature.length === $c3af9e523501759a$var$SIGNATURE_BYTES, `Signature must be ${$c3af9e523501759a$var$SIGNATURE_BYTES} bytes but received ${signature.length} bytes`);\n const publicKeyOffset = $c3af9e523501759a$var$ED25519_INSTRUCTION_LAYOUT.span;\n const signatureOffset = publicKeyOffset + publicKey.length;\n const messageDataOffset = signatureOffset + signature.length;\n const numSignatures = 1;\n const instructionData = (0, $6ZWSX.Buffer).alloc(messageDataOffset + message.length);\n const index = instructionIndex == null ? 0xffff // An index of `u16::MAX` makes it default to the current instruction.\n : instructionIndex;\n $c3af9e523501759a$var$ED25519_INSTRUCTION_LAYOUT.encode({\n numSignatures: numSignatures,\n padding: 0,\n signatureOffset: signatureOffset,\n signatureInstructionIndex: index,\n publicKeyOffset: publicKeyOffset,\n publicKeyInstructionIndex: index,\n messageDataOffset: messageDataOffset,\n messageDataSize: message.length,\n messageInstructionIndex: index\n }, instructionData);\n instructionData.fill(publicKey, publicKeyOffset);\n instructionData.fill(signature, signatureOffset);\n instructionData.fill(message, messageDataOffset);\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n keys: [],\n programId: $c3af9e523501759a$export$e5087aea02631e.programId,\n data: instructionData\n });\n }\n /**\n * Create an ed25519 instruction with a private key. The private key\n * must be a buffer that is 64 bytes long.\n */ static createInstructionWithPrivateKey(params) {\n const { privateKey: privateKey, message: message, instructionIndex: instructionIndex } = params;\n $c3af9e523501759a$var$assert(privateKey.length === $c3af9e523501759a$var$PRIVATE_KEY_BYTES$1, `Private key must be ${$c3af9e523501759a$var$PRIVATE_KEY_BYTES$1} bytes but received ${privateKey.length} bytes`);\n try {\n const keypair = $c3af9e523501759a$export$c53bca448cf33676.fromSecretKey(privateKey);\n const publicKey = keypair.publicKey.toBytes();\n const signature = $c3af9e523501759a$var$sign(message, keypair.secretKey);\n return this.createInstructionWithPublicKey({\n publicKey: publicKey,\n message: message,\n signature: signature,\n instructionIndex: instructionIndex\n });\n } catch (error) {\n throw new Error(`Error creating instruction; ${error}`);\n }\n }\n}\n$c3af9e523501759a$export$e5087aea02631e.programId = new $c3af9e523501759a$export$ca8b6604d6ce14de('Ed25519SigVerify111111111111111111111111111');\nconst $c3af9e523501759a$var$ecdsaSign = (msgHash, privKey)=>{\n const signature = (0, $5r7db.secp256k1).sign(msgHash, privKey);\n return [\n signature.toCompactRawBytes(),\n signature.recovery\n ];\n};\n(0, $5r7db.secp256k1).utils.isValidPrivateKey;\nconst $c3af9e523501759a$var$publicKeyCreate = (0, $5r7db.secp256k1).getPublicKey;\nconst $c3af9e523501759a$var$PRIVATE_KEY_BYTES = 32;\nconst $c3af9e523501759a$var$ETHEREUM_ADDRESS_BYTES = 20;\nconst $c3af9e523501759a$var$PUBLIC_KEY_BYTES = 64;\nconst $c3af9e523501759a$var$SIGNATURE_OFFSETS_SERIALIZED_SIZE = 11;\n/**\n * Params for creating an secp256k1 instruction using a public key\n */ /**\n * Params for creating an secp256k1 instruction using an Ethereum address\n */ /**\n * Params for creating an secp256k1 instruction using a private key\n */ const $c3af9e523501759a$var$SECP256K1_INSTRUCTION_LAYOUT = $Q02IV.struct([\n $Q02IV.u8('numSignatures'),\n $Q02IV.u16('signatureOffset'),\n $Q02IV.u8('signatureInstructionIndex'),\n $Q02IV.u16('ethAddressOffset'),\n $Q02IV.u8('ethAddressInstructionIndex'),\n $Q02IV.u16('messageDataOffset'),\n $Q02IV.u16('messageDataSize'),\n $Q02IV.u8('messageInstructionIndex'),\n $Q02IV.blob(20, 'ethAddress'),\n $Q02IV.blob(64, 'signature'),\n $Q02IV.u8('recoveryId')\n]);\nclass $c3af9e523501759a$export$d85dd4c1161d13c9 {\n /**\n * @internal\n */ constructor(){}\n /**\n * Public key that identifies the secp256k1 program\n */ /**\n * Construct an Ethereum address from a secp256k1 public key buffer.\n * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer\n */ static publicKeyToEthAddress(publicKey) {\n $c3af9e523501759a$var$assert(publicKey.length === $c3af9e523501759a$var$PUBLIC_KEY_BYTES, `Public key must be ${$c3af9e523501759a$var$PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);\n try {\n return (0, $6ZWSX.Buffer).from((0, $J0sDk.keccak_256)($c3af9e523501759a$var$toBuffer(publicKey))).slice(-$c3af9e523501759a$var$ETHEREUM_ADDRESS_BYTES);\n } catch (error) {\n throw new Error(`Error constructing Ethereum address: ${error}`);\n }\n }\n /**\n * Create an secp256k1 instruction with a public key. The public key\n * must be a buffer that is 64 bytes long.\n */ static createInstructionWithPublicKey(params) {\n const { publicKey: publicKey, message: message, signature: signature, recoveryId: recoveryId, instructionIndex: instructionIndex } = params;\n return $c3af9e523501759a$export$d85dd4c1161d13c9.createInstructionWithEthAddress({\n ethAddress: $c3af9e523501759a$export$d85dd4c1161d13c9.publicKeyToEthAddress(publicKey),\n message: message,\n signature: signature,\n recoveryId: recoveryId,\n instructionIndex: instructionIndex\n });\n }\n /**\n * Create an secp256k1 instruction with an Ethereum address. The address\n * must be a hex string or a buffer that is 20 bytes long.\n */ static createInstructionWithEthAddress(params) {\n const { ethAddress: rawAddress, message: message, signature: signature, recoveryId: recoveryId, instructionIndex: instructionIndex = 0 } = params;\n let ethAddress;\n if (typeof rawAddress === 'string') {\n if (rawAddress.startsWith('0x')) ethAddress = (0, $6ZWSX.Buffer).from(rawAddress.substr(2), 'hex');\n else ethAddress = (0, $6ZWSX.Buffer).from(rawAddress, 'hex');\n } else ethAddress = rawAddress;\n $c3af9e523501759a$var$assert(ethAddress.length === $c3af9e523501759a$var$ETHEREUM_ADDRESS_BYTES, `Address must be ${$c3af9e523501759a$var$ETHEREUM_ADDRESS_BYTES} bytes but received ${ethAddress.length} bytes`);\n const dataStart = 1 + $c3af9e523501759a$var$SIGNATURE_OFFSETS_SERIALIZED_SIZE;\n const ethAddressOffset = dataStart;\n const signatureOffset = dataStart + ethAddress.length;\n const messageDataOffset = signatureOffset + signature.length + 1;\n const numSignatures = 1;\n const instructionData = (0, $6ZWSX.Buffer).alloc($c3af9e523501759a$var$SECP256K1_INSTRUCTION_LAYOUT.span + message.length);\n $c3af9e523501759a$var$SECP256K1_INSTRUCTION_LAYOUT.encode({\n numSignatures: numSignatures,\n signatureOffset: signatureOffset,\n signatureInstructionIndex: instructionIndex,\n ethAddressOffset: ethAddressOffset,\n ethAddressInstructionIndex: instructionIndex,\n messageDataOffset: messageDataOffset,\n messageDataSize: message.length,\n messageInstructionIndex: instructionIndex,\n signature: $c3af9e523501759a$var$toBuffer(signature),\n ethAddress: $c3af9e523501759a$var$toBuffer(ethAddress),\n recoveryId: recoveryId\n }, instructionData);\n instructionData.fill($c3af9e523501759a$var$toBuffer(message), $c3af9e523501759a$var$SECP256K1_INSTRUCTION_LAYOUT.span);\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n keys: [],\n programId: $c3af9e523501759a$export$d85dd4c1161d13c9.programId,\n data: instructionData\n });\n }\n /**\n * Create an secp256k1 instruction with a private key. The private key\n * must be a buffer that is 32 bytes long.\n */ static createInstructionWithPrivateKey(params) {\n const { privateKey: pkey, message: message, instructionIndex: instructionIndex } = params;\n $c3af9e523501759a$var$assert(pkey.length === $c3af9e523501759a$var$PRIVATE_KEY_BYTES, `Private key must be ${$c3af9e523501759a$var$PRIVATE_KEY_BYTES} bytes but received ${pkey.length} bytes`);\n try {\n const privateKey = $c3af9e523501759a$var$toBuffer(pkey);\n const publicKey = $c3af9e523501759a$var$publicKeyCreate(privateKey, false).slice(1); // throw away leading byte\n const messageHash = (0, $6ZWSX.Buffer).from((0, $J0sDk.keccak_256)($c3af9e523501759a$var$toBuffer(message)));\n const [signature, recoveryId] = $c3af9e523501759a$var$ecdsaSign(messageHash, privateKey);\n return this.createInstructionWithPublicKey({\n publicKey: publicKey,\n message: message,\n signature: signature,\n recoveryId: recoveryId,\n instructionIndex: instructionIndex\n });\n } catch (error) {\n throw new Error(`Error creating instruction; ${error}`);\n }\n }\n}\n$c3af9e523501759a$export$d85dd4c1161d13c9.programId = new $c3af9e523501759a$export$ca8b6604d6ce14de('KeccakSecp256k11111111111111111111111111111');\nvar $c3af9e523501759a$var$_Lockup;\n/**\n * Address of the stake config account which configures the rate\n * of stake warmup and cooldown as well as the slashing penalty.\n */ const $c3af9e523501759a$export$18aac71979bdd08f = new $c3af9e523501759a$export$ca8b6604d6ce14de('StakeConfig11111111111111111111111111111111');\n/**\n * Stake account authority info\n */ class $c3af9e523501759a$export$9ac74ae66932a145 {\n /**\n * Create a new Authorized object\n * @param staker the stake authority\n * @param withdrawer the withdraw authority\n */ constructor(staker, withdrawer){\n /** stake authority */ this.staker = void 0;\n /** withdraw authority */ this.withdrawer = void 0;\n this.staker = staker;\n this.withdrawer = withdrawer;\n }\n}\n/**\n * Stake account lockup info\n */ class $c3af9e523501759a$export$e7f3941ade35598c {\n /**\n * Create a new Lockup object\n */ constructor(unixTimestamp, epoch, custodian){\n /** Unix timestamp of lockup expiration */ this.unixTimestamp = void 0;\n /** Epoch of lockup expiration */ this.epoch = void 0;\n /** Lockup custodian authority */ this.custodian = void 0;\n this.unixTimestamp = unixTimestamp;\n this.epoch = epoch;\n this.custodian = custodian;\n }\n}\n$c3af9e523501759a$var$_Lockup = $c3af9e523501759a$export$e7f3941ade35598c;\n$c3af9e523501759a$export$e7f3941ade35598c.default = new $c3af9e523501759a$var$_Lockup(0, 0, $c3af9e523501759a$export$ca8b6604d6ce14de.default);\n/**\n * Create stake account transaction params\n */ /**\n * Create stake account with seed transaction params\n */ /**\n * Initialize stake instruction params\n */ /**\n * Delegate stake instruction params\n */ /**\n * Authorize stake instruction params\n */ /**\n * Authorize stake instruction params using a derived key\n */ /**\n * Split stake instruction params\n */ /**\n * Split with seed transaction params\n */ /**\n * Withdraw stake instruction params\n */ /**\n * Deactivate stake instruction params\n */ /**\n * Merge stake instruction params\n */ /**\n * Stake Instruction class\n */ class $c3af9e523501759a$export$aded313c3a4800f9 {\n /**\n * @internal\n */ constructor(){}\n /**\n * Decode a stake instruction and retrieve the instruction type.\n */ static decodeInstructionType(instruction) {\n this.checkProgramId(instruction.programId);\n const instructionTypeLayout = $Q02IV.u32('instruction');\n const typeIndex = instructionTypeLayout.decode(instruction.data);\n let type;\n for (const [ixType, layout] of Object.entries($c3af9e523501759a$export$c89793bd2bba8b2e))if (layout.index == typeIndex) {\n type = ixType;\n break;\n }\n if (!type) throw new Error('Instruction type incorrect; not a StakeInstruction');\n return type;\n }\n /**\n * Decode a initialize stake instruction and retrieve the instruction params.\n */ static decodeInitialize(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n const { authorized: authorized, lockup: lockup } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$c89793bd2bba8b2e.Initialize, instruction.data);\n return {\n stakePubkey: instruction.keys[0].pubkey,\n authorized: new $c3af9e523501759a$export$9ac74ae66932a145(new $c3af9e523501759a$export$ca8b6604d6ce14de(authorized.staker), new $c3af9e523501759a$export$ca8b6604d6ce14de(authorized.withdrawer)),\n lockup: new $c3af9e523501759a$export$e7f3941ade35598c(lockup.unixTimestamp, lockup.epoch, new $c3af9e523501759a$export$ca8b6604d6ce14de(lockup.custodian))\n };\n }\n /**\n * Decode a delegate stake instruction and retrieve the instruction params.\n */ static decodeDelegate(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 6);\n $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$c89793bd2bba8b2e.Delegate, instruction.data);\n return {\n stakePubkey: instruction.keys[0].pubkey,\n votePubkey: instruction.keys[1].pubkey,\n authorizedPubkey: instruction.keys[5].pubkey\n };\n }\n /**\n * Decode an authorize stake instruction and retrieve the instruction params.\n */ static decodeAuthorize(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const { newAuthorized: newAuthorized, stakeAuthorizationType: stakeAuthorizationType } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$c89793bd2bba8b2e.Authorize, instruction.data);\n const o = {\n stakePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: instruction.keys[2].pubkey,\n newAuthorizedPubkey: new $c3af9e523501759a$export$ca8b6604d6ce14de(newAuthorized),\n stakeAuthorizationType: {\n index: stakeAuthorizationType\n }\n };\n if (instruction.keys.length > 3) o.custodianPubkey = instruction.keys[3].pubkey;\n return o;\n }\n /**\n * Decode an authorize-with-seed stake instruction and retrieve the instruction params.\n */ static decodeAuthorizeWithSeed(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n const { newAuthorized: newAuthorized, stakeAuthorizationType: stakeAuthorizationType, authoritySeed: authoritySeed, authorityOwner: authorityOwner } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$c89793bd2bba8b2e.AuthorizeWithSeed, instruction.data);\n const o = {\n stakePubkey: instruction.keys[0].pubkey,\n authorityBase: instruction.keys[1].pubkey,\n authoritySeed: authoritySeed,\n authorityOwner: new $c3af9e523501759a$export$ca8b6604d6ce14de(authorityOwner),\n newAuthorizedPubkey: new $c3af9e523501759a$export$ca8b6604d6ce14de(newAuthorized),\n stakeAuthorizationType: {\n index: stakeAuthorizationType\n }\n };\n if (instruction.keys.length > 3) o.custodianPubkey = instruction.keys[3].pubkey;\n return o;\n }\n /**\n * Decode a split stake instruction and retrieve the instruction params.\n */ static decodeSplit(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const { lamports: lamports } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$c89793bd2bba8b2e.Split, instruction.data);\n return {\n stakePubkey: instruction.keys[0].pubkey,\n splitStakePubkey: instruction.keys[1].pubkey,\n authorizedPubkey: instruction.keys[2].pubkey,\n lamports: lamports\n };\n }\n /**\n * Decode a merge stake instruction and retrieve the instruction params.\n */ static decodeMerge(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$c89793bd2bba8b2e.Merge, instruction.data);\n return {\n stakePubkey: instruction.keys[0].pubkey,\n sourceStakePubKey: instruction.keys[1].pubkey,\n authorizedPubkey: instruction.keys[4].pubkey\n };\n }\n /**\n * Decode a withdraw stake instruction and retrieve the instruction params.\n */ static decodeWithdraw(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 5);\n const { lamports: lamports } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$c89793bd2bba8b2e.Withdraw, instruction.data);\n const o = {\n stakePubkey: instruction.keys[0].pubkey,\n toPubkey: instruction.keys[1].pubkey,\n authorizedPubkey: instruction.keys[4].pubkey,\n lamports: lamports\n };\n if (instruction.keys.length > 5) o.custodianPubkey = instruction.keys[5].pubkey;\n return o;\n }\n /**\n * Decode a deactivate stake instruction and retrieve the instruction params.\n */ static decodeDeactivate(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$export$c89793bd2bba8b2e.Deactivate, instruction.data);\n return {\n stakePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: instruction.keys[2].pubkey\n };\n }\n /**\n * @internal\n */ static checkProgramId(programId) {\n if (!programId.equals($c3af9e523501759a$export$df86f933e9f8fb15.programId)) throw new Error('invalid instruction; programId is not StakeProgram');\n }\n /**\n * @internal\n */ static checkKeyLength(keys, expectedLength) {\n if (keys.length < expectedLength) throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);\n }\n}\n/**\n * An enumeration of valid StakeInstructionType's\n */ /**\n * An enumeration of valid stake InstructionType's\n * @internal\n */ const $c3af9e523501759a$export$c89793bd2bba8b2e = Object.freeze({\n Initialize: {\n index: 0,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$authorized(),\n $c3af9e523501759a$var$lockup()\n ])\n },\n Authorize: {\n index: 1,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$publicKey('newAuthorized'),\n $Q02IV.u32('stakeAuthorizationType')\n ])\n },\n Delegate: {\n index: 2,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction')\n ])\n },\n Split: {\n index: 3,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $Q02IV.ns64('lamports')\n ])\n },\n Withdraw: {\n index: 4,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $Q02IV.ns64('lamports')\n ])\n },\n Deactivate: {\n index: 5,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction')\n ])\n },\n Merge: {\n index: 7,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction')\n ])\n },\n AuthorizeWithSeed: {\n index: 8,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$publicKey('newAuthorized'),\n $Q02IV.u32('stakeAuthorizationType'),\n $c3af9e523501759a$var$rustString('authoritySeed'),\n $c3af9e523501759a$var$publicKey('authorityOwner')\n ])\n }\n});\n/**\n * Stake authorization type\n */ /**\n * An enumeration of valid StakeAuthorizationLayout's\n */ const $c3af9e523501759a$export$4783920eadd34361 = Object.freeze({\n Staker: {\n index: 0\n },\n Withdrawer: {\n index: 1\n }\n});\n/**\n * Factory class for transactions to interact with the Stake program\n */ class $c3af9e523501759a$export$df86f933e9f8fb15 {\n /**\n * @internal\n */ constructor(){}\n /**\n * Public key that identifies the Stake program\n */ /**\n * Generate an Initialize instruction to add to a Stake Create transaction\n */ static initialize(params) {\n const { stakePubkey: stakePubkey, authorized: authorized, lockup: maybeLockup } = params;\n const lockup = maybeLockup || $c3af9e523501759a$export$e7f3941ade35598c.default;\n const type = $c3af9e523501759a$export$c89793bd2bba8b2e.Initialize;\n const data = $c3af9e523501759a$var$encodeData(type, {\n authorized: {\n staker: $c3af9e523501759a$var$toBuffer(authorized.staker.toBuffer()),\n withdrawer: $c3af9e523501759a$var$toBuffer(authorized.withdrawer.toBuffer())\n },\n lockup: {\n unixTimestamp: lockup.unixTimestamp,\n epoch: lockup.epoch,\n custodian: $c3af9e523501759a$var$toBuffer(lockup.custodian.toBuffer())\n }\n });\n const instructionData = {\n keys: [\n {\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: $c3af9e523501759a$export$970d0190cdb3a8e9,\n isSigner: false,\n isWritable: false\n }\n ],\n programId: this.programId,\n data: data\n };\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59(instructionData);\n }\n /**\n * Generate a Transaction that creates a new Stake account at\n * an address generated with `from`, a seed, and the Stake programId\n */ static createAccountWithSeed(params) {\n const transaction = new $c3af9e523501759a$export$febc5573c75cefb0();\n transaction.add($c3af9e523501759a$export$d8c4e17726848113.createAccountWithSeed({\n fromPubkey: params.fromPubkey,\n newAccountPubkey: params.stakePubkey,\n basePubkey: params.basePubkey,\n seed: params.seed,\n lamports: params.lamports,\n space: this.space,\n programId: this.programId\n }));\n const { stakePubkey: stakePubkey, authorized: authorized, lockup: lockup } = params;\n return transaction.add(this.initialize({\n stakePubkey: stakePubkey,\n authorized: authorized,\n lockup: lockup\n }));\n }\n /**\n * Generate a Transaction that creates a new Stake account\n */ static createAccount(params) {\n const transaction = new $c3af9e523501759a$export$febc5573c75cefb0();\n transaction.add($c3af9e523501759a$export$d8c4e17726848113.createAccount({\n fromPubkey: params.fromPubkey,\n newAccountPubkey: params.stakePubkey,\n lamports: params.lamports,\n space: this.space,\n programId: this.programId\n }));\n const { stakePubkey: stakePubkey, authorized: authorized, lockup: lockup } = params;\n return transaction.add(this.initialize({\n stakePubkey: stakePubkey,\n authorized: authorized,\n lockup: lockup\n }));\n }\n /**\n * Generate a Transaction that delegates Stake tokens to a validator\n * Vote PublicKey. This transaction can also be used to redelegate Stake\n * to a new validator Vote PublicKey.\n */ static delegate(params) {\n const { stakePubkey: stakePubkey, authorizedPubkey: authorizedPubkey, votePubkey: votePubkey } = params;\n const type = $c3af9e523501759a$export$c89793bd2bba8b2e.Delegate;\n const data = $c3af9e523501759a$var$encodeData(type);\n return new $c3af9e523501759a$export$febc5573c75cefb0().add({\n keys: [\n {\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: votePubkey,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: $c3af9e523501759a$export$393aa1412d47050e,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: $c3af9e523501759a$export$ca994171317280ea,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: $c3af9e523501759a$export$18aac71979bdd08f,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: authorizedPubkey,\n isSigner: true,\n isWritable: false\n }\n ],\n programId: this.programId,\n data: data\n });\n }\n /**\n * Generate a Transaction that authorizes a new PublicKey as Staker\n * or Withdrawer on the Stake account.\n */ static authorize(params) {\n const { stakePubkey: stakePubkey, authorizedPubkey: authorizedPubkey, newAuthorizedPubkey: newAuthorizedPubkey, stakeAuthorizationType: stakeAuthorizationType, custodianPubkey: custodianPubkey } = params;\n const type = $c3af9e523501759a$export$c89793bd2bba8b2e.Authorize;\n const data = $c3af9e523501759a$var$encodeData(type, {\n newAuthorized: $c3af9e523501759a$var$toBuffer(newAuthorizedPubkey.toBuffer()),\n stakeAuthorizationType: stakeAuthorizationType.index\n });\n const keys = [\n {\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: $c3af9e523501759a$export$393aa1412d47050e,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: authorizedPubkey,\n isSigner: true,\n isWritable: false\n }\n ];\n if (custodianPubkey) keys.push({\n pubkey: custodianPubkey,\n isSigner: true,\n isWritable: false\n });\n return new $c3af9e523501759a$export$febc5573c75cefb0().add({\n keys: keys,\n programId: this.programId,\n data: data\n });\n }\n /**\n * Generate a Transaction that authorizes a new PublicKey as Staker\n * or Withdrawer on the Stake account.\n */ static authorizeWithSeed(params) {\n const { stakePubkey: stakePubkey, authorityBase: authorityBase, authoritySeed: authoritySeed, authorityOwner: authorityOwner, newAuthorizedPubkey: newAuthorizedPubkey, stakeAuthorizationType: stakeAuthorizationType, custodianPubkey: custodianPubkey } = params;\n const type = $c3af9e523501759a$export$c89793bd2bba8b2e.AuthorizeWithSeed;\n const data = $c3af9e523501759a$var$encodeData(type, {\n newAuthorized: $c3af9e523501759a$var$toBuffer(newAuthorizedPubkey.toBuffer()),\n stakeAuthorizationType: stakeAuthorizationType.index,\n authoritySeed: authoritySeed,\n authorityOwner: $c3af9e523501759a$var$toBuffer(authorityOwner.toBuffer())\n });\n const keys = [\n {\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: authorityBase,\n isSigner: true,\n isWritable: false\n },\n {\n pubkey: $c3af9e523501759a$export$393aa1412d47050e,\n isSigner: false,\n isWritable: false\n }\n ];\n if (custodianPubkey) keys.push({\n pubkey: custodianPubkey,\n isSigner: true,\n isWritable: false\n });\n return new $c3af9e523501759a$export$febc5573c75cefb0().add({\n keys: keys,\n programId: this.programId,\n data: data\n });\n }\n /**\n * @internal\n */ static splitInstruction(params) {\n const { stakePubkey: stakePubkey, authorizedPubkey: authorizedPubkey, splitStakePubkey: splitStakePubkey, lamports: lamports } = params;\n const type = $c3af9e523501759a$export$c89793bd2bba8b2e.Split;\n const data = $c3af9e523501759a$var$encodeData(type, {\n lamports: lamports\n });\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59({\n keys: [\n {\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: splitStakePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: authorizedPubkey,\n isSigner: true,\n isWritable: false\n }\n ],\n programId: this.programId,\n data: data\n });\n }\n /**\n * Generate a Transaction that splits Stake tokens into another stake account\n */ static split(params, // Compute the cost of allocating the new stake account in lamports\n rentExemptReserve) {\n const transaction = new $c3af9e523501759a$export$febc5573c75cefb0();\n transaction.add($c3af9e523501759a$export$d8c4e17726848113.createAccount({\n fromPubkey: params.authorizedPubkey,\n newAccountPubkey: params.splitStakePubkey,\n lamports: rentExemptReserve,\n space: this.space,\n programId: this.programId\n }));\n return transaction.add(this.splitInstruction(params));\n }\n /**\n * Generate a Transaction that splits Stake tokens into another account\n * derived from a base public key and seed\n */ static splitWithSeed(params, // If this stake account is new, compute the cost of allocating it in lamports\n rentExemptReserve) {\n const { stakePubkey: stakePubkey, authorizedPubkey: authorizedPubkey, splitStakePubkey: splitStakePubkey, basePubkey: basePubkey, seed: seed, lamports: lamports } = params;\n const transaction = new $c3af9e523501759a$export$febc5573c75cefb0();\n transaction.add($c3af9e523501759a$export$d8c4e17726848113.allocate({\n accountPubkey: splitStakePubkey,\n basePubkey: basePubkey,\n seed: seed,\n space: this.space,\n programId: this.programId\n }));\n if (rentExemptReserve && rentExemptReserve > 0) transaction.add($c3af9e523501759a$export$d8c4e17726848113.transfer({\n fromPubkey: params.authorizedPubkey,\n toPubkey: splitStakePubkey,\n lamports: rentExemptReserve\n }));\n return transaction.add(this.splitInstruction({\n stakePubkey: stakePubkey,\n authorizedPubkey: authorizedPubkey,\n splitStakePubkey: splitStakePubkey,\n lamports: lamports\n }));\n }\n /**\n * Generate a Transaction that merges Stake accounts.\n */ static merge(params) {\n const { stakePubkey: stakePubkey, sourceStakePubKey: sourceStakePubKey, authorizedPubkey: authorizedPubkey } = params;\n const type = $c3af9e523501759a$export$c89793bd2bba8b2e.Merge;\n const data = $c3af9e523501759a$var$encodeData(type);\n return new $c3af9e523501759a$export$febc5573c75cefb0().add({\n keys: [\n {\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: sourceStakePubKey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: $c3af9e523501759a$export$393aa1412d47050e,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: $c3af9e523501759a$export$ca994171317280ea,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: authorizedPubkey,\n isSigner: true,\n isWritable: false\n }\n ],\n programId: this.programId,\n data: data\n });\n }\n /**\n * Generate a Transaction that withdraws deactivated Stake tokens.\n */ static withdraw(params) {\n const { stakePubkey: stakePubkey, authorizedPubkey: authorizedPubkey, toPubkey: toPubkey, lamports: lamports, custodianPubkey: custodianPubkey } = params;\n const type = $c3af9e523501759a$export$c89793bd2bba8b2e.Withdraw;\n const data = $c3af9e523501759a$var$encodeData(type, {\n lamports: lamports\n });\n const keys = [\n {\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: toPubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: $c3af9e523501759a$export$393aa1412d47050e,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: $c3af9e523501759a$export$ca994171317280ea,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: authorizedPubkey,\n isSigner: true,\n isWritable: false\n }\n ];\n if (custodianPubkey) keys.push({\n pubkey: custodianPubkey,\n isSigner: true,\n isWritable: false\n });\n return new $c3af9e523501759a$export$febc5573c75cefb0().add({\n keys: keys,\n programId: this.programId,\n data: data\n });\n }\n /**\n * Generate a Transaction that deactivates Stake tokens.\n */ static deactivate(params) {\n const { stakePubkey: stakePubkey, authorizedPubkey: authorizedPubkey } = params;\n const type = $c3af9e523501759a$export$c89793bd2bba8b2e.Deactivate;\n const data = $c3af9e523501759a$var$encodeData(type);\n return new $c3af9e523501759a$export$febc5573c75cefb0().add({\n keys: [\n {\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: $c3af9e523501759a$export$393aa1412d47050e,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: authorizedPubkey,\n isSigner: true,\n isWritable: false\n }\n ],\n programId: this.programId,\n data: data\n });\n }\n}\n$c3af9e523501759a$export$df86f933e9f8fb15.programId = new $c3af9e523501759a$export$ca8b6604d6ce14de('Stake11111111111111111111111111111111111111');\n/**\n * Max space of a Stake account\n *\n * This is generated from the solana-stake-program StakeState struct as\n * `StakeStateV2::size_of()`:\n * https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeStateV2.html\n */ $c3af9e523501759a$export$df86f933e9f8fb15.space = 200;\n/**\n * Vote account info\n */ class $c3af9e523501759a$export$3f9d1b16ff840d7 {\n /** [0, 100] */ constructor(nodePubkey, authorizedVoter, authorizedWithdrawer, commission){\n this.nodePubkey = void 0;\n this.authorizedVoter = void 0;\n this.authorizedWithdrawer = void 0;\n this.commission = void 0;\n this.nodePubkey = nodePubkey;\n this.authorizedVoter = authorizedVoter;\n this.authorizedWithdrawer = authorizedWithdrawer;\n this.commission = commission;\n }\n}\n/**\n * Create vote account transaction params\n */ /**\n * InitializeAccount instruction params\n */ /**\n * Authorize instruction params\n */ /**\n * AuthorizeWithSeed instruction params\n */ /**\n * Withdraw from vote account transaction params\n */ /**\n * Update validator identity (node pubkey) vote account instruction params.\n */ /**\n * Vote Instruction class\n */ class $c3af9e523501759a$export$af8300401fc56047 {\n /**\n * @internal\n */ constructor(){}\n /**\n * Decode a vote instruction and retrieve the instruction type.\n */ static decodeInstructionType(instruction) {\n this.checkProgramId(instruction.programId);\n const instructionTypeLayout = $Q02IV.u32('instruction');\n const typeIndex = instructionTypeLayout.decode(instruction.data);\n let type;\n for (const [ixType, layout] of Object.entries($c3af9e523501759a$var$VOTE_INSTRUCTION_LAYOUTS))if (layout.index == typeIndex) {\n type = ixType;\n break;\n }\n if (!type) throw new Error('Instruction type incorrect; not a VoteInstruction');\n return type;\n }\n /**\n * Decode an initialize vote instruction and retrieve the instruction params.\n */ static decodeInitializeAccount(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 4);\n const { voteInit: voteInit } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$var$VOTE_INSTRUCTION_LAYOUTS.InitializeAccount, instruction.data);\n return {\n votePubkey: instruction.keys[0].pubkey,\n nodePubkey: instruction.keys[3].pubkey,\n voteInit: new $c3af9e523501759a$export$3f9d1b16ff840d7(new $c3af9e523501759a$export$ca8b6604d6ce14de(voteInit.nodePubkey), new $c3af9e523501759a$export$ca8b6604d6ce14de(voteInit.authorizedVoter), new $c3af9e523501759a$export$ca8b6604d6ce14de(voteInit.authorizedWithdrawer), voteInit.commission)\n };\n }\n /**\n * Decode an authorize instruction and retrieve the instruction params.\n */ static decodeAuthorize(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const { newAuthorized: newAuthorized, voteAuthorizationType: voteAuthorizationType } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$var$VOTE_INSTRUCTION_LAYOUTS.Authorize, instruction.data);\n return {\n votePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: instruction.keys[2].pubkey,\n newAuthorizedPubkey: new $c3af9e523501759a$export$ca8b6604d6ce14de(newAuthorized),\n voteAuthorizationType: {\n index: voteAuthorizationType\n }\n };\n }\n /**\n * Decode an authorize instruction and retrieve the instruction params.\n */ static decodeAuthorizeWithSeed(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const { voteAuthorizeWithSeedArgs: { currentAuthorityDerivedKeyOwnerPubkey: currentAuthorityDerivedKeyOwnerPubkey, currentAuthorityDerivedKeySeed: currentAuthorityDerivedKeySeed, newAuthorized: newAuthorized, voteAuthorizationType: voteAuthorizationType } } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$var$VOTE_INSTRUCTION_LAYOUTS.AuthorizeWithSeed, instruction.data);\n return {\n currentAuthorityDerivedKeyBasePubkey: instruction.keys[2].pubkey,\n currentAuthorityDerivedKeyOwnerPubkey: new $c3af9e523501759a$export$ca8b6604d6ce14de(currentAuthorityDerivedKeyOwnerPubkey),\n currentAuthorityDerivedKeySeed: currentAuthorityDerivedKeySeed,\n newAuthorizedPubkey: new $c3af9e523501759a$export$ca8b6604d6ce14de(newAuthorized),\n voteAuthorizationType: {\n index: voteAuthorizationType\n },\n votePubkey: instruction.keys[0].pubkey\n };\n }\n /**\n * Decode a withdraw instruction and retrieve the instruction params.\n */ static decodeWithdraw(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const { lamports: lamports } = $c3af9e523501759a$var$decodeData$1($c3af9e523501759a$var$VOTE_INSTRUCTION_LAYOUTS.Withdraw, instruction.data);\n return {\n votePubkey: instruction.keys[0].pubkey,\n authorizedWithdrawerPubkey: instruction.keys[2].pubkey,\n lamports: lamports,\n toPubkey: instruction.keys[1].pubkey\n };\n }\n /**\n * @internal\n */ static checkProgramId(programId) {\n if (!programId.equals($c3af9e523501759a$export$83db2bc702bee1eb.programId)) throw new Error('invalid instruction; programId is not VoteProgram');\n }\n /**\n * @internal\n */ static checkKeyLength(keys, expectedLength) {\n if (keys.length < expectedLength) throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);\n }\n}\n/**\n * An enumeration of valid VoteInstructionType's\n */ /** @internal */ const $c3af9e523501759a$var$VOTE_INSTRUCTION_LAYOUTS = Object.freeze({\n InitializeAccount: {\n index: 0,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$voteInit()\n ])\n },\n Authorize: {\n index: 1,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$publicKey('newAuthorized'),\n $Q02IV.u32('voteAuthorizationType')\n ])\n },\n Withdraw: {\n index: 3,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $Q02IV.ns64('lamports')\n ])\n },\n UpdateValidatorIdentity: {\n index: 4,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction')\n ])\n },\n AuthorizeWithSeed: {\n index: 10,\n layout: $Q02IV.struct([\n $Q02IV.u32('instruction'),\n $c3af9e523501759a$var$voteAuthorizeWithSeedArgs()\n ])\n }\n});\n/**\n * VoteAuthorize type\n */ /**\n * An enumeration of valid VoteAuthorization layouts.\n */ const $c3af9e523501759a$export$3f2a92246fa9f71c = Object.freeze({\n Voter: {\n index: 0\n },\n Withdrawer: {\n index: 1\n }\n});\n/**\n * Factory class for transactions to interact with the Vote program\n */ class $c3af9e523501759a$export$83db2bc702bee1eb {\n /**\n * @internal\n */ constructor(){}\n /**\n * Public key that identifies the Vote program\n */ /**\n * Generate an Initialize instruction.\n */ static initializeAccount(params) {\n const { votePubkey: votePubkey, nodePubkey: nodePubkey, voteInit: voteInit } = params;\n const type = $c3af9e523501759a$var$VOTE_INSTRUCTION_LAYOUTS.InitializeAccount;\n const data = $c3af9e523501759a$var$encodeData(type, {\n voteInit: {\n nodePubkey: $c3af9e523501759a$var$toBuffer(voteInit.nodePubkey.toBuffer()),\n authorizedVoter: $c3af9e523501759a$var$toBuffer(voteInit.authorizedVoter.toBuffer()),\n authorizedWithdrawer: $c3af9e523501759a$var$toBuffer(voteInit.authorizedWithdrawer.toBuffer()),\n commission: voteInit.commission\n }\n });\n const instructionData = {\n keys: [\n {\n pubkey: votePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: $c3af9e523501759a$export$970d0190cdb3a8e9,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: $c3af9e523501759a$export$393aa1412d47050e,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: nodePubkey,\n isSigner: true,\n isWritable: false\n }\n ],\n programId: this.programId,\n data: data\n };\n return new $c3af9e523501759a$export$a7a3aa8360ac9f59(instructionData);\n }\n /**\n * Generate a transaction that creates a new Vote account.\n */ static createAccount(params) {\n const transaction = new $c3af9e523501759a$export$febc5573c75cefb0();\n transaction.add($c3af9e523501759a$export$d8c4e17726848113.createAccount({\n fromPubkey: params.fromPubkey,\n newAccountPubkey: params.votePubkey,\n lamports: params.lamports,\n space: this.space,\n programId: this.programId\n }));\n return transaction.add(this.initializeAccount({\n votePubkey: params.votePubkey,\n nodePubkey: params.voteInit.nodePubkey,\n voteInit: params.voteInit\n }));\n }\n /**\n * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account.\n */ static authorize(params) {\n const { votePubkey: votePubkey, authorizedPubkey: authorizedPubkey, newAuthorizedPubkey: newAuthorizedPubkey, voteAuthorizationType: voteAuthorizationType } = params;\n const type = $c3af9e523501759a$var$VOTE_INSTRUCTION_LAYOUTS.Authorize;\n const data = $c3af9e523501759a$var$encodeData(type, {\n newAuthorized: $c3af9e523501759a$var$toBuffer(newAuthorizedPubkey.toBuffer()),\n voteAuthorizationType: voteAuthorizationType.index\n });\n const keys = [\n {\n pubkey: votePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: $c3af9e523501759a$export$393aa1412d47050e,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: authorizedPubkey,\n isSigner: true,\n isWritable: false\n }\n ];\n return new $c3af9e523501759a$export$febc5573c75cefb0().add({\n keys: keys,\n programId: this.programId,\n data: data\n });\n }\n /**\n * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account\n * where the current Voter or Withdrawer authority is a derived key.\n */ static authorizeWithSeed(params) {\n const { currentAuthorityDerivedKeyBasePubkey: currentAuthorityDerivedKeyBasePubkey, currentAuthorityDerivedKeyOwnerPubkey: currentAuthorityDerivedKeyOwnerPubkey, currentAuthorityDerivedKeySeed: currentAuthorityDerivedKeySeed, newAuthorizedPubkey: newAuthorizedPubkey, voteAuthorizationType: voteAuthorizationType, votePubkey: votePubkey } = params;\n const type = $c3af9e523501759a$var$VOTE_INSTRUCTION_LAYOUTS.AuthorizeWithSeed;\n const data = $c3af9e523501759a$var$encodeData(type, {\n voteAuthorizeWithSeedArgs: {\n currentAuthorityDerivedKeyOwnerPubkey: $c3af9e523501759a$var$toBuffer(currentAuthorityDerivedKeyOwnerPubkey.toBuffer()),\n currentAuthorityDerivedKeySeed: currentAuthorityDerivedKeySeed,\n newAuthorized: $c3af9e523501759a$var$toBuffer(newAuthorizedPubkey.toBuffer()),\n voteAuthorizationType: voteAuthorizationType.index\n }\n });\n const keys = [\n {\n pubkey: votePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: $c3af9e523501759a$export$393aa1412d47050e,\n isSigner: false,\n isWritable: false\n },\n {\n pubkey: currentAuthorityDerivedKeyBasePubkey,\n isSigner: true,\n isWritable: false\n }\n ];\n return new $c3af9e523501759a$export$febc5573c75cefb0().add({\n keys: keys,\n programId: this.programId,\n data: data\n });\n }\n /**\n * Generate a transaction to withdraw from a Vote account.\n */ static withdraw(params) {\n const { votePubkey: votePubkey, authorizedWithdrawerPubkey: authorizedWithdrawerPubkey, lamports: lamports, toPubkey: toPubkey } = params;\n const type = $c3af9e523501759a$var$VOTE_INSTRUCTION_LAYOUTS.Withdraw;\n const data = $c3af9e523501759a$var$encodeData(type, {\n lamports: lamports\n });\n const keys = [\n {\n pubkey: votePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: toPubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: authorizedWithdrawerPubkey,\n isSigner: true,\n isWritable: false\n }\n ];\n return new $c3af9e523501759a$export$febc5573c75cefb0().add({\n keys: keys,\n programId: this.programId,\n data: data\n });\n }\n /**\n * Generate a transaction to withdraw safely from a Vote account.\n *\n * This function was created as a safeguard for vote accounts running validators, `safeWithdraw`\n * checks that the withdraw amount will not exceed the specified balance while leaving enough left\n * to cover rent. If you wish to close the vote account by withdrawing the full amount, call the\n * `withdraw` method directly.\n */ static safeWithdraw(params, currentVoteAccountBalance, rentExemptMinimum) {\n if (params.lamports > currentVoteAccountBalance - rentExemptMinimum) throw new Error('Withdraw will leave vote account with insufficient funds.');\n return $c3af9e523501759a$export$83db2bc702bee1eb.withdraw(params);\n }\n /**\n * Generate a transaction to update the validator identity (node pubkey) of a Vote account.\n */ static updateValidatorIdentity(params) {\n const { votePubkey: votePubkey, authorizedWithdrawerPubkey: authorizedWithdrawerPubkey, nodePubkey: nodePubkey } = params;\n const type = $c3af9e523501759a$var$VOTE_INSTRUCTION_LAYOUTS.UpdateValidatorIdentity;\n const data = $c3af9e523501759a$var$encodeData(type);\n const keys = [\n {\n pubkey: votePubkey,\n isSigner: false,\n isWritable: true\n },\n {\n pubkey: nodePubkey,\n isSigner: true,\n isWritable: false\n },\n {\n pubkey: authorizedWithdrawerPubkey,\n isSigner: true,\n isWritable: false\n }\n ];\n return new $c3af9e523501759a$export$febc5573c75cefb0().add({\n keys: keys,\n programId: this.programId,\n data: data\n });\n }\n}\n$c3af9e523501759a$export$83db2bc702bee1eb.programId = new $c3af9e523501759a$export$ca8b6604d6ce14de('Vote111111111111111111111111111111111111111');\n/**\n * Max space of a Vote account\n *\n * This is generated from the solana-vote-program VoteState struct as\n * `VoteState::size_of()`:\n * https://docs.rs/solana-vote-program/1.9.5/solana_vote_program/vote_state/struct.VoteState.html#method.size_of\n *\n * KEEP IN SYNC WITH `VoteState::size_of()` in https://github.com/solana-labs/solana/blob/a474cb24b9238f5edcc982f65c0b37d4a1046f7e/sdk/program/src/vote/state/mod.rs#L340-L342\n */ $c3af9e523501759a$export$83db2bc702bee1eb.space = 3762;\nconst $c3af9e523501759a$export$afdb09d3afdde87c = new $c3af9e523501759a$export$ca8b6604d6ce14de('Va1idator1nfo111111111111111111111111111111');\n/**\n * @internal\n */ /**\n * Info used to identity validators.\n */ const $c3af9e523501759a$var$InfoString = (0, $5DqgT.type)({\n name: (0, $5DqgT.string)(),\n website: (0, $5DqgT.optional)((0, $5DqgT.string)()),\n details: (0, $5DqgT.optional)((0, $5DqgT.string)()),\n iconUrl: (0, $5DqgT.optional)((0, $5DqgT.string)()),\n keybaseUsername: (0, $5DqgT.optional)((0, $5DqgT.string)())\n});\n/**\n * ValidatorInfo class\n */ class $c3af9e523501759a$export$152d279cf067309b {\n /**\n * Construct a valid ValidatorInfo\n *\n * @param key validator public key\n * @param info validator information\n */ constructor(key, info){\n /**\n * validator public key\n */ this.key = void 0;\n /**\n * validator information\n */ this.info = void 0;\n this.key = key;\n this.info = info;\n }\n /**\n * Deserialize ValidatorInfo from the config account data. Exactly two config\n * keys are required in the data.\n *\n * @param buffer config account data\n * @return null if info was not found\n */ static fromConfigData(buffer) {\n let byteArray = [\n ...buffer\n ];\n const configKeyCount = $c3af9e523501759a$var$decodeLength(byteArray);\n if (configKeyCount !== 2) return null;\n const configKeys = [];\n for(let i = 0; i < 2; i++){\n const publicKey = new $c3af9e523501759a$export$ca8b6604d6ce14de($c3af9e523501759a$var$guardedSplice(byteArray, 0, $c3af9e523501759a$export$84fc0a248cc54343));\n const isSigner = $c3af9e523501759a$var$guardedShift(byteArray) === 1;\n configKeys.push({\n publicKey: publicKey,\n isSigner: isSigner\n });\n }\n if (configKeys[0].publicKey.equals($c3af9e523501759a$export$afdb09d3afdde87c)) {\n if (configKeys[1].isSigner) {\n const rawInfo = $c3af9e523501759a$var$rustString().decode((0, $6ZWSX.Buffer).from(byteArray));\n const info = JSON.parse(rawInfo);\n (0, $5DqgT.assert)(info, $c3af9e523501759a$var$InfoString);\n return new $c3af9e523501759a$export$152d279cf067309b(configKeys[1].publicKey, info);\n }\n }\n return null;\n }\n}\nconst $c3af9e523501759a$export$90bca02a3aea0768 = new $c3af9e523501759a$export$ca8b6604d6ce14de('Vote111111111111111111111111111111111111111');\n/**\n * History of how many credits earned by the end of each epoch\n */ /**\n * See https://github.com/solana-labs/solana/blob/8a12ed029cfa38d4a45400916c2463fb82bbec8c/programs/vote_api/src/vote_state.rs#L68-L88\n *\n * @internal\n */ const $c3af9e523501759a$var$VoteAccountLayout = $Q02IV.struct([\n $c3af9e523501759a$var$publicKey('nodePubkey'),\n $c3af9e523501759a$var$publicKey('authorizedWithdrawer'),\n $Q02IV.u8('commission'),\n $Q02IV.nu64(),\n // votes.length\n $Q02IV.seq($Q02IV.struct([\n $Q02IV.nu64('slot'),\n $Q02IV.u32('confirmationCount')\n ]), $Q02IV.offset($Q02IV.u32(), -8), 'votes'),\n $Q02IV.u8('rootSlotValid'),\n $Q02IV.nu64('rootSlot'),\n $Q02IV.nu64(),\n // authorizedVoters.length\n $Q02IV.seq($Q02IV.struct([\n $Q02IV.nu64('epoch'),\n $c3af9e523501759a$var$publicKey('authorizedVoter')\n ]), $Q02IV.offset($Q02IV.u32(), -8), 'authorizedVoters'),\n $Q02IV.struct([\n $Q02IV.seq($Q02IV.struct([\n $c3af9e523501759a$var$publicKey('authorizedPubkey'),\n $Q02IV.nu64('epochOfLastAuthorizedSwitch'),\n $Q02IV.nu64('targetEpoch')\n ]), 32, 'buf'),\n $Q02IV.nu64('idx'),\n $Q02IV.u8('isEmpty')\n ], 'priorVoters'),\n $Q02IV.nu64(),\n // epochCredits.length\n $Q02IV.seq($Q02IV.struct([\n $Q02IV.nu64('epoch'),\n $Q02IV.nu64('credits'),\n $Q02IV.nu64('prevCredits')\n ]), $Q02IV.offset($Q02IV.u32(), -8), 'epochCredits'),\n $Q02IV.struct([\n $Q02IV.nu64('slot'),\n $Q02IV.nu64('timestamp')\n ], 'lastTimestamp')\n]);\n/**\n * VoteAccount class\n */ class $c3af9e523501759a$export$89ef186f708d638b {\n /**\n * @internal\n */ constructor(args){\n this.nodePubkey = void 0;\n this.authorizedWithdrawer = void 0;\n this.commission = void 0;\n this.rootSlot = void 0;\n this.votes = void 0;\n this.authorizedVoters = void 0;\n this.priorVoters = void 0;\n this.epochCredits = void 0;\n this.lastTimestamp = void 0;\n this.nodePubkey = args.nodePubkey;\n this.authorizedWithdrawer = args.authorizedWithdrawer;\n this.commission = args.commission;\n this.rootSlot = args.rootSlot;\n this.votes = args.votes;\n this.authorizedVoters = args.authorizedVoters;\n this.priorVoters = args.priorVoters;\n this.epochCredits = args.epochCredits;\n this.lastTimestamp = args.lastTimestamp;\n }\n /**\n * Deserialize VoteAccount from the account data.\n *\n * @param buffer account data\n * @return VoteAccount\n */ static fromAccountData(buffer) {\n const versionOffset = 4;\n const va = $c3af9e523501759a$var$VoteAccountLayout.decode($c3af9e523501759a$var$toBuffer(buffer), versionOffset);\n let rootSlot = va.rootSlot;\n if (!va.rootSlotValid) rootSlot = null;\n return new $c3af9e523501759a$export$89ef186f708d638b({\n nodePubkey: new $c3af9e523501759a$export$ca8b6604d6ce14de(va.nodePubkey),\n authorizedWithdrawer: new $c3af9e523501759a$export$ca8b6604d6ce14de(va.authorizedWithdrawer),\n commission: va.commission,\n votes: va.votes,\n rootSlot: rootSlot,\n authorizedVoters: va.authorizedVoters.map($c3af9e523501759a$var$parseAuthorizedVoter),\n priorVoters: $c3af9e523501759a$var$getPriorVoters(va.priorVoters),\n epochCredits: va.epochCredits,\n lastTimestamp: va.lastTimestamp\n });\n }\n}\nfunction $c3af9e523501759a$var$parseAuthorizedVoter({ authorizedVoter: authorizedVoter, epoch: epoch }) {\n return {\n epoch: epoch,\n authorizedVoter: new $c3af9e523501759a$export$ca8b6604d6ce14de(authorizedVoter)\n };\n}\nfunction $c3af9e523501759a$var$parsePriorVoters({ authorizedPubkey: authorizedPubkey, epochOfLastAuthorizedSwitch: epochOfLastAuthorizedSwitch, targetEpoch: targetEpoch }) {\n return {\n authorizedPubkey: new $c3af9e523501759a$export$ca8b6604d6ce14de(authorizedPubkey),\n epochOfLastAuthorizedSwitch: epochOfLastAuthorizedSwitch,\n targetEpoch: targetEpoch\n };\n}\nfunction $c3af9e523501759a$var$getPriorVoters({ buf: buf, idx: idx, isEmpty: isEmpty }) {\n if (isEmpty) return [];\n return [\n ...buf.slice(idx + 1).map($c3af9e523501759a$var$parsePriorVoters),\n ...buf.slice(0, idx).map($c3af9e523501759a$var$parsePriorVoters)\n ];\n}\nconst $c3af9e523501759a$var$endpoint = {\n http: {\n devnet: 'http://api.devnet.solana.com',\n testnet: 'http://api.testnet.solana.com',\n 'mainnet-beta': 'http://api.mainnet-beta.solana.com/'\n },\n https: {\n devnet: 'https://api.devnet.solana.com',\n testnet: 'https://api.testnet.solana.com',\n 'mainnet-beta': 'https://api.mainnet-beta.solana.com/'\n }\n};\n/**\n * Retrieves the RPC API URL for the specified cluster\n * @param {Cluster} [cluster=\"devnet\"] - The cluster name of the RPC API URL to use. Possible options: 'devnet' | 'testnet' | 'mainnet-beta'\n * @param {boolean} [tls=\"http\"] - Use TLS when connecting to cluster.\n *\n * @returns {string} URL string of the RPC endpoint\n */ function $c3af9e523501759a$export$11656287b4eb76ff(cluster, tls) {\n const key = tls === false ? 'http' : 'https';\n if (!cluster) return $c3af9e523501759a$var$endpoint[key]['devnet'];\n const url = $c3af9e523501759a$var$endpoint[key][cluster];\n if (!url) throw new Error(`Unknown ${key} cluster: ${cluster}`);\n return url;\n}\n/**\n * Send and confirm a raw transaction\n *\n * If `commitment` option is not specified, defaults to 'max' commitment.\n *\n * @param {Connection} connection\n * @param {Buffer} rawTransaction\n * @param {TransactionConfirmationStrategy} confirmationStrategy\n * @param {ConfirmOptions} [options]\n * @returns {Promise}\n */ /**\n * @deprecated Calling `sendAndConfirmRawTransaction()` without a `confirmationStrategy`\n * is no longer supported and will be removed in a future version.\n */ // eslint-disable-next-line no-redeclare\n// eslint-disable-next-line no-redeclare\nasync function $c3af9e523501759a$export$554271b88fdb7843(connection, rawTransaction, confirmationStrategyOrConfirmOptions, maybeConfirmOptions) {\n let confirmationStrategy;\n let options;\n if (confirmationStrategyOrConfirmOptions && Object.prototype.hasOwnProperty.call(confirmationStrategyOrConfirmOptions, 'lastValidBlockHeight')) {\n confirmationStrategy = confirmationStrategyOrConfirmOptions;\n options = maybeConfirmOptions;\n } else if (confirmationStrategyOrConfirmOptions && Object.prototype.hasOwnProperty.call(confirmationStrategyOrConfirmOptions, 'nonceValue')) {\n confirmationStrategy = confirmationStrategyOrConfirmOptions;\n options = maybeConfirmOptions;\n } else options = confirmationStrategyOrConfirmOptions;\n const sendOptions = options && {\n skipPreflight: options.skipPreflight,\n preflightCommitment: options.preflightCommitment || options.commitment,\n minContextSlot: options.minContextSlot\n };\n const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);\n const commitment = options && options.commitment;\n const confirmationPromise = confirmationStrategy ? connection.confirmTransaction(confirmationStrategy, commitment) : connection.confirmTransaction(signature, commitment);\n const status = (await confirmationPromise).value;\n if (status.err) {\n if (signature != null) throw new $c3af9e523501759a$export$121e803f723b3045({\n action: sendOptions?.skipPreflight ? 'send' : 'simulate',\n signature: signature,\n transactionMessage: `Status: (${JSON.stringify(status)})`\n });\n throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);\n }\n return signature;\n}\n/**\n * There are 1-billion lamports in one SOL\n */ const $c3af9e523501759a$export$5f6a2f2669741bbe = 1000000000;\n\n});\nparcelRegister(\"kE5x4\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.hash_to_ristretto255 = module.exports.hashToRistretto255 = module.exports.RistrettoPoint = module.exports.encodeToCurve = module.exports.hashToCurve = module.exports.edwardsToMontgomery = module.exports.x25519 = module.exports.ed25519ph = module.exports.ed25519ctx = module.exports.ed25519 = module.exports.ED25519_TORSION_SUBGROUP = void 0;\nmodule.exports.edwardsToMontgomeryPub = $f07bd5acd6595f86$var$edwardsToMontgomeryPub;\nmodule.exports.edwardsToMontgomeryPriv = $f07bd5acd6595f86$var$edwardsToMontgomeryPriv;\n\nvar $3dtER = parcelRequire(\"3dtER\");\n\nvar $3Bcdj = parcelRequire(\"3Bcdj\");\n\nvar $lkFCe = parcelRequire(\"lkFCe\");\n\nvar $qoWOx = parcelRequire(\"qoWOx\");\n\nvar $rkPJ6 = parcelRequire(\"rkPJ6\");\n\nvar $2D9sF = parcelRequire(\"2D9sF\");\n\nvar $kiLeO = parcelRequire(\"kiLeO\");\n\nvar $esaJO = parcelRequire(\"esaJO\");\nconst $f07bd5acd6595f86$var$ED25519_P = BigInt('57896044618658097711785492504343953926634992332820282019728792003956564819949');\n// √(-1) aka √(a) aka 2^((p-1)/4)\nconst $f07bd5acd6595f86$var$ED25519_SQRT_M1 = /* @__PURE__ */ BigInt('19681161376707505956807079304988542015446066515923890162744021073123829784752');\n// prettier-ignore\nconst $f07bd5acd6595f86$var$_0n = BigInt(0), $f07bd5acd6595f86$var$_1n = BigInt(1), $f07bd5acd6595f86$var$_2n = BigInt(2), $f07bd5acd6595f86$var$_3n = BigInt(3);\n// prettier-ignore\nconst $f07bd5acd6595f86$var$_5n = BigInt(5), $f07bd5acd6595f86$var$_8n = BigInt(8);\nfunction $f07bd5acd6595f86$var$ed25519_pow_2_252_3(x) {\n // prettier-ignore\n const _10n = BigInt(10), _20n = BigInt(20), _40n = BigInt(40), _80n = BigInt(80);\n const P = $f07bd5acd6595f86$var$ED25519_P;\n const x2 = x * x % P;\n const b2 = x2 * x % P; // x^3, 11\n const b4 = (0, $2D9sF.pow2)(b2, $f07bd5acd6595f86$var$_2n, P) * b2 % P; // x^15, 1111\n const b5 = (0, $2D9sF.pow2)(b4, $f07bd5acd6595f86$var$_1n, P) * x % P; // x^31\n const b10 = (0, $2D9sF.pow2)(b5, $f07bd5acd6595f86$var$_5n, P) * b5 % P;\n const b20 = (0, $2D9sF.pow2)(b10, _10n, P) * b10 % P;\n const b40 = (0, $2D9sF.pow2)(b20, _20n, P) * b20 % P;\n const b80 = (0, $2D9sF.pow2)(b40, _40n, P) * b40 % P;\n const b160 = (0, $2D9sF.pow2)(b80, _80n, P) * b80 % P;\n const b240 = (0, $2D9sF.pow2)(b160, _80n, P) * b80 % P;\n const b250 = (0, $2D9sF.pow2)(b240, _10n, P) * b10 % P;\n const pow_p_5_8 = (0, $2D9sF.pow2)(b250, $f07bd5acd6595f86$var$_2n, P) * x % P;\n // ^ To pow to (p+3)/8, multiply it by x.\n return {\n pow_p_5_8: pow_p_5_8,\n b2: b2\n };\n}\nfunction $f07bd5acd6595f86$var$adjustScalarBytes(bytes) {\n // Section 5: For X25519, in order to decode 32 random bytes as an integer scalar,\n // set the three least significant bits of the first byte\n bytes[0] &= 248; // 0b1111_1000\n // and the most significant bit of the last to zero,\n bytes[31] &= 127; // 0b0111_1111\n // set the second most significant bit of the last byte to 1\n bytes[31] |= 64; // 0b0100_0000\n return bytes;\n}\n// sqrt(u/v)\nfunction $f07bd5acd6595f86$var$uvRatio(u, v) {\n const P = $f07bd5acd6595f86$var$ED25519_P;\n const v3 = (0, $2D9sF.mod)(v * v * v, P); // v³\n const v7 = (0, $2D9sF.mod)(v3 * v3 * v, P); // v⁷\n // (p+3)/8 and (p-5)/8\n const pow = $f07bd5acd6595f86$var$ed25519_pow_2_252_3(u * v7).pow_p_5_8;\n let x = (0, $2D9sF.mod)(u * v3 * pow, P); // (uv³)(uv⁷)^(p-5)/8\n const vx2 = (0, $2D9sF.mod)(v * x * x, P); // vx²\n const root1 = x; // First root candidate\n const root2 = (0, $2D9sF.mod)(x * $f07bd5acd6595f86$var$ED25519_SQRT_M1, P); // Second root candidate\n const useRoot1 = vx2 === u; // If vx² = u (mod p), x is a square root\n const useRoot2 = vx2 === (0, $2D9sF.mod)(-u, P); // If vx² = -u, set x <-- x * 2^((p-1)/4)\n const noRoot = vx2 === (0, $2D9sF.mod)(-u * $f07bd5acd6595f86$var$ED25519_SQRT_M1, P); // There is no valid root, vx² = -u√(-1)\n if (useRoot1) x = root1;\n if (useRoot2 || noRoot) x = root2; // We return root2 anyway, for const-time\n if ((0, $2D9sF.isNegativeLE)(x, P)) x = (0, $2D9sF.mod)(-x, P);\n return {\n isValid: useRoot1 || useRoot2,\n value: x\n };\n}\n// Just in case\nmodule.exports.ED25519_TORSION_SUBGROUP = [\n '0100000000000000000000000000000000000000000000000000000000000000',\n 'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a',\n '0000000000000000000000000000000000000000000000000000000000000080',\n '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05',\n 'ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f',\n '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85',\n '0000000000000000000000000000000000000000000000000000000000000000',\n 'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa'\n];\nconst $f07bd5acd6595f86$var$Fp = /* @__PURE__ */ (()=>(0, $2D9sF.Field)($f07bd5acd6595f86$var$ED25519_P, undefined, true))();\nconst $f07bd5acd6595f86$var$ed25519Defaults = /* @__PURE__ */ (()=>({\n // Param: a\n a: BigInt(-1),\n // d is equal to -121665/121666 over finite field.\n // Negative number is P - number, and division is invert(number, P)\n d: BigInt('37095705934669439343138083508754565189542113879843219016388785533085940283555'),\n Fp: // Finite field 𝔽p over which we'll do calculations; 2n**255n - 19n\n $f07bd5acd6595f86$var$Fp,\n // Subgroup order: how many points curve has\n // 2n**252n + 27742317777372353535851937790883648493n;\n n: BigInt('7237005577332262213973186563042994240857116359379907606001950938285454250989'),\n // Cofactor\n h: $f07bd5acd6595f86$var$_8n,\n // Base point (x, y) aka generator point\n Gx: BigInt('15112221349535400772501151409588531511454012693041857206046113283949847762202'),\n Gy: BigInt('46316835694926478169428394003475163141307993866256225615783033603165251855960'),\n hash: $3dtER.sha512,\n randomBytes: $3Bcdj.randomBytes,\n adjustScalarBytes: $f07bd5acd6595f86$var$adjustScalarBytes,\n uvRatio: // dom2\n // Ratio of u to v. Allows us to combine inversion and square root. Uses algo from RFC8032 5.1.3.\n // Constant-time, u/√v\n $f07bd5acd6595f86$var$uvRatio\n }))();\n/**\n * ed25519 curve with EdDSA signatures.\n * @example\n * import { ed25519 } from '@noble/curves/ed25519';\n * const priv = ed25519.utils.randomPrivateKey();\n * const pub = ed25519.getPublicKey(priv);\n * const msg = new TextEncoder().encode('hello');\n * const sig = ed25519.sign(msg, priv);\n * ed25519.verify(sig, msg, pub); // Default mode: follows ZIP215\n * ed25519.verify(sig, msg, pub, { zip215: false }); // RFC8032 / FIPS 186-5\n */ module.exports.ed25519 = (()=>(0, $qoWOx.twistedEdwards)($f07bd5acd6595f86$var$ed25519Defaults))();\nfunction $f07bd5acd6595f86$var$ed25519_domain(data, ctx, phflag) {\n if (ctx.length > 255) throw new Error('Context is too big');\n return (0, $3Bcdj.concatBytes)((0, $3Bcdj.utf8ToBytes)('SigEd25519 no Ed25519 collisions'), new Uint8Array([\n phflag ? 1 : 0,\n ctx.length\n ]), ctx, data);\n}\nmodule.exports.ed25519ctx = (()=>(0, $qoWOx.twistedEdwards)({\n ...$f07bd5acd6595f86$var$ed25519Defaults,\n domain: $f07bd5acd6595f86$var$ed25519_domain\n }))();\nmodule.exports.ed25519ph = (()=>(0, $qoWOx.twistedEdwards)(Object.assign({}, $f07bd5acd6595f86$var$ed25519Defaults, {\n domain: $f07bd5acd6595f86$var$ed25519_domain,\n prehash: $3dtER.sha512\n })))();\n/**\n * ECDH using curve25519 aka x25519.\n * @example\n * import { x25519 } from '@noble/curves/ed25519';\n * const priv = 'a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4';\n * const pub = 'e6db6867583030db3594c1a424b15f7c726624ec26b3353b10a903a6d0ab1c4c';\n * x25519.getSharedSecret(priv, pub) === x25519.scalarMult(priv, pub); // aliases\n * x25519.getPublicKey(priv) === x25519.scalarMultBase(priv);\n * x25519.getPublicKey(x25519.utils.randomPrivateKey());\n */ module.exports.x25519 = (()=>(0, $kiLeO.montgomery)({\n P: $f07bd5acd6595f86$var$ED25519_P,\n a: BigInt(486662),\n montgomeryBits: 255,\n nByteLength: 32,\n Gu: BigInt(9),\n powPminus2: (x)=>{\n const P = $f07bd5acd6595f86$var$ED25519_P;\n // x^(p-2) aka x^(2^255-21)\n const { pow_p_5_8: pow_p_5_8, b2: b2 } = $f07bd5acd6595f86$var$ed25519_pow_2_252_3(x);\n return (0, $2D9sF.mod)((0, $2D9sF.pow2)(pow_p_5_8, $f07bd5acd6595f86$var$_3n, P) * b2, P);\n },\n adjustScalarBytes: $f07bd5acd6595f86$var$adjustScalarBytes,\n randomBytes: $3Bcdj.randomBytes\n }))();\n/**\n * Converts ed25519 public key to x25519 public key. Uses formula:\n * * `(u, v) = ((1+y)/(1-y), sqrt(-486664)*u/x)`\n * * `(x, y) = (sqrt(-486664)*u/v, (u-1)/(u+1))`\n * @example\n * const someonesPub = ed25519.getPublicKey(ed25519.utils.randomPrivateKey());\n * const aPriv = x25519.utils.randomPrivateKey();\n * x25519.getSharedSecret(aPriv, edwardsToMontgomeryPub(someonesPub))\n */ function $f07bd5acd6595f86$var$edwardsToMontgomeryPub(edwardsPub) {\n const { y: y } = module.exports.ed25519.ExtendedPoint.fromHex(edwardsPub);\n const _1n = BigInt(1);\n return $f07bd5acd6595f86$var$Fp.toBytes($f07bd5acd6595f86$var$Fp.create((_1n + y) * $f07bd5acd6595f86$var$Fp.inv(_1n - y)));\n}\nmodule.exports.edwardsToMontgomery = $f07bd5acd6595f86$var$edwardsToMontgomeryPub; // deprecated\n/**\n * Converts ed25519 secret key to x25519 secret key.\n * @example\n * const someonesPub = x25519.getPublicKey(x25519.utils.randomPrivateKey());\n * const aPriv = ed25519.utils.randomPrivateKey();\n * x25519.getSharedSecret(edwardsToMontgomeryPriv(aPriv), someonesPub)\n */ function $f07bd5acd6595f86$var$edwardsToMontgomeryPriv(edwardsPriv) {\n const hashed = $f07bd5acd6595f86$var$ed25519Defaults.hash(edwardsPriv.subarray(0, 32));\n return $f07bd5acd6595f86$var$ed25519Defaults.adjustScalarBytes(hashed).subarray(0, 32);\n}\n// Hash To Curve Elligator2 Map (NOTE: different from ristretto255 elligator)\n// NOTE: very important part is usage of FpSqrtEven for ELL2_C1_EDWARDS, since\n// SageMath returns different root first and everything falls apart\nconst $f07bd5acd6595f86$var$ELL2_C1 = /* @__PURE__ */ (()=>($f07bd5acd6595f86$var$Fp.ORDER + $f07bd5acd6595f86$var$_3n) / $f07bd5acd6595f86$var$_8n)(); // 1. c1 = (q + 3) / 8 # Integer arithmetic\nconst $f07bd5acd6595f86$var$ELL2_C2 = /* @__PURE__ */ (()=>$f07bd5acd6595f86$var$Fp.pow($f07bd5acd6595f86$var$_2n, $f07bd5acd6595f86$var$ELL2_C1))(); // 2. c2 = 2^c1\nconst $f07bd5acd6595f86$var$ELL2_C3 = /* @__PURE__ */ (()=>$f07bd5acd6595f86$var$Fp.sqrt($f07bd5acd6595f86$var$Fp.neg($f07bd5acd6595f86$var$Fp.ONE)))(); // 3. c3 = sqrt(-1)\n// prettier-ignore\nfunction $f07bd5acd6595f86$var$map_to_curve_elligator2_curve25519(u) {\n const ELL2_C4 = ($f07bd5acd6595f86$var$Fp.ORDER - $f07bd5acd6595f86$var$_5n) / $f07bd5acd6595f86$var$_8n; // 4. c4 = (q - 5) / 8 # Integer arithmetic\n const ELL2_J = BigInt(486662);\n let tv1 = $f07bd5acd6595f86$var$Fp.sqr(u); // 1. tv1 = u^2\n tv1 = $f07bd5acd6595f86$var$Fp.mul(tv1, $f07bd5acd6595f86$var$_2n); // 2. tv1 = 2 * tv1\n let xd = $f07bd5acd6595f86$var$Fp.add(tv1, $f07bd5acd6595f86$var$Fp.ONE); // 3. xd = tv1 + 1 # Nonzero: -1 is square (mod p), tv1 is not\n let x1n = $f07bd5acd6595f86$var$Fp.neg(ELL2_J); // 4. x1n = -J # x1 = x1n / xd = -J / (1 + 2 * u^2)\n let tv2 = $f07bd5acd6595f86$var$Fp.sqr(xd); // 5. tv2 = xd^2\n let gxd = $f07bd5acd6595f86$var$Fp.mul(tv2, xd); // 6. gxd = tv2 * xd # gxd = xd^3\n let gx1 = $f07bd5acd6595f86$var$Fp.mul(tv1, ELL2_J); // 7. gx1 = J * tv1 # x1n + J * xd\n gx1 = $f07bd5acd6595f86$var$Fp.mul(gx1, x1n); // 8. gx1 = gx1 * x1n # x1n^2 + J * x1n * xd\n gx1 = $f07bd5acd6595f86$var$Fp.add(gx1, tv2); // 9. gx1 = gx1 + tv2 # x1n^2 + J * x1n * xd + xd^2\n gx1 = $f07bd5acd6595f86$var$Fp.mul(gx1, x1n); // 10. gx1 = gx1 * x1n # x1n^3 + J * x1n^2 * xd + x1n * xd^2\n let tv3 = $f07bd5acd6595f86$var$Fp.sqr(gxd); // 11. tv3 = gxd^2\n tv2 = $f07bd5acd6595f86$var$Fp.sqr(tv3); // 12. tv2 = tv3^2 # gxd^4\n tv3 = $f07bd5acd6595f86$var$Fp.mul(tv3, gxd); // 13. tv3 = tv3 * gxd # gxd^3\n tv3 = $f07bd5acd6595f86$var$Fp.mul(tv3, gx1); // 14. tv3 = tv3 * gx1 # gx1 * gxd^3\n tv2 = $f07bd5acd6595f86$var$Fp.mul(tv2, tv3); // 15. tv2 = tv2 * tv3 # gx1 * gxd^7\n let y11 = $f07bd5acd6595f86$var$Fp.pow(tv2, ELL2_C4); // 16. y11 = tv2^c4 # (gx1 * gxd^7)^((p - 5) / 8)\n y11 = $f07bd5acd6595f86$var$Fp.mul(y11, tv3); // 17. y11 = y11 * tv3 # gx1*gxd^3*(gx1*gxd^7)^((p-5)/8)\n let y12 = $f07bd5acd6595f86$var$Fp.mul(y11, $f07bd5acd6595f86$var$ELL2_C3); // 18. y12 = y11 * c3\n tv2 = $f07bd5acd6595f86$var$Fp.sqr(y11); // 19. tv2 = y11^2\n tv2 = $f07bd5acd6595f86$var$Fp.mul(tv2, gxd); // 20. tv2 = tv2 * gxd\n let e1 = $f07bd5acd6595f86$var$Fp.eql(tv2, gx1); // 21. e1 = tv2 == gx1\n let y1 = $f07bd5acd6595f86$var$Fp.cmov(y12, y11, e1); // 22. y1 = CMOV(y12, y11, e1) # If g(x1) is square, this is its sqrt\n let x2n = $f07bd5acd6595f86$var$Fp.mul(x1n, tv1); // 23. x2n = x1n * tv1 # x2 = x2n / xd = 2 * u^2 * x1n / xd\n let y21 = $f07bd5acd6595f86$var$Fp.mul(y11, u); // 24. y21 = y11 * u\n y21 = $f07bd5acd6595f86$var$Fp.mul(y21, $f07bd5acd6595f86$var$ELL2_C2); // 25. y21 = y21 * c2\n let y22 = $f07bd5acd6595f86$var$Fp.mul(y21, $f07bd5acd6595f86$var$ELL2_C3); // 26. y22 = y21 * c3\n let gx2 = $f07bd5acd6595f86$var$Fp.mul(gx1, tv1); // 27. gx2 = gx1 * tv1 # g(x2) = gx2 / gxd = 2 * u^2 * g(x1)\n tv2 = $f07bd5acd6595f86$var$Fp.sqr(y21); // 28. tv2 = y21^2\n tv2 = $f07bd5acd6595f86$var$Fp.mul(tv2, gxd); // 29. tv2 = tv2 * gxd\n let e2 = $f07bd5acd6595f86$var$Fp.eql(tv2, gx2); // 30. e2 = tv2 == gx2\n let y2 = $f07bd5acd6595f86$var$Fp.cmov(y22, y21, e2); // 31. y2 = CMOV(y22, y21, e2) # If g(x2) is square, this is its sqrt\n tv2 = $f07bd5acd6595f86$var$Fp.sqr(y1); // 32. tv2 = y1^2\n tv2 = $f07bd5acd6595f86$var$Fp.mul(tv2, gxd); // 33. tv2 = tv2 * gxd\n let e3 = $f07bd5acd6595f86$var$Fp.eql(tv2, gx1); // 34. e3 = tv2 == gx1\n let xn = $f07bd5acd6595f86$var$Fp.cmov(x2n, x1n, e3); // 35. xn = CMOV(x2n, x1n, e3) # If e3, x = x1, else x = x2\n let y = $f07bd5acd6595f86$var$Fp.cmov(y2, y1, e3); // 36. y = CMOV(y2, y1, e3) # If e3, y = y1, else y = y2\n let e4 = $f07bd5acd6595f86$var$Fp.isOdd(y); // 37. e4 = sgn0(y) == 1 # Fix sign of y\n y = $f07bd5acd6595f86$var$Fp.cmov(y, $f07bd5acd6595f86$var$Fp.neg(y), e3 !== e4); // 38. y = CMOV(y, -y, e3 XOR e4)\n return {\n xMn: xn,\n xMd: xd,\n yMn: y,\n yMd: $f07bd5acd6595f86$var$_1n\n }; // 39. return (xn, xd, y, 1)\n}\nconst $f07bd5acd6595f86$var$ELL2_C1_EDWARDS = /* @__PURE__ */ (()=>(0, $2D9sF.FpSqrtEven)($f07bd5acd6595f86$var$Fp, $f07bd5acd6595f86$var$Fp.neg(BigInt(486664))))(); // sgn0(c1) MUST equal 0\nfunction $f07bd5acd6595f86$var$map_to_curve_elligator2_edwards25519(u) {\n const { xMn: xMn, xMd: xMd, yMn: yMn, yMd: yMd } = $f07bd5acd6595f86$var$map_to_curve_elligator2_curve25519(u); // 1. (xMn, xMd, yMn, yMd) =\n // map_to_curve_elligator2_curve25519(u)\n let xn = $f07bd5acd6595f86$var$Fp.mul(xMn, yMd); // 2. xn = xMn * yMd\n xn = $f07bd5acd6595f86$var$Fp.mul(xn, $f07bd5acd6595f86$var$ELL2_C1_EDWARDS); // 3. xn = xn * c1\n let xd = $f07bd5acd6595f86$var$Fp.mul(xMd, yMn); // 4. xd = xMd * yMn # xn / xd = c1 * xM / yM\n let yn = $f07bd5acd6595f86$var$Fp.sub(xMn, xMd); // 5. yn = xMn - xMd\n let yd = $f07bd5acd6595f86$var$Fp.add(xMn, xMd); // 6. yd = xMn + xMd # (n / d - 1) / (n / d + 1) = (n - d) / (n + d)\n let tv1 = $f07bd5acd6595f86$var$Fp.mul(xd, yd); // 7. tv1 = xd * yd\n let e = $f07bd5acd6595f86$var$Fp.eql(tv1, $f07bd5acd6595f86$var$Fp.ZERO); // 8. e = tv1 == 0\n xn = $f07bd5acd6595f86$var$Fp.cmov(xn, $f07bd5acd6595f86$var$Fp.ZERO, e); // 9. xn = CMOV(xn, 0, e)\n xd = $f07bd5acd6595f86$var$Fp.cmov(xd, $f07bd5acd6595f86$var$Fp.ONE, e); // 10. xd = CMOV(xd, 1, e)\n yn = $f07bd5acd6595f86$var$Fp.cmov(yn, $f07bd5acd6595f86$var$Fp.ONE, e); // 11. yn = CMOV(yn, 1, e)\n yd = $f07bd5acd6595f86$var$Fp.cmov(yd, $f07bd5acd6595f86$var$Fp.ONE, e); // 12. yd = CMOV(yd, 1, e)\n const inv = $f07bd5acd6595f86$var$Fp.invertBatch([\n xd,\n yd\n ]); // batch division\n return {\n x: $f07bd5acd6595f86$var$Fp.mul(xn, inv[0]),\n y: $f07bd5acd6595f86$var$Fp.mul(yn, inv[1])\n }; // 13. return (xn, xd, yn, yd)\n}\nconst $f07bd5acd6595f86$var$htf = /* @__PURE__ */ (()=>(0, $rkPJ6.createHasher)(module.exports.ed25519.ExtendedPoint, (scalars)=>$f07bd5acd6595f86$var$map_to_curve_elligator2_edwards25519(scalars[0]), {\n DST: 'edwards25519_XMD:SHA-512_ELL2_RO_',\n encodeDST: 'edwards25519_XMD:SHA-512_ELL2_NU_',\n p: $f07bd5acd6595f86$var$Fp.ORDER,\n m: 1,\n k: 128,\n expand: 'xmd',\n hash: $3dtER.sha512\n }))();\nmodule.exports.hashToCurve = (()=>$f07bd5acd6595f86$var$htf.hashToCurve)();\nmodule.exports.encodeToCurve = (()=>$f07bd5acd6595f86$var$htf.encodeToCurve)();\nfunction $f07bd5acd6595f86$var$assertRstPoint(other) {\n if (!(other instanceof $f07bd5acd6595f86$var$RistPoint)) throw new Error('RistrettoPoint expected');\n}\n// √(-1) aka √(a) aka 2^((p-1)/4)\nconst $f07bd5acd6595f86$var$SQRT_M1 = $f07bd5acd6595f86$var$ED25519_SQRT_M1;\n// √(ad - 1)\nconst $f07bd5acd6595f86$var$SQRT_AD_MINUS_ONE = /* @__PURE__ */ BigInt('25063068953384623474111414158702152701244531502492656460079210482610430750235');\n// 1 / √(a-d)\nconst $f07bd5acd6595f86$var$INVSQRT_A_MINUS_D = /* @__PURE__ */ BigInt('54469307008909316920995813868745141605393597292927456921205312896311721017578');\n// 1-d²\nconst $f07bd5acd6595f86$var$ONE_MINUS_D_SQ = /* @__PURE__ */ BigInt('1159843021668779879193775521855586647937357759715417654439879720876111806838');\n// (d-1)²\nconst $f07bd5acd6595f86$var$D_MINUS_ONE_SQ = /* @__PURE__ */ BigInt('40440834346308536858101042469323190826248399146238708352240133220865137265952');\n// Calculates 1/√(number)\nconst $f07bd5acd6595f86$var$invertSqrt = (number)=>$f07bd5acd6595f86$var$uvRatio($f07bd5acd6595f86$var$_1n, number);\nconst $f07bd5acd6595f86$var$MAX_255B = /* @__PURE__ */ BigInt('0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');\nconst $f07bd5acd6595f86$var$bytes255ToNumberLE = (bytes)=>module.exports.ed25519.CURVE.Fp.create((0, $esaJO.bytesToNumberLE)(bytes) & $f07bd5acd6595f86$var$MAX_255B);\n// Computes Elligator map for Ristretto\n// https://ristretto.group/formulas/elligator.html\nfunction $f07bd5acd6595f86$var$calcElligatorRistrettoMap(r0) {\n const { d: d } = module.exports.ed25519.CURVE;\n const P = module.exports.ed25519.CURVE.Fp.ORDER;\n const mod = module.exports.ed25519.CURVE.Fp.create;\n const r = mod($f07bd5acd6595f86$var$SQRT_M1 * r0 * r0); // 1\n const Ns = mod((r + $f07bd5acd6595f86$var$_1n) * $f07bd5acd6595f86$var$ONE_MINUS_D_SQ); // 2\n let c = BigInt(-1); // 3\n const D = mod((c - d * r) * mod(r + d)); // 4\n let { isValid: Ns_D_is_sq, value: s } = $f07bd5acd6595f86$var$uvRatio(Ns, D); // 5\n let s_ = mod(s * r0); // 6\n if (!(0, $2D9sF.isNegativeLE)(s_, P)) s_ = mod(-s_);\n if (!Ns_D_is_sq) s = s_; // 7\n if (!Ns_D_is_sq) c = r; // 8\n const Nt = mod(c * (r - $f07bd5acd6595f86$var$_1n) * $f07bd5acd6595f86$var$D_MINUS_ONE_SQ - D); // 9\n const s2 = s * s;\n const W0 = mod((s + s) * D); // 10\n const W1 = mod(Nt * $f07bd5acd6595f86$var$SQRT_AD_MINUS_ONE); // 11\n const W2 = mod($f07bd5acd6595f86$var$_1n - s2); // 12\n const W3 = mod($f07bd5acd6595f86$var$_1n + s2); // 13\n return new module.exports.ed25519.ExtendedPoint(mod(W0 * W3), mod(W2 * W1), mod(W1 * W3), mod(W0 * W2));\n}\n/**\n * Each ed25519/ExtendedPoint has 8 different equivalent points. This can be\n * a source of bugs for protocols like ring signatures. Ristretto was created to solve this.\n * Ristretto point operates in X:Y:Z:T extended coordinates like ExtendedPoint,\n * but it should work in its own namespace: do not combine those two.\n * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-ristretto255-decaf448\n */ class $f07bd5acd6595f86$var$RistPoint {\n // Private property to discourage combining ExtendedPoint + RistrettoPoint\n // Always use Ristretto encoding/decoding instead.\n constructor(ep){\n this.ep = ep;\n }\n static fromAffine(ap) {\n return new $f07bd5acd6595f86$var$RistPoint(module.exports.ed25519.ExtendedPoint.fromAffine(ap));\n }\n /**\n * Takes uniform output of 64-byte hash function like sha512 and converts it to `RistrettoPoint`.\n * The hash-to-group operation applies Elligator twice and adds the results.\n * **Note:** this is one-way map, there is no conversion from point to hash.\n * https://ristretto.group/formulas/elligator.html\n * @param hex 64-byte output of a hash function\n */ static hashToCurve(hex) {\n hex = (0, $esaJO.ensureBytes)('ristrettoHash', hex, 64);\n const r1 = $f07bd5acd6595f86$var$bytes255ToNumberLE(hex.slice(0, 32));\n const R1 = $f07bd5acd6595f86$var$calcElligatorRistrettoMap(r1);\n const r2 = $f07bd5acd6595f86$var$bytes255ToNumberLE(hex.slice(32, 64));\n const R2 = $f07bd5acd6595f86$var$calcElligatorRistrettoMap(r2);\n return new $f07bd5acd6595f86$var$RistPoint(R1.add(R2));\n }\n /**\n * Converts ristretto-encoded string to ristretto point.\n * https://ristretto.group/formulas/decoding.html\n * @param hex Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding\n */ static fromHex(hex) {\n hex = (0, $esaJO.ensureBytes)('ristrettoHex', hex, 32);\n const { a: a, d: d } = module.exports.ed25519.CURVE;\n const P = module.exports.ed25519.CURVE.Fp.ORDER;\n const mod = module.exports.ed25519.CURVE.Fp.create;\n const emsg = 'RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint';\n const s = $f07bd5acd6595f86$var$bytes255ToNumberLE(hex);\n // 1. Check that s_bytes is the canonical encoding of a field element, or else abort.\n // 3. Check that s is non-negative, or else abort\n if (!(0, $esaJO.equalBytes)((0, $esaJO.numberToBytesLE)(s, 32), hex) || (0, $2D9sF.isNegativeLE)(s, P)) throw new Error(emsg);\n const s2 = mod(s * s);\n const u1 = mod($f07bd5acd6595f86$var$_1n + a * s2); // 4 (a is -1)\n const u2 = mod($f07bd5acd6595f86$var$_1n - a * s2); // 5\n const u1_2 = mod(u1 * u1);\n const u2_2 = mod(u2 * u2);\n const v = mod(a * d * u1_2 - u2_2); // 6\n const { isValid: isValid, value: I } = $f07bd5acd6595f86$var$invertSqrt(mod(v * u2_2)); // 7\n const Dx = mod(I * u2); // 8\n const Dy = mod(I * Dx * v); // 9\n let x = mod((s + s) * Dx); // 10\n if ((0, $2D9sF.isNegativeLE)(x, P)) x = mod(-x); // 10\n const y = mod(u1 * Dy); // 11\n const t = mod(x * y); // 12\n if (!isValid || (0, $2D9sF.isNegativeLE)(t, P) || y === $f07bd5acd6595f86$var$_0n) throw new Error(emsg);\n return new $f07bd5acd6595f86$var$RistPoint(new module.exports.ed25519.ExtendedPoint(x, y, $f07bd5acd6595f86$var$_1n, t));\n }\n static msm(points, scalars) {\n const Fn = (0, $2D9sF.Field)(module.exports.ed25519.CURVE.n, module.exports.ed25519.CURVE.nBitLength);\n return (0, $lkFCe.pippenger)($f07bd5acd6595f86$var$RistPoint, Fn, points, scalars);\n }\n /**\n * Encodes ristretto point to Uint8Array.\n * https://ristretto.group/formulas/encoding.html\n */ toRawBytes() {\n let { ex: x, ey: y, ez: z, et: t } = this.ep;\n const P = module.exports.ed25519.CURVE.Fp.ORDER;\n const mod = module.exports.ed25519.CURVE.Fp.create;\n const u1 = mod(mod(z + y) * mod(z - y)); // 1\n const u2 = mod(x * y); // 2\n // Square root always exists\n const u2sq = mod(u2 * u2);\n const { value: invsqrt } = $f07bd5acd6595f86$var$invertSqrt(mod(u1 * u2sq)); // 3\n const D1 = mod(invsqrt * u1); // 4\n const D2 = mod(invsqrt * u2); // 5\n const zInv = mod(D1 * D2 * t); // 6\n let D; // 7\n if ((0, $2D9sF.isNegativeLE)(t * zInv, P)) {\n let _x = mod(y * $f07bd5acd6595f86$var$SQRT_M1);\n let _y = mod(x * $f07bd5acd6595f86$var$SQRT_M1);\n x = _x;\n y = _y;\n D = mod(D1 * $f07bd5acd6595f86$var$INVSQRT_A_MINUS_D);\n } else D = D2; // 8\n if ((0, $2D9sF.isNegativeLE)(x * zInv, P)) y = mod(-y); // 9\n let s = mod((z - y) * D); // 10 (check footer's note, no sqrt(-a))\n if ((0, $2D9sF.isNegativeLE)(s, P)) s = mod(-s);\n return (0, $esaJO.numberToBytesLE)(s, 32); // 11\n }\n toHex() {\n return (0, $esaJO.bytesToHex)(this.toRawBytes());\n }\n toString() {\n return this.toHex();\n }\n // Compare one point to another.\n equals(other) {\n $f07bd5acd6595f86$var$assertRstPoint(other);\n const { ex: X1, ey: Y1 } = this.ep;\n const { ex: X2, ey: Y2 } = other.ep;\n const mod = module.exports.ed25519.CURVE.Fp.create;\n // (x1 * y2 == y1 * x2) | (y1 * y2 == x1 * x2)\n const one = mod(X1 * Y2) === mod(Y1 * X2);\n const two = mod(Y1 * Y2) === mod(X1 * X2);\n return one || two;\n }\n add(other) {\n $f07bd5acd6595f86$var$assertRstPoint(other);\n return new $f07bd5acd6595f86$var$RistPoint(this.ep.add(other.ep));\n }\n subtract(other) {\n $f07bd5acd6595f86$var$assertRstPoint(other);\n return new $f07bd5acd6595f86$var$RistPoint(this.ep.subtract(other.ep));\n }\n multiply(scalar) {\n return new $f07bd5acd6595f86$var$RistPoint(this.ep.multiply(scalar));\n }\n multiplyUnsafe(scalar) {\n return new $f07bd5acd6595f86$var$RistPoint(this.ep.multiplyUnsafe(scalar));\n }\n double() {\n return new $f07bd5acd6595f86$var$RistPoint(this.ep.double());\n }\n negate() {\n return new $f07bd5acd6595f86$var$RistPoint(this.ep.negate());\n }\n}\nmodule.exports.RistrettoPoint = (()=>{\n if (!$f07bd5acd6595f86$var$RistPoint.BASE) $f07bd5acd6595f86$var$RistPoint.BASE = new $f07bd5acd6595f86$var$RistPoint(module.exports.ed25519.ExtendedPoint.BASE);\n if (!$f07bd5acd6595f86$var$RistPoint.ZERO) $f07bd5acd6595f86$var$RistPoint.ZERO = new $f07bd5acd6595f86$var$RistPoint(module.exports.ed25519.ExtendedPoint.ZERO);\n return $f07bd5acd6595f86$var$RistPoint;\n})();\n// Hashing to ristretto255. https://www.rfc-editor.org/rfc/rfc9380#appendix-B\nconst $f07bd5acd6595f86$var$hashToRistretto255 = (msg, options)=>{\n const d = options.DST;\n const DST = typeof d === 'string' ? (0, $3Bcdj.utf8ToBytes)(d) : d;\n const uniform_bytes = (0, $rkPJ6.expand_message_xmd)(msg, DST, 64, $3dtER.sha512);\n const P = $f07bd5acd6595f86$var$RistPoint.hashToCurve(uniform_bytes);\n return P;\n};\nmodule.exports.hashToRistretto255 = $f07bd5acd6595f86$var$hashToRistretto255;\nmodule.exports.hash_to_ristretto255 = module.exports.hashToRistretto255; // legacy\n\n});\nparcelRegister(\"3dtER\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.sha384 = module.exports.sha512_256 = module.exports.sha512_224 = module.exports.sha512 = module.exports.SHA384 = module.exports.SHA512_256 = module.exports.SHA512_224 = module.exports.SHA512 = void 0;\n\nvar $iYRTw = parcelRequire(\"iYRTw\");\n\nvar $eDgKs = parcelRequire(\"eDgKs\");\n\nvar $3Bcdj = parcelRequire(\"3Bcdj\");\n// Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409):\n// prettier-ignore\nconst [$2579977b4e52adba$var$SHA512_Kh, $2579977b4e52adba$var$SHA512_Kl] = /* @__PURE__ */ (()=>$eDgKs.default.split([\n '0x428a2f98d728ae22',\n '0x7137449123ef65cd',\n '0xb5c0fbcfec4d3b2f',\n '0xe9b5dba58189dbbc',\n '0x3956c25bf348b538',\n '0x59f111f1b605d019',\n '0x923f82a4af194f9b',\n '0xab1c5ed5da6d8118',\n '0xd807aa98a3030242',\n '0x12835b0145706fbe',\n '0x243185be4ee4b28c',\n '0x550c7dc3d5ffb4e2',\n '0x72be5d74f27b896f',\n '0x80deb1fe3b1696b1',\n '0x9bdc06a725c71235',\n '0xc19bf174cf692694',\n '0xe49b69c19ef14ad2',\n '0xefbe4786384f25e3',\n '0x0fc19dc68b8cd5b5',\n '0x240ca1cc77ac9c65',\n '0x2de92c6f592b0275',\n '0x4a7484aa6ea6e483',\n '0x5cb0a9dcbd41fbd4',\n '0x76f988da831153b5',\n '0x983e5152ee66dfab',\n '0xa831c66d2db43210',\n '0xb00327c898fb213f',\n '0xbf597fc7beef0ee4',\n '0xc6e00bf33da88fc2',\n '0xd5a79147930aa725',\n '0x06ca6351e003826f',\n '0x142929670a0e6e70',\n '0x27b70a8546d22ffc',\n '0x2e1b21385c26c926',\n '0x4d2c6dfc5ac42aed',\n '0x53380d139d95b3df',\n '0x650a73548baf63de',\n '0x766a0abb3c77b2a8',\n '0x81c2c92e47edaee6',\n '0x92722c851482353b',\n '0xa2bfe8a14cf10364',\n '0xa81a664bbc423001',\n '0xc24b8b70d0f89791',\n '0xc76c51a30654be30',\n '0xd192e819d6ef5218',\n '0xd69906245565a910',\n '0xf40e35855771202a',\n '0x106aa07032bbd1b8',\n '0x19a4c116b8d2d0c8',\n '0x1e376c085141ab53',\n '0x2748774cdf8eeb99',\n '0x34b0bcb5e19b48a8',\n '0x391c0cb3c5c95a63',\n '0x4ed8aa4ae3418acb',\n '0x5b9cca4f7763e373',\n '0x682e6ff3d6b2b8a3',\n '0x748f82ee5defb2fc',\n '0x78a5636f43172f60',\n '0x84c87814a1f0ab72',\n '0x8cc702081a6439ec',\n '0x90befffa23631e28',\n '0xa4506cebde82bde9',\n '0xbef9a3f7b2c67915',\n '0xc67178f2e372532b',\n '0xca273eceea26619c',\n '0xd186b8c721c0c207',\n '0xeada7dd6cde0eb1e',\n '0xf57d4f7fee6ed178',\n '0x06f067aa72176fba',\n '0x0a637dc5a2c898a6',\n '0x113f9804bef90dae',\n '0x1b710b35131c471b',\n '0x28db77f523047d84',\n '0x32caab7b40c72493',\n '0x3c9ebe0a15c9bebc',\n '0x431d67c49c100d4c',\n '0x4cc5d4becb3e42b6',\n '0x597f299cfc657e2a',\n '0x5fcb6fab3ad6faec',\n '0x6c44198c4a475817'\n ].map((n)=>BigInt(n))))();\n// Temporary buffer, not used to store anything between runs\nconst $2579977b4e52adba$var$SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);\nconst $2579977b4e52adba$var$SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);\nclass $2579977b4e52adba$var$SHA512 extends $iYRTw.HashMD {\n constructor(){\n super(128, 64, 16, false);\n // We cannot use array here since array allows indexing by variable which means optimizer/compiler cannot use registers.\n // Also looks cleaner and easier to verify with spec.\n // Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 1779033703;\n this.Al = -205731576;\n this.Bh = -1150833019;\n this.Bl = -2067093701;\n this.Ch = 1013904242;\n this.Cl = -23791573;\n this.Dh = -1521486534;\n this.Dl = 1595750129;\n this.Eh = 1359893119;\n this.El = -1377402159;\n this.Fh = -1694144372;\n this.Fl = 725511199;\n this.Gh = 528734635;\n this.Gl = -79577749;\n this.Hh = 1541459225;\n this.Hl = 327033209;\n }\n // prettier-ignore\n get() {\n const { Ah: Ah, Al: Al, Bh: Bh, Bl: Bl, Ch: Ch, Cl: Cl, Dh: Dh, Dl: Dl, Eh: Eh, El: El, Fh: Fh, Fl: Fl, Gh: Gh, Gl: Gl, Hh: Hh, Hl: Hl } = this;\n return [\n Ah,\n Al,\n Bh,\n Bl,\n Ch,\n Cl,\n Dh,\n Dl,\n Eh,\n El,\n Fh,\n Fl,\n Gh,\n Gl,\n Hh,\n Hl\n ];\n }\n // prettier-ignore\n set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {\n this.Ah = Ah | 0;\n this.Al = Al | 0;\n this.Bh = Bh | 0;\n this.Bl = Bl | 0;\n this.Ch = Ch | 0;\n this.Cl = Cl | 0;\n this.Dh = Dh | 0;\n this.Dl = Dl | 0;\n this.Eh = Eh | 0;\n this.El = El | 0;\n this.Fh = Fh | 0;\n this.Fl = Fl | 0;\n this.Gh = Gh | 0;\n this.Gl = Gl | 0;\n this.Hh = Hh | 0;\n this.Hl = Hl | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array\n for(let i = 0; i < 16; i++, offset += 4){\n $2579977b4e52adba$var$SHA512_W_H[i] = view.getUint32(offset);\n $2579977b4e52adba$var$SHA512_W_L[i] = view.getUint32(offset += 4);\n }\n for(let i = 16; i < 80; i++){\n // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)\n const W15h = $2579977b4e52adba$var$SHA512_W_H[i - 15] | 0;\n const W15l = $2579977b4e52adba$var$SHA512_W_L[i - 15] | 0;\n const s0h = $eDgKs.default.rotrSH(W15h, W15l, 1) ^ $eDgKs.default.rotrSH(W15h, W15l, 8) ^ $eDgKs.default.shrSH(W15h, W15l, 7);\n const s0l = $eDgKs.default.rotrSL(W15h, W15l, 1) ^ $eDgKs.default.rotrSL(W15h, W15l, 8) ^ $eDgKs.default.shrSL(W15h, W15l, 7);\n // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)\n const W2h = $2579977b4e52adba$var$SHA512_W_H[i - 2] | 0;\n const W2l = $2579977b4e52adba$var$SHA512_W_L[i - 2] | 0;\n const s1h = $eDgKs.default.rotrSH(W2h, W2l, 19) ^ $eDgKs.default.rotrBH(W2h, W2l, 61) ^ $eDgKs.default.shrSH(W2h, W2l, 6);\n const s1l = $eDgKs.default.rotrSL(W2h, W2l, 19) ^ $eDgKs.default.rotrBL(W2h, W2l, 61) ^ $eDgKs.default.shrSL(W2h, W2l, 6);\n // SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];\n const SUMl = $eDgKs.default.add4L(s0l, s1l, $2579977b4e52adba$var$SHA512_W_L[i - 7], $2579977b4e52adba$var$SHA512_W_L[i - 16]);\n const SUMh = $eDgKs.default.add4H(SUMl, s0h, s1h, $2579977b4e52adba$var$SHA512_W_H[i - 7], $2579977b4e52adba$var$SHA512_W_H[i - 16]);\n $2579977b4e52adba$var$SHA512_W_H[i] = SUMh | 0;\n $2579977b4e52adba$var$SHA512_W_L[i] = SUMl | 0;\n }\n let { Ah: Ah, Al: Al, Bh: Bh, Bl: Bl, Ch: Ch, Cl: Cl, Dh: Dh, Dl: Dl, Eh: Eh, El: El, Fh: Fh, Fl: Fl, Gh: Gh, Gl: Gl, Hh: Hh, Hl: Hl } = this;\n // Compression function main loop, 80 rounds\n for(let i = 0; i < 80; i++){\n // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)\n const sigma1h = $eDgKs.default.rotrSH(Eh, El, 14) ^ $eDgKs.default.rotrSH(Eh, El, 18) ^ $eDgKs.default.rotrBH(Eh, El, 41);\n const sigma1l = $eDgKs.default.rotrSL(Eh, El, 14) ^ $eDgKs.default.rotrSL(Eh, El, 18) ^ $eDgKs.default.rotrBL(Eh, El, 41);\n //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const CHIh = Eh & Fh ^ ~Eh & Gh;\n const CHIl = El & Fl ^ ~El & Gl;\n // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]\n // prettier-ignore\n const T1ll = $eDgKs.default.add5L(Hl, sigma1l, CHIl, $2579977b4e52adba$var$SHA512_Kl[i], $2579977b4e52adba$var$SHA512_W_L[i]);\n const T1h = $eDgKs.default.add5H(T1ll, Hh, sigma1h, CHIh, $2579977b4e52adba$var$SHA512_Kh[i], $2579977b4e52adba$var$SHA512_W_H[i]);\n const T1l = T1ll | 0;\n // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)\n const sigma0h = $eDgKs.default.rotrSH(Ah, Al, 28) ^ $eDgKs.default.rotrBH(Ah, Al, 34) ^ $eDgKs.default.rotrBH(Ah, Al, 39);\n const sigma0l = $eDgKs.default.rotrSL(Ah, Al, 28) ^ $eDgKs.default.rotrBL(Ah, Al, 34) ^ $eDgKs.default.rotrBL(Ah, Al, 39);\n const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;\n const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;\n Hh = Gh | 0;\n Hl = Gl | 0;\n Gh = Fh | 0;\n Gl = Fl | 0;\n Fh = Eh | 0;\n Fl = El | 0;\n ({ h: Eh, l: El } = $eDgKs.default.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));\n Dh = Ch | 0;\n Dl = Cl | 0;\n Ch = Bh | 0;\n Cl = Bl | 0;\n Bh = Ah | 0;\n Bl = Al | 0;\n const All = $eDgKs.default.add3L(T1l, sigma0l, MAJl);\n Ah = $eDgKs.default.add3H(All, T1h, sigma0h, MAJh);\n Al = All | 0;\n }\n // Add the compressed chunk to the current hash value\n ({ h: Ah, l: Al } = $eDgKs.default.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));\n ({ h: Bh, l: Bl } = $eDgKs.default.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));\n ({ h: Ch, l: Cl } = $eDgKs.default.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));\n ({ h: Dh, l: Dl } = $eDgKs.default.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));\n ({ h: Eh, l: El } = $eDgKs.default.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));\n ({ h: Fh, l: Fl } = $eDgKs.default.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));\n ({ h: Gh, l: Gl } = $eDgKs.default.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));\n ({ h: Hh, l: Hl } = $eDgKs.default.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));\n this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);\n }\n roundClean() {\n $2579977b4e52adba$var$SHA512_W_H.fill(0);\n $2579977b4e52adba$var$SHA512_W_L.fill(0);\n }\n destroy() {\n this.buffer.fill(0);\n this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n }\n}\nmodule.exports.SHA512 = $2579977b4e52adba$var$SHA512;\nclass $2579977b4e52adba$var$SHA512_224 extends $2579977b4e52adba$var$SHA512 {\n constructor(){\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = -1942145080;\n this.Al = 424955298;\n this.Bh = 1944164710;\n this.Bl = -1982016298;\n this.Ch = 502970286;\n this.Cl = 855612546;\n this.Dh = 1738396948;\n this.Dl = 1479516111;\n this.Eh = 258812777;\n this.El = 2077511080;\n this.Fh = 2011393907;\n this.Fl = 79989058;\n this.Gh = 1067287976;\n this.Gl = 1780299464;\n this.Hh = 286451373;\n this.Hl = -1848208735;\n this.outputLen = 28;\n }\n}\nmodule.exports.SHA512_224 = $2579977b4e52adba$var$SHA512_224;\nclass $2579977b4e52adba$var$SHA512_256 extends $2579977b4e52adba$var$SHA512 {\n constructor(){\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 573645204;\n this.Al = -64227540;\n this.Bh = -1621794909;\n this.Bl = -934517566;\n this.Ch = 596883563;\n this.Cl = 1867755857;\n this.Dh = -1774684391;\n this.Dl = 1497426621;\n this.Eh = -1775747358;\n this.El = -1467023389;\n this.Fh = -1101128155;\n this.Fl = 1401305490;\n this.Gh = 721525244;\n this.Gl = 746961066;\n this.Hh = 246885852;\n this.Hl = -2117784414;\n this.outputLen = 32;\n }\n}\nmodule.exports.SHA512_256 = $2579977b4e52adba$var$SHA512_256;\nclass $2579977b4e52adba$var$SHA384 extends $2579977b4e52adba$var$SHA512 {\n constructor(){\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = -876896931;\n this.Al = -1056596264;\n this.Bh = 1654270250;\n this.Bl = 914150663;\n this.Ch = -1856437926;\n this.Cl = 812702999;\n this.Dh = 355462360;\n this.Dl = -150054599;\n this.Eh = 1731405415;\n this.El = -4191439;\n this.Fh = -1900787065;\n this.Fl = 1750603025;\n this.Gh = -619958771;\n this.Gl = 1694076839;\n this.Hh = 1203062813;\n this.Hl = -1090891868;\n this.outputLen = 48;\n }\n}\nmodule.exports.SHA384 = $2579977b4e52adba$var$SHA384;\n/** SHA2-512 hash function. */ module.exports.sha512 = (0, $3Bcdj.wrapConstructor)(()=>new $2579977b4e52adba$var$SHA512());\n/** SHA2-512/224 \"truncated\" hash function, with improved resistance to length extension attacks. */ module.exports.sha512_224 = (0, $3Bcdj.wrapConstructor)(()=>new $2579977b4e52adba$var$SHA512_224());\n/** SHA2-512/256 \"truncated\" hash function, with improved resistance to length extension attacks. */ module.exports.sha512_256 = (0, $3Bcdj.wrapConstructor)(()=>new $2579977b4e52adba$var$SHA512_256());\n/** SHA2-384 hash function. */ module.exports.sha384 = (0, $3Bcdj.wrapConstructor)(()=>new $2579977b4e52adba$var$SHA384());\n\n});\nparcelRegister(\"iYRTw\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.HashMD = void 0;\nmodule.exports.setBigUint64 = $dd17a2ee919821c7$var$setBigUint64;\nmodule.exports.Chi = $dd17a2ee919821c7$var$Chi;\nmodule.exports.Maj = $dd17a2ee919821c7$var$Maj;\n\nvar $dNiq9 = parcelRequire(\"dNiq9\");\n\nvar $3Bcdj = parcelRequire(\"3Bcdj\");\n/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */ function $dd17a2ee919821c7$var$setBigUint64(view, byteOffset, value, isLE) {\n if (typeof view.setBigUint64 === 'function') return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number(value >> _32n & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n/** Choice: a ? b : c */ function $dd17a2ee919821c7$var$Chi(a, b, c) {\n return a & b ^ ~a & c;\n}\n/** Majority function, true if any two inputs is true. */ function $dd17a2ee919821c7$var$Maj(a, b, c) {\n return a & b ^ a & c ^ b & c;\n}\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */ class $dd17a2ee919821c7$var$HashMD extends $3Bcdj.Hash {\n constructor(blockLen, outputLen, padOffset, isLE){\n super();\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.finished = false;\n this.length = 0;\n this.pos = 0;\n this.destroyed = false;\n this.buffer = new Uint8Array(blockLen);\n this.view = (0, $3Bcdj.createView)(this.buffer);\n }\n update(data) {\n (0, $dNiq9.aexists)(this);\n const { view: view, buffer: buffer, blockLen: blockLen } = this;\n data = (0, $3Bcdj.toBytes)(data);\n const len = data.length;\n for(let pos = 0; pos < len;){\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = (0, $3Bcdj.createView)(data);\n for(; blockLen <= len - pos; pos += blockLen)this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out) {\n (0, $dNiq9.aexists)(this);\n (0, $dNiq9.aoutput)(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer: buffer, view: view, blockLen: blockLen, isLE: isLE } = this;\n let { pos: pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 128;\n this.buffer.subarray(pos).fill(0);\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for(let i = pos; i < blockLen; i++)buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n $dd17a2ee919821c7$var$setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = (0, $3Bcdj.createView)(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4) throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length) throw new Error('_sha2: outputLen bigger than state');\n for(let i = 0; i < outLen; i++)oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer: buffer, outputLen: outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to) {\n to || (to = new this.constructor());\n to.set(...this.get());\n const { blockLen: blockLen, buffer: buffer, length: length, finished: finished, destroyed: destroyed, pos: pos } = this;\n to.length = length;\n to.pos = pos;\n to.finished = finished;\n to.destroyed = destroyed;\n if (length % blockLen) to.buffer.set(buffer);\n return to;\n }\n}\nmodule.exports.HashMD = $dd17a2ee919821c7$var$HashMD;\n\n});\nparcelRegister(\"dNiq9\", function(module, exports) {\n\"use strict\";\n/**\n * Internal assertion helpers.\n * @module\n */ Object.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.anumber = $a0ae23f5901291b4$var$anumber;\nmodule.exports.abytes = $a0ae23f5901291b4$var$abytes;\nmodule.exports.ahash = $a0ae23f5901291b4$var$ahash;\nmodule.exports.aexists = $a0ae23f5901291b4$var$aexists;\nmodule.exports.aoutput = $a0ae23f5901291b4$var$aoutput;\n/** Asserts something is positive integer. */ function $a0ae23f5901291b4$var$anumber(n) {\n if (!Number.isSafeInteger(n) || n < 0) throw new Error('positive integer expected, got ' + n);\n}\n/** Is number an Uint8Array? Copied from utils for perf. */ function $a0ae23f5901291b4$var$isBytes(a) {\n return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array';\n}\n/** Asserts something is Uint8Array. */ function $a0ae23f5901291b4$var$abytes(b, ...lengths) {\n if (!$a0ae23f5901291b4$var$isBytes(b)) throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length)) throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\n/** Asserts something is hash */ function $a0ae23f5901291b4$var$ahash(h) {\n if (typeof h !== 'function' || typeof h.create !== 'function') throw new Error('Hash should be wrapped by utils.wrapConstructor');\n $a0ae23f5901291b4$var$anumber(h.outputLen);\n $a0ae23f5901291b4$var$anumber(h.blockLen);\n}\n/** Asserts a hash instance has not been destroyed / finished */ function $a0ae23f5901291b4$var$aexists(instance, checkFinished = true) {\n if (instance.destroyed) throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called');\n}\n/** Asserts output is properly-sized byte array */ function $a0ae23f5901291b4$var$aoutput(out, instance) {\n $a0ae23f5901291b4$var$abytes(out);\n const min = instance.outputLen;\n if (out.length < min) throw new Error('digestInto() expects output buffer of length at least ' + min);\n}\n\n});\n\nparcelRegister(\"3Bcdj\", function(module, exports) {\n\"use strict\";\n/**\n * Utilities for hex, bytes, CSPRNG.\n * @module\n */ /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */ Object.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.Hash = module.exports.nextTick = module.exports.byteSwapIfBE = module.exports.isLE = void 0;\nmodule.exports.isBytes = $29ee4d3171d9809b$var$isBytes;\nmodule.exports.u8 = $29ee4d3171d9809b$var$u8;\nmodule.exports.u32 = $29ee4d3171d9809b$var$u32;\nmodule.exports.createView = $29ee4d3171d9809b$var$createView;\nmodule.exports.rotr = $29ee4d3171d9809b$var$rotr;\nmodule.exports.rotl = $29ee4d3171d9809b$var$rotl;\nmodule.exports.byteSwap = $29ee4d3171d9809b$var$byteSwap;\nmodule.exports.byteSwap32 = $29ee4d3171d9809b$var$byteSwap32;\nmodule.exports.bytesToHex = $29ee4d3171d9809b$var$bytesToHex;\nmodule.exports.hexToBytes = $29ee4d3171d9809b$var$hexToBytes;\nmodule.exports.asyncLoop = $29ee4d3171d9809b$var$asyncLoop;\nmodule.exports.utf8ToBytes = $29ee4d3171d9809b$var$utf8ToBytes;\nmodule.exports.toBytes = $29ee4d3171d9809b$var$toBytes;\nmodule.exports.concatBytes = $29ee4d3171d9809b$var$concatBytes;\nmodule.exports.checkOpts = $29ee4d3171d9809b$var$checkOpts;\nmodule.exports.wrapConstructor = $29ee4d3171d9809b$var$wrapConstructor;\nmodule.exports.wrapConstructorWithOpts = $29ee4d3171d9809b$var$wrapConstructorWithOpts;\nmodule.exports.wrapXOFConstructorWithOpts = $29ee4d3171d9809b$var$wrapXOFConstructorWithOpts;\nmodule.exports.randomBytes = $29ee4d3171d9809b$var$randomBytes;\n\nvar $dUxV2 = parcelRequire(\"dUxV2\");\n\nvar $dNiq9 = parcelRequire(\"dNiq9\");\n// export { isBytes } from './_assert.js';\n// We can't reuse isBytes from _assert, because somehow this causes huge perf issues\nfunction $29ee4d3171d9809b$var$isBytes(a) {\n return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array';\n}\n// Cast array to different type\nfunction $29ee4d3171d9809b$var$u8(arr) {\n return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\n}\nfunction $29ee4d3171d9809b$var$u32(arr) {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\n// Cast array to view\nfunction $29ee4d3171d9809b$var$createView(arr) {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/** The rotate right (circular right shift) operation for uint32 */ function $29ee4d3171d9809b$var$rotr(word, shift) {\n return word << 32 - shift | word >>> shift;\n}\n/** The rotate left (circular left shift) operation for uint32 */ function $29ee4d3171d9809b$var$rotl(word, shift) {\n return word << shift | word >>> 32 - shift >>> 0;\n}\n/** Is current platform little-endian? Most are. Big-Endian platform: IBM */ module.exports.isLE = (()=>new Uint8Array(new Uint32Array([\n 0x11223344\n ]).buffer)[0] === 0x44)();\n// The byte swap operation for uint32\nfunction $29ee4d3171d9809b$var$byteSwap(word) {\n return word << 24 & 0xff000000 | word << 8 & 0xff0000 | word >>> 8 & 0xff00 | word >>> 24 & 0xff;\n}\n/** Conditionally byte swap if on a big-endian platform */ module.exports.byteSwapIfBE = module.exports.isLE ? (n)=>n : (n)=>$29ee4d3171d9809b$var$byteSwap(n);\n/** In place byte swap for Uint32Array */ function $29ee4d3171d9809b$var$byteSwap32(arr) {\n for(let i = 0; i < arr.length; i++)arr[i] = $29ee4d3171d9809b$var$byteSwap(arr[i]);\n}\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst $29ee4d3171d9809b$var$hexes = /* @__PURE__ */ Array.from({\n length: 256\n}, (_, i)=>i.toString(16).padStart(2, '0'));\n/**\n * Convert byte array to hex string.\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */ function $29ee4d3171d9809b$var$bytesToHex(bytes) {\n (0, $dNiq9.abytes)(bytes);\n // pre-caching improves the speed 6x\n let hex = '';\n for(let i = 0; i < bytes.length; i++)hex += $29ee4d3171d9809b$var$hexes[bytes[i]];\n return hex;\n}\n// We use optimized technique to convert hex string to byte array\nconst $29ee4d3171d9809b$var$asciis = {\n _0: 48,\n _9: 57,\n A: 65,\n F: 70,\n a: 97,\n f: 102\n};\nfunction $29ee4d3171d9809b$var$asciiToBase16(ch) {\n if (ch >= $29ee4d3171d9809b$var$asciis._0 && ch <= $29ee4d3171d9809b$var$asciis._9) return ch - $29ee4d3171d9809b$var$asciis._0; // '2' => 50-48\n if (ch >= $29ee4d3171d9809b$var$asciis.A && ch <= $29ee4d3171d9809b$var$asciis.F) return ch - ($29ee4d3171d9809b$var$asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= $29ee4d3171d9809b$var$asciis.a && ch <= $29ee4d3171d9809b$var$asciis.f) return ch - ($29ee4d3171d9809b$var$asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n/**\n * Convert hex string to byte array.\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */ function $29ee4d3171d9809b$var$hexToBytes(hex) {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2) throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for(let ai = 0, hi = 0; ai < al; ai++, hi += 2){\n const n1 = $29ee4d3171d9809b$var$asciiToBase16(hex.charCodeAt(hi));\n const n2 = $29ee4d3171d9809b$var$asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n/**\n * There is no setImmediate in browser and setTimeout is slow.\n * Call of async fn will return Promise, which will be fullfiled only on\n * next scheduler queue processing step and this is exactly what we need.\n */ const $29ee4d3171d9809b$var$nextTick = async ()=>{};\nmodule.exports.nextTick = $29ee4d3171d9809b$var$nextTick;\n/** Returns control to thread each 'tick' ms to avoid blocking. */ async function $29ee4d3171d9809b$var$asyncLoop(iters, tick, cb) {\n let ts = Date.now();\n for(let i = 0; i < iters; i++){\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick) continue;\n await (0, module.exports.nextTick)();\n ts += diff;\n }\n}\n/**\n * Convert JS string to byte array.\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */ function $29ee4d3171d9809b$var$utf8ToBytes(str) {\n if (typeof str !== 'string') throw new Error('utf8ToBytes expected string, got ' + typeof str);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */ function $29ee4d3171d9809b$var$toBytes(data) {\n if (typeof data === 'string') data = $29ee4d3171d9809b$var$utf8ToBytes(data);\n (0, $dNiq9.abytes)(data);\n return data;\n}\n/**\n * Copies several Uint8Arrays into one.\n */ function $29ee4d3171d9809b$var$concatBytes(...arrays) {\n let sum = 0;\n for(let i = 0; i < arrays.length; i++){\n const a = arrays[i];\n (0, $dNiq9.abytes)(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for(let i = 0, pad = 0; i < arrays.length; i++){\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n/** For runtime check if class implements interface */ class $29ee4d3171d9809b$var$Hash {\n // Safe version that clones internal state\n clone() {\n return this._cloneInto();\n }\n}\nmodule.exports.Hash = $29ee4d3171d9809b$var$Hash;\nfunction $29ee4d3171d9809b$var$checkOpts(defaults, opts) {\n if (opts !== undefined && ({}).toString.call(opts) !== '[object Object]') throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged;\n}\n/** Wraps hash function, creating an interface on top of it */ function $29ee4d3171d9809b$var$wrapConstructor(hashCons) {\n const hashC = (msg)=>hashCons().update($29ee4d3171d9809b$var$toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = ()=>hashCons();\n return hashC;\n}\nfunction $29ee4d3171d9809b$var$wrapConstructorWithOpts(hashCons) {\n const hashC = (msg, opts)=>hashCons(opts).update($29ee4d3171d9809b$var$toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts)=>hashCons(opts);\n return hashC;\n}\nfunction $29ee4d3171d9809b$var$wrapXOFConstructorWithOpts(hashCons) {\n const hashC = (msg, opts)=>hashCons(opts).update($29ee4d3171d9809b$var$toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts)=>hashCons(opts);\n return hashC;\n}\n/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */ function $29ee4d3171d9809b$var$randomBytes(bytesLength = 32) {\n if ($dUxV2.crypto && typeof $dUxV2.crypto.getRandomValues === 'function') return $dUxV2.crypto.getRandomValues(new Uint8Array(bytesLength));\n // Legacy Node.js compatibility\n if ($dUxV2.crypto && typeof $dUxV2.crypto.randomBytes === 'function') return $dUxV2.crypto.randomBytes(bytesLength);\n throw new Error('crypto.getRandomValues must be defined');\n}\n\n});\nparcelRegister(\"dUxV2\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.crypto = void 0;\nmodule.exports.crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;\n\n});\n\n\n\nparcelRegister(\"eDgKs\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.add5L = module.exports.add5H = module.exports.add4H = module.exports.add4L = module.exports.add3H = module.exports.add3L = module.exports.rotlBL = module.exports.rotlBH = module.exports.rotlSL = module.exports.rotlSH = module.exports.rotr32L = module.exports.rotr32H = module.exports.rotrBL = module.exports.rotrBH = module.exports.rotrSL = module.exports.rotrSH = module.exports.shrSL = module.exports.shrSH = module.exports.toBig = void 0;\nmodule.exports.fromBig = $aa71b30d36adb919$var$fromBig;\nmodule.exports.split = $aa71b30d36adb919$var$split;\nmodule.exports.add = $aa71b30d36adb919$var$add;\n/**\n * Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.\n * @todo re-check https://issues.chromium.org/issues/42212588\n * @module\n */ const $aa71b30d36adb919$var$U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);\nconst $aa71b30d36adb919$var$_32n = /* @__PURE__ */ BigInt(32);\nfunction $aa71b30d36adb919$var$fromBig(n, le = false) {\n if (le) return {\n h: Number(n & $aa71b30d36adb919$var$U32_MASK64),\n l: Number(n >> $aa71b30d36adb919$var$_32n & $aa71b30d36adb919$var$U32_MASK64)\n };\n return {\n h: Number(n >> $aa71b30d36adb919$var$_32n & $aa71b30d36adb919$var$U32_MASK64) | 0,\n l: Number(n & $aa71b30d36adb919$var$U32_MASK64) | 0\n };\n}\nfunction $aa71b30d36adb919$var$split(lst, le = false) {\n let Ah = new Uint32Array(lst.length);\n let Al = new Uint32Array(lst.length);\n for(let i = 0; i < lst.length; i++){\n const { h: h, l: l } = $aa71b30d36adb919$var$fromBig(lst[i], le);\n [Ah[i], Al[i]] = [\n h,\n l\n ];\n }\n return [\n Ah,\n Al\n ];\n}\nconst $aa71b30d36adb919$var$toBig = (h, l)=>BigInt(h >>> 0) << $aa71b30d36adb919$var$_32n | BigInt(l >>> 0);\nmodule.exports.toBig = $aa71b30d36adb919$var$toBig;\n// for Shift in [0, 32)\nconst $aa71b30d36adb919$var$shrSH = (h, _l, s)=>h >>> s;\nmodule.exports.shrSH = $aa71b30d36adb919$var$shrSH;\nconst $aa71b30d36adb919$var$shrSL = (h, l, s)=>h << 32 - s | l >>> s;\nmodule.exports.shrSL = $aa71b30d36adb919$var$shrSL;\n// Right rotate for Shift in [1, 32)\nconst $aa71b30d36adb919$var$rotrSH = (h, l, s)=>h >>> s | l << 32 - s;\nmodule.exports.rotrSH = $aa71b30d36adb919$var$rotrSH;\nconst $aa71b30d36adb919$var$rotrSL = (h, l, s)=>h << 32 - s | l >>> s;\nmodule.exports.rotrSL = $aa71b30d36adb919$var$rotrSL;\n// Right rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst $aa71b30d36adb919$var$rotrBH = (h, l, s)=>h << 64 - s | l >>> s - 32;\nmodule.exports.rotrBH = $aa71b30d36adb919$var$rotrBH;\nconst $aa71b30d36adb919$var$rotrBL = (h, l, s)=>h >>> s - 32 | l << 64 - s;\nmodule.exports.rotrBL = $aa71b30d36adb919$var$rotrBL;\n// Right rotate for shift===32 (just swaps l&h)\nconst $aa71b30d36adb919$var$rotr32H = (_h, l)=>l;\nmodule.exports.rotr32H = $aa71b30d36adb919$var$rotr32H;\nconst $aa71b30d36adb919$var$rotr32L = (h, _l)=>h;\nmodule.exports.rotr32L = $aa71b30d36adb919$var$rotr32L;\n// Left rotate for Shift in [1, 32)\nconst $aa71b30d36adb919$var$rotlSH = (h, l, s)=>h << s | l >>> 32 - s;\nmodule.exports.rotlSH = $aa71b30d36adb919$var$rotlSH;\nconst $aa71b30d36adb919$var$rotlSL = (h, l, s)=>l << s | h >>> 32 - s;\nmodule.exports.rotlSL = $aa71b30d36adb919$var$rotlSL;\n// Left rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst $aa71b30d36adb919$var$rotlBH = (h, l, s)=>l << s - 32 | h >>> 64 - s;\nmodule.exports.rotlBH = $aa71b30d36adb919$var$rotlBH;\nconst $aa71b30d36adb919$var$rotlBL = (h, l, s)=>h << s - 32 | l >>> 64 - s;\nmodule.exports.rotlBL = $aa71b30d36adb919$var$rotlBL;\n// JS uses 32-bit signed integers for bitwise operations which means we cannot\n// simple take carry out of low bit sum by shift, we need to use division.\nfunction $aa71b30d36adb919$var$add(Ah, Al, Bh, Bl) {\n const l = (Al >>> 0) + (Bl >>> 0);\n return {\n h: Ah + Bh + (l / 2 ** 32 | 0) | 0,\n l: l | 0\n };\n}\n// Addition with more than 2 elements\nconst $aa71b30d36adb919$var$add3L = (Al, Bl, Cl)=>(Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);\nmodule.exports.add3L = $aa71b30d36adb919$var$add3L;\nconst $aa71b30d36adb919$var$add3H = (low, Ah, Bh, Ch)=>Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;\nmodule.exports.add3H = $aa71b30d36adb919$var$add3H;\nconst $aa71b30d36adb919$var$add4L = (Al, Bl, Cl, Dl)=>(Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);\nmodule.exports.add4L = $aa71b30d36adb919$var$add4L;\nconst $aa71b30d36adb919$var$add4H = (low, Ah, Bh, Ch, Dh)=>Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;\nmodule.exports.add4H = $aa71b30d36adb919$var$add4H;\nconst $aa71b30d36adb919$var$add5L = (Al, Bl, Cl, Dl, El)=>(Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);\nmodule.exports.add5L = $aa71b30d36adb919$var$add5L;\nconst $aa71b30d36adb919$var$add5H = (low, Ah, Bh, Ch, Dh, Eh)=>Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;\nmodule.exports.add5H = $aa71b30d36adb919$var$add5H;\n// prettier-ignore\nconst $aa71b30d36adb919$var$u64 = {\n fromBig: $aa71b30d36adb919$var$fromBig,\n split: $aa71b30d36adb919$var$split,\n toBig: $aa71b30d36adb919$var$toBig,\n shrSH: $aa71b30d36adb919$var$shrSH,\n shrSL: $aa71b30d36adb919$var$shrSL,\n rotrSH: $aa71b30d36adb919$var$rotrSH,\n rotrSL: $aa71b30d36adb919$var$rotrSL,\n rotrBH: $aa71b30d36adb919$var$rotrBH,\n rotrBL: $aa71b30d36adb919$var$rotrBL,\n rotr32H: $aa71b30d36adb919$var$rotr32H,\n rotr32L: $aa71b30d36adb919$var$rotr32L,\n rotlSH: $aa71b30d36adb919$var$rotlSH,\n rotlSL: $aa71b30d36adb919$var$rotlSL,\n rotlBH: $aa71b30d36adb919$var$rotlBH,\n rotlBL: $aa71b30d36adb919$var$rotlBL,\n add: $aa71b30d36adb919$var$add,\n add3L: $aa71b30d36adb919$var$add3L,\n add3H: $aa71b30d36adb919$var$add3H,\n add4L: $aa71b30d36adb919$var$add4L,\n add4H: $aa71b30d36adb919$var$add4H,\n add5H: $aa71b30d36adb919$var$add5H,\n add5L: $aa71b30d36adb919$var$add5L\n};\nmodule.exports.default = $aa71b30d36adb919$var$u64;\n\n});\n\n\nparcelRegister(\"lkFCe\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.wNAF = wNAF;\nexports.pippenger = pippenger;\nexports.precomputeMSMUnsafe = precomputeMSMUnsafe;\nexports.validateBasic = validateBasic;\n\nvar $2D9sF = parcelRequire(\"2D9sF\");\n\nvar $esaJO = parcelRequire(\"esaJO\");\nconst _0n = BigInt(0);\nconst _1n = BigInt(1);\nfunction constTimeNegate(condition, item) {\n const neg = item.negate();\n return condition ? neg : item;\n}\nfunction validateW(W, bits) {\n if (!Number.isSafeInteger(W) || W <= 0 || W > bits) throw new Error('invalid window size, expected [1..' + bits + '], got W=' + W);\n}\nfunction calcWOpts(W, bits) {\n validateW(W, bits);\n const windows = Math.ceil(bits / W) + 1; // +1, because\n const windowSize = 2 ** (W - 1); // -1 because we skip zero\n return {\n windows: windows,\n windowSize: windowSize\n };\n}\nfunction validateMSMPoints(points, c) {\n if (!Array.isArray(points)) throw new Error('array expected');\n points.forEach((p, i)=>{\n if (!(p instanceof c)) throw new Error('invalid point at index ' + i);\n });\n}\nfunction validateMSMScalars(scalars, field) {\n if (!Array.isArray(scalars)) throw new Error('array of scalars expected');\n scalars.forEach((s, i)=>{\n if (!field.isValid(s)) throw new Error('invalid scalar at index ' + i);\n });\n}\n// Since points in different groups cannot be equal (different object constructor),\n// we can have single place to store precomputes\nconst pointPrecomputes = new WeakMap();\nconst pointWindowSizes = new WeakMap(); // This allows use make points immutable (nothing changes inside)\nfunction getW(P) {\n return pointWindowSizes.get(P) || 1;\n}\n/**\n * Elliptic curve multiplication of Point by scalar. Fragile.\n * Scalars should always be less than curve order: this should be checked inside of a curve itself.\n * Creates precomputation tables for fast multiplication:\n * - private scalar is split by fixed size windows of W bits\n * - every window point is collected from window's table & added to accumulator\n * - since windows are different, same point inside tables won't be accessed more than once per calc\n * - each multiplication is 'Math.ceil(CURVE_ORDER / 𝑊) + 1' point additions (fixed for any scalar)\n * - +1 window is neccessary for wNAF\n * - wNAF reduces table size: 2x less memory + 2x faster generation, but 10% slower multiplication\n *\n * @todo Research returning 2d JS array of windows, instead of a single window.\n * This would allow windows to be in different memory locations\n */ function wNAF(c, bits) {\n return {\n constTimeNegate: constTimeNegate,\n hasPrecomputes (elm) {\n return getW(elm) !== 1;\n },\n // non-const time multiplication ladder\n unsafeLadder (elm, n, p = c.ZERO) {\n let d = elm;\n while(n > _0n){\n if (n & _1n) p = p.add(d);\n d = d.double();\n n >>= _1n;\n }\n return p;\n },\n /**\n * Creates a wNAF precomputation window. Used for caching.\n * Default window size is set by `utils.precompute()` and is equal to 8.\n * Number of precomputed points depends on the curve size:\n * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:\n * - 𝑊 is the window size\n * - 𝑛 is the bitlength of the curve order.\n * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.\n * @param elm Point instance\n * @param W window size\n * @returns precomputed point tables flattened to a single array\n */ precomputeWindow (elm, W) {\n const { windows, windowSize } = calcWOpts(W, bits);\n const points = [];\n let p = elm;\n let base = p;\n for(let window = 0; window < windows; window++){\n base = p;\n points.push(base);\n // =1, because we skip zero\n for(let i = 1; i < windowSize; i++){\n base = base.add(p);\n points.push(base);\n }\n p = base.double();\n }\n return points;\n },\n /**\n * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.\n * @param W window size\n * @param precomputes precomputed tables\n * @param n scalar (we don't check here, but should be less than curve order)\n * @returns real and fake (for const-time) points\n */ wNAF (W, precomputes, n) {\n // TODO: maybe check that scalar is less than group order? wNAF behavious is undefined otherwise\n // But need to carefully remove other checks before wNAF. ORDER == bits here\n const { windows, windowSize } = calcWOpts(W, bits);\n let p = c.ZERO;\n let f = c.BASE;\n const mask = BigInt(2 ** W - 1); // Create mask with W ones: 0b1111 for W=4 etc.\n const maxNumber = 2 ** W;\n const shiftBy = BigInt(W);\n for(let window = 0; window < windows; window++){\n const offset = window * windowSize;\n // Extract W bits.\n let wbits = Number(n & mask);\n // Shift number by W bits.\n n >>= shiftBy;\n // If the bits are bigger than max size, we'll split those.\n // +224 => 256 - 32\n if (wbits > windowSize) {\n wbits -= maxNumber;\n n += _1n;\n }\n // This code was first written with assumption that 'f' and 'p' will never be infinity point:\n // since each addition is multiplied by 2 ** W, it cannot cancel each other. However,\n // there is negate now: it is possible that negated element from low value\n // would be the same as high element, which will create carry into next window.\n // It's not obvious how this can fail, but still worth investigating later.\n // Check if we're onto Zero point.\n // Add random point inside current window to f.\n const offset1 = offset;\n const offset2 = offset + Math.abs(wbits) - 1; // -1 because we skip zero\n const cond1 = window % 2 !== 0;\n const cond2 = wbits < 0;\n if (wbits === 0) // The most important part for const-time getPublicKey\n f = f.add(constTimeNegate(cond1, precomputes[offset1]));\n else p = p.add(constTimeNegate(cond2, precomputes[offset2]));\n }\n // JIT-compiler should not eliminate f here, since it will later be used in normalizeZ()\n // Even if the variable is still unused, there are some checks which will\n // throw an exception, so compiler needs to prove they won't happen, which is hard.\n // At this point there is a way to F be infinity-point even if p is not,\n // which makes it less const-time: around 1 bigint multiply.\n return {\n p: p,\n f: f\n };\n },\n /**\n * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.\n * @param W window size\n * @param precomputes precomputed tables\n * @param n scalar (we don't check here, but should be less than curve order)\n * @param acc accumulator point to add result of multiplication\n * @returns point\n */ wNAFUnsafe (W, precomputes, n, acc = c.ZERO) {\n const { windows, windowSize } = calcWOpts(W, bits);\n const mask = BigInt(2 ** W - 1); // Create mask with W ones: 0b1111 for W=4 etc.\n const maxNumber = 2 ** W;\n const shiftBy = BigInt(W);\n for(let window = 0; window < windows; window++){\n const offset = window * windowSize;\n if (n === _0n) break; // No need to go over empty scalar\n // Extract W bits.\n let wbits = Number(n & mask);\n // Shift number by W bits.\n n >>= shiftBy;\n // If the bits are bigger than max size, we'll split those.\n // +224 => 256 - 32\n if (wbits > windowSize) {\n wbits -= maxNumber;\n n += _1n;\n }\n if (wbits === 0) continue;\n let curr = precomputes[offset + Math.abs(wbits) - 1]; // -1 because we skip zero\n if (wbits < 0) curr = curr.negate();\n // NOTE: by re-using acc, we can save a lot of additions in case of MSM\n acc = acc.add(curr);\n }\n return acc;\n },\n getPrecomputes (W, P, transform) {\n // Calculate precomputes on a first run, reuse them after\n let comp = pointPrecomputes.get(P);\n if (!comp) {\n comp = this.precomputeWindow(P, W);\n if (W !== 1) pointPrecomputes.set(P, transform(comp));\n }\n return comp;\n },\n wNAFCached (P, n, transform) {\n const W = getW(P);\n return this.wNAF(W, this.getPrecomputes(W, P, transform), n);\n },\n wNAFCachedUnsafe (P, n, transform, prev) {\n const W = getW(P);\n if (W === 1) return this.unsafeLadder(P, n, prev); // For W=1 ladder is ~x2 faster\n return this.wNAFUnsafe(W, this.getPrecomputes(W, P, transform), n, prev);\n },\n // We calculate precomputes for elliptic curve point multiplication\n // using windowed method. This specifies window size and\n // stores precomputed values. Usually only base point would be precomputed.\n setWindowSize (P, W) {\n validateW(W, bits);\n pointWindowSizes.set(P, W);\n pointPrecomputes.delete(P);\n }\n };\n}\n/**\n * Pippenger algorithm for multi-scalar multiplication (MSM, Pa + Qb + Rc + ...).\n * 30x faster vs naive addition on L=4096, 10x faster with precomputes.\n * For N=254bit, L=1, it does: 1024 ADD + 254 DBL. For L=5: 1536 ADD + 254 DBL.\n * Algorithmically constant-time (for same L), even when 1 point + scalar, or when scalar = 0.\n * @param c Curve Point constructor\n * @param fieldN field over CURVE.N - important that it's not over CURVE.P\n * @param points array of L curve points\n * @param scalars array of L scalars (aka private keys / bigints)\n */ function pippenger(c, fieldN, points, scalars) {\n // If we split scalars by some window (let's say 8 bits), every chunk will only\n // take 256 buckets even if there are 4096 scalars, also re-uses double.\n // TODO:\n // - https://eprint.iacr.org/2024/750.pdf\n // - https://tches.iacr.org/index.php/TCHES/article/view/10287\n // 0 is accepted in scalars\n validateMSMPoints(points, c);\n validateMSMScalars(scalars, fieldN);\n if (points.length !== scalars.length) throw new Error('arrays of points and scalars must have equal length');\n const zero = c.ZERO;\n const wbits = (0, $esaJO.bitLen)(BigInt(points.length));\n const windowSize = wbits > 12 ? wbits - 3 : wbits > 4 ? wbits - 2 : wbits ? 2 : 1; // in bits\n const MASK = (1 << windowSize) - 1;\n const buckets = new Array(MASK + 1).fill(zero); // +1 for zero array\n const lastBits = Math.floor((fieldN.BITS - 1) / windowSize) * windowSize;\n let sum = zero;\n for(let i = lastBits; i >= 0; i -= windowSize){\n buckets.fill(zero);\n for(let j = 0; j < scalars.length; j++){\n const scalar = scalars[j];\n const wbits = Number(scalar >> BigInt(i) & BigInt(MASK));\n buckets[wbits] = buckets[wbits].add(points[j]);\n }\n let resI = zero; // not using this will do small speed-up, but will lose ct\n // Skip first bucket, because it is zero\n for(let j = buckets.length - 1, sumI = zero; j > 0; j--){\n sumI = sumI.add(buckets[j]);\n resI = resI.add(sumI);\n }\n sum = sum.add(resI);\n if (i !== 0) for(let j = 0; j < windowSize; j++)sum = sum.double();\n }\n return sum;\n}\n/**\n * Precomputed multi-scalar multiplication (MSM, Pa + Qb + Rc + ...).\n * @param c Curve Point constructor\n * @param fieldN field over CURVE.N - important that it's not over CURVE.P\n * @param points array of L curve points\n * @returns function which multiplies points with scaars\n */ function precomputeMSMUnsafe(c, fieldN, points, windowSize) {\n /**\n * Performance Analysis of Window-based Precomputation\n *\n * Base Case (256-bit scalar, 8-bit window):\n * - Standard precomputation requires:\n * - 31 additions per scalar × 256 scalars = 7,936 ops\n * - Plus 255 summary additions = 8,191 total ops\n * Note: Summary additions can be optimized via accumulator\n *\n * Chunked Precomputation Analysis:\n * - Using 32 chunks requires:\n * - 255 additions per chunk\n * - 256 doublings\n * - Total: (255 × 32) + 256 = 8,416 ops\n *\n * Memory Usage Comparison:\n * Window Size | Standard Points | Chunked Points\n * ------------|-----------------|---------------\n * 4-bit | 520 | 15\n * 8-bit | 4,224 | 255\n * 10-bit | 13,824 | 1,023\n * 16-bit | 557,056 | 65,535\n *\n * Key Advantages:\n * 1. Enables larger window sizes due to reduced memory overhead\n * 2. More efficient for smaller scalar counts:\n * - 16 chunks: (16 × 255) + 256 = 4,336 ops\n * - ~2x faster than standard 8,191 ops\n *\n * Limitations:\n * - Not suitable for plain precomputes (requires 256 constant doublings)\n * - Performance degrades with larger scalar counts:\n * - Optimal for ~256 scalars\n * - Less efficient for 4096+ scalars (Pippenger preferred)\n */ validateW(windowSize, fieldN.BITS);\n validateMSMPoints(points, c);\n const zero = c.ZERO;\n const tableSize = 2 ** windowSize - 1; // table size (without zero)\n const chunks = Math.ceil(fieldN.BITS / windowSize); // chunks of item\n const MASK = BigInt((1 << windowSize) - 1);\n const tables = points.map((p)=>{\n const res = [];\n for(let i = 0, acc = p; i < tableSize; i++){\n res.push(acc);\n acc = acc.add(p);\n }\n return res;\n });\n return (scalars)=>{\n validateMSMScalars(scalars, fieldN);\n if (scalars.length > points.length) throw new Error('array of scalars must be smaller than array of points');\n let res = zero;\n for(let i = 0; i < chunks; i++){\n // No need to double if accumulator is still zero.\n if (res !== zero) for(let j = 0; j < windowSize; j++)res = res.double();\n const shiftBy = BigInt(chunks * windowSize - (i + 1) * windowSize);\n for(let j = 0; j < scalars.length; j++){\n const n = scalars[j];\n const curr = Number(n >> shiftBy & MASK);\n if (!curr) continue; // skip zero scalars chunks\n res = res.add(tables[j][curr - 1]);\n }\n }\n return res;\n };\n}\nfunction validateBasic(curve) {\n (0, $2D9sF.validateField)(curve.Fp);\n (0, $esaJO.validateObject)(curve, {\n n: 'bigint',\n h: 'bigint',\n Gx: 'field',\n Gy: 'field'\n }, {\n nBitLength: 'isSafeInteger',\n nByteLength: 'isSafeInteger'\n });\n // Set defaults\n return Object.freeze({\n ...(0, $2D9sF.nLength)(curve.n, curve.nBitLength),\n ...curve,\n p: curve.Fp.ORDER\n });\n}\n\n});\nparcelRegister(\"2D9sF\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.isNegativeLE = void 0;\nmodule.exports.mod = $1ea6901afdde618b$var$mod;\nmodule.exports.pow = $1ea6901afdde618b$var$pow;\nmodule.exports.pow2 = $1ea6901afdde618b$var$pow2;\nmodule.exports.invert = $1ea6901afdde618b$var$invert;\nmodule.exports.tonelliShanks = $1ea6901afdde618b$var$tonelliShanks;\nmodule.exports.FpSqrt = $1ea6901afdde618b$var$FpSqrt;\nmodule.exports.validateField = $1ea6901afdde618b$var$validateField;\nmodule.exports.FpPow = $1ea6901afdde618b$var$FpPow;\nmodule.exports.FpInvertBatch = $1ea6901afdde618b$var$FpInvertBatch;\nmodule.exports.FpDiv = $1ea6901afdde618b$var$FpDiv;\nmodule.exports.FpLegendre = $1ea6901afdde618b$var$FpLegendre;\nmodule.exports.FpIsSquare = $1ea6901afdde618b$var$FpIsSquare;\nmodule.exports.nLength = $1ea6901afdde618b$var$nLength;\nmodule.exports.Field = $1ea6901afdde618b$var$Field;\nmodule.exports.FpSqrtOdd = $1ea6901afdde618b$var$FpSqrtOdd;\nmodule.exports.FpSqrtEven = $1ea6901afdde618b$var$FpSqrtEven;\nmodule.exports.hashToPrivateScalar = $1ea6901afdde618b$var$hashToPrivateScalar;\nmodule.exports.getFieldBytesLength = $1ea6901afdde618b$var$getFieldBytesLength;\nmodule.exports.getMinHashLength = $1ea6901afdde618b$var$getMinHashLength;\nmodule.exports.mapHashToField = $1ea6901afdde618b$var$mapHashToField;\n\nvar $esaJO = parcelRequire(\"esaJO\");\n// prettier-ignore\nconst $1ea6901afdde618b$var$_0n = BigInt(0), $1ea6901afdde618b$var$_1n = BigInt(1), $1ea6901afdde618b$var$_2n = /* @__PURE__ */ BigInt(2), $1ea6901afdde618b$var$_3n = /* @__PURE__ */ BigInt(3);\n// prettier-ignore\nconst $1ea6901afdde618b$var$_4n = /* @__PURE__ */ BigInt(4), $1ea6901afdde618b$var$_5n = /* @__PURE__ */ BigInt(5), $1ea6901afdde618b$var$_8n = /* @__PURE__ */ BigInt(8);\n// prettier-ignore\nconst $1ea6901afdde618b$var$_9n = /* @__PURE__ */ BigInt(9), $1ea6901afdde618b$var$_16n = /* @__PURE__ */ BigInt(16);\n// Calculates a modulo b\nfunction $1ea6901afdde618b$var$mod(a, b) {\n const result = a % b;\n return result >= $1ea6901afdde618b$var$_0n ? result : b + result;\n}\n/**\n * Efficiently raise num to power and do modular division.\n * Unsafe in some contexts: uses ladder, so can expose bigint bits.\n * @todo use field version && remove\n * @example\n * pow(2n, 6n, 11n) // 64n % 11n == 9n\n */ function $1ea6901afdde618b$var$pow(num, power, modulo) {\n if (power < $1ea6901afdde618b$var$_0n) throw new Error('invalid exponent, negatives unsupported');\n if (modulo <= $1ea6901afdde618b$var$_0n) throw new Error('invalid modulus');\n if (modulo === $1ea6901afdde618b$var$_1n) return $1ea6901afdde618b$var$_0n;\n let res = $1ea6901afdde618b$var$_1n;\n while(power > $1ea6901afdde618b$var$_0n){\n if (power & $1ea6901afdde618b$var$_1n) res = res * num % modulo;\n num = num * num % modulo;\n power >>= $1ea6901afdde618b$var$_1n;\n }\n return res;\n}\n/** Does `x^(2^power)` mod p. `pow2(30, 4)` == `30^(2^4)` */ function $1ea6901afdde618b$var$pow2(x, power, modulo) {\n let res = x;\n while(power-- > $1ea6901afdde618b$var$_0n){\n res *= res;\n res %= modulo;\n }\n return res;\n}\n/**\n * Inverses number over modulo.\n * Implemented using [Euclidean GCD](https://brilliant.org/wiki/extended-euclidean-algorithm/).\n */ function $1ea6901afdde618b$var$invert(number, modulo) {\n if (number === $1ea6901afdde618b$var$_0n) throw new Error('invert: expected non-zero number');\n if (modulo <= $1ea6901afdde618b$var$_0n) throw new Error('invert: expected positive modulus, got ' + modulo);\n // Fermat's little theorem \"CT-like\" version inv(n) = n^(m-2) mod m is 30x slower.\n let a = $1ea6901afdde618b$var$mod(number, modulo);\n let b = modulo;\n // prettier-ignore\n let x = $1ea6901afdde618b$var$_0n, y = $1ea6901afdde618b$var$_1n, u = $1ea6901afdde618b$var$_1n, v = $1ea6901afdde618b$var$_0n;\n while(a !== $1ea6901afdde618b$var$_0n){\n // JIT applies optimization if those two lines follow each other\n const q = b / a;\n const r = b % a;\n const m = x - u * q;\n const n = y - v * q;\n // prettier-ignore\n b = a, a = r, x = u, y = v, u = m, v = n;\n }\n const gcd = b;\n if (gcd !== $1ea6901afdde618b$var$_1n) throw new Error('invert: does not exist');\n return $1ea6901afdde618b$var$mod(x, modulo);\n}\n/**\n * Tonelli-Shanks square root search algorithm.\n * 1. https://eprint.iacr.org/2012/685.pdf (page 12)\n * 2. Square Roots from 1; 24, 51, 10 to Dan Shanks\n * Will start an infinite loop if field order P is not prime.\n * @param P field order\n * @returns function that takes field Fp (created from P) and number n\n */ function $1ea6901afdde618b$var$tonelliShanks(P) {\n // Legendre constant: used to calculate Legendre symbol (a | p),\n // which denotes the value of a^((p-1)/2) (mod p).\n // (a | p) ≡ 1 if a is a square (mod p)\n // (a | p) ≡ -1 if a is not a square (mod p)\n // (a | p) ≡ 0 if a ≡ 0 (mod p)\n const legendreC = (P - $1ea6901afdde618b$var$_1n) / $1ea6901afdde618b$var$_2n;\n let Q, S, Z;\n // Step 1: By factoring out powers of 2 from p - 1,\n // find q and s such that p - 1 = q*(2^s) with q odd\n for(Q = P - $1ea6901afdde618b$var$_1n, S = 0; Q % $1ea6901afdde618b$var$_2n === $1ea6901afdde618b$var$_0n; Q /= $1ea6901afdde618b$var$_2n, S++);\n // Step 2: Select a non-square z such that (z | p) ≡ -1 and set c ≡ zq\n for(Z = $1ea6901afdde618b$var$_2n; Z < P && $1ea6901afdde618b$var$pow(Z, legendreC, P) !== P - $1ea6901afdde618b$var$_1n; Z++){\n // Crash instead of infinity loop, we cannot reasonable count until P.\n if (Z > 1000) throw new Error('Cannot find square root: likely non-prime P');\n }\n // Fast-path\n if (S === 1) {\n const p1div4 = (P + $1ea6901afdde618b$var$_1n) / $1ea6901afdde618b$var$_4n;\n return function tonelliFast(Fp, n) {\n const root = Fp.pow(n, p1div4);\n if (!Fp.eql(Fp.sqr(root), n)) throw new Error('Cannot find square root');\n return root;\n };\n }\n // Slow-path\n const Q1div2 = (Q + $1ea6901afdde618b$var$_1n) / $1ea6901afdde618b$var$_2n;\n return function tonelliSlow(Fp, n) {\n // Step 0: Check that n is indeed a square: (n | p) should not be ≡ -1\n if (Fp.pow(n, legendreC) === Fp.neg(Fp.ONE)) throw new Error('Cannot find square root');\n let r = S;\n // TODO: will fail at Fp2/etc\n let g = Fp.pow(Fp.mul(Fp.ONE, Z), Q); // will update both x and b\n let x = Fp.pow(n, Q1div2); // first guess at the square root\n let b = Fp.pow(n, Q); // first guess at the fudge factor\n while(!Fp.eql(b, Fp.ONE)){\n if (Fp.eql(b, Fp.ZERO)) return Fp.ZERO; // https://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm (4. If t = 0, return r = 0)\n // Find m such b^(2^m)==1\n let m = 1;\n for(let t2 = Fp.sqr(b); m < r; m++){\n if (Fp.eql(t2, Fp.ONE)) break;\n t2 = Fp.sqr(t2); // t2 *= t2\n }\n // NOTE: r-m-1 can be bigger than 32, need to convert to bigint before shift, otherwise there will be overflow\n const ge = Fp.pow(g, $1ea6901afdde618b$var$_1n << BigInt(r - m - 1)); // ge = 2^(r-m-1)\n g = Fp.sqr(ge); // g = ge * ge\n x = Fp.mul(x, ge); // x *= ge\n b = Fp.mul(b, g); // b *= g\n r = m;\n }\n return x;\n };\n}\n/**\n * Square root for a finite field. It will try to check if optimizations are applicable and fall back to 4:\n *\n * 1. P ≡ 3 (mod 4)\n * 2. P ≡ 5 (mod 8)\n * 3. P ≡ 9 (mod 16)\n * 4. Tonelli-Shanks algorithm\n *\n * Different algorithms can give different roots, it is up to user to decide which one they want.\n * For example there is FpSqrtOdd/FpSqrtEven to choice root based on oddness (used for hash-to-curve).\n */ function $1ea6901afdde618b$var$FpSqrt(P) {\n // P ≡ 3 (mod 4)\n // √n = n^((P+1)/4)\n if (P % $1ea6901afdde618b$var$_4n === $1ea6901afdde618b$var$_3n) {\n // Not all roots possible!\n // const ORDER =\n // 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn;\n // const NUM = 72057594037927816n;\n const p1div4 = (P + $1ea6901afdde618b$var$_1n) / $1ea6901afdde618b$var$_4n;\n return function sqrt3mod4(Fp, n) {\n const root = Fp.pow(n, p1div4);\n // Throw if root**2 != n\n if (!Fp.eql(Fp.sqr(root), n)) throw new Error('Cannot find square root');\n return root;\n };\n }\n // Atkin algorithm for q ≡ 5 (mod 8), https://eprint.iacr.org/2012/685.pdf (page 10)\n if (P % $1ea6901afdde618b$var$_8n === $1ea6901afdde618b$var$_5n) {\n const c1 = (P - $1ea6901afdde618b$var$_5n) / $1ea6901afdde618b$var$_8n;\n return function sqrt5mod8(Fp, n) {\n const n2 = Fp.mul(n, $1ea6901afdde618b$var$_2n);\n const v = Fp.pow(n2, c1);\n const nv = Fp.mul(n, v);\n const i = Fp.mul(Fp.mul(nv, $1ea6901afdde618b$var$_2n), v);\n const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));\n if (!Fp.eql(Fp.sqr(root), n)) throw new Error('Cannot find square root');\n return root;\n };\n }\n // P ≡ 9 (mod 16)\n $1ea6901afdde618b$var$_9n;\n // Other cases: Tonelli-Shanks algorithm\n return $1ea6901afdde618b$var$tonelliShanks(P);\n}\n// Little-endian check for first LE bit (last BE bit);\nconst $1ea6901afdde618b$var$isNegativeLE = (num, modulo)=>($1ea6901afdde618b$var$mod(num, modulo) & $1ea6901afdde618b$var$_1n) === $1ea6901afdde618b$var$_1n;\nmodule.exports.isNegativeLE = $1ea6901afdde618b$var$isNegativeLE;\n// prettier-ignore\nconst $1ea6901afdde618b$var$FIELD_FIELDS = [\n 'create',\n 'isValid',\n 'is0',\n 'neg',\n 'inv',\n 'sqrt',\n 'sqr',\n 'eql',\n 'add',\n 'sub',\n 'mul',\n 'pow',\n 'div',\n 'addN',\n 'subN',\n 'mulN',\n 'sqrN'\n];\nfunction $1ea6901afdde618b$var$validateField(field) {\n const initial = {\n ORDER: 'bigint',\n MASK: 'bigint',\n BYTES: 'isSafeInteger',\n BITS: 'isSafeInteger'\n };\n const opts = $1ea6901afdde618b$var$FIELD_FIELDS.reduce((map, val)=>{\n map[val] = 'function';\n return map;\n }, initial);\n return (0, $esaJO.validateObject)(field, opts);\n}\n// Generic field functions\n/**\n * Same as `pow` but for Fp: non-constant-time.\n * Unsafe in some contexts: uses ladder, so can expose bigint bits.\n */ function $1ea6901afdde618b$var$FpPow(f, num, power) {\n // Should have same speed as pow for bigints\n // TODO: benchmark!\n if (power < $1ea6901afdde618b$var$_0n) throw new Error('invalid exponent, negatives unsupported');\n if (power === $1ea6901afdde618b$var$_0n) return f.ONE;\n if (power === $1ea6901afdde618b$var$_1n) return num;\n let p = f.ONE;\n let d = num;\n while(power > $1ea6901afdde618b$var$_0n){\n if (power & $1ea6901afdde618b$var$_1n) p = f.mul(p, d);\n d = f.sqr(d);\n power >>= $1ea6901afdde618b$var$_1n;\n }\n return p;\n}\n/**\n * Efficiently invert an array of Field elements.\n * `inv(0)` will return `undefined` here: make sure to throw an error.\n */ function $1ea6901afdde618b$var$FpInvertBatch(f, nums) {\n const tmp = new Array(nums.length);\n // Walk from first to last, multiply them by each other MOD p\n const lastMultiplied = nums.reduce((acc, num, i)=>{\n if (f.is0(num)) return acc;\n tmp[i] = acc;\n return f.mul(acc, num);\n }, f.ONE);\n // Invert last element\n const inverted = f.inv(lastMultiplied);\n // Walk from last to first, multiply them by inverted each other MOD p\n nums.reduceRight((acc, num, i)=>{\n if (f.is0(num)) return acc;\n tmp[i] = f.mul(acc, tmp[i]);\n return f.mul(acc, num);\n }, inverted);\n return tmp;\n}\nfunction $1ea6901afdde618b$var$FpDiv(f, lhs, rhs) {\n return f.mul(lhs, typeof rhs === 'bigint' ? $1ea6901afdde618b$var$invert(rhs, f.ORDER) : f.inv(rhs));\n}\n/**\n * Legendre symbol.\n * * (a | p) ≡ 1 if a is a square (mod p), quadratic residue\n * * (a | p) ≡ -1 if a is not a square (mod p), quadratic non residue\n * * (a | p) ≡ 0 if a ≡ 0 (mod p)\n */ function $1ea6901afdde618b$var$FpLegendre(order) {\n const legendreConst = (order - $1ea6901afdde618b$var$_1n) / $1ea6901afdde618b$var$_2n; // Integer arithmetic\n return (f, x)=>f.pow(x, legendreConst);\n}\n// This function returns True whenever the value x is a square in the field F.\nfunction $1ea6901afdde618b$var$FpIsSquare(f) {\n const legendre = $1ea6901afdde618b$var$FpLegendre(f.ORDER);\n return (x)=>{\n const p = legendre(f, x);\n return f.eql(p, f.ZERO) || f.eql(p, f.ONE);\n };\n}\n// CURVE.n lengths\nfunction $1ea6901afdde618b$var$nLength(n, nBitLength) {\n // Bit size, byte size of CURVE.n\n const _nBitLength = nBitLength !== undefined ? nBitLength : n.toString(2).length;\n const nByteLength = Math.ceil(_nBitLength / 8);\n return {\n nBitLength: _nBitLength,\n nByteLength: nByteLength\n };\n}\n/**\n * Initializes a finite field over prime.\n * Major performance optimizations:\n * * a) denormalized operations like mulN instead of mul\n * * b) same object shape: never add or remove keys\n * * c) Object.freeze\n * Fragile: always run a benchmark on a change.\n * Security note: operations don't check 'isValid' for all elements for performance reasons,\n * it is caller responsibility to check this.\n * This is low-level code, please make sure you know what you're doing.\n * @param ORDER prime positive bigint\n * @param bitLen how many bits the field consumes\n * @param isLE (def: false) if encoding / decoding should be in little-endian\n * @param redef optional faster redefinitions of sqrt and other methods\n */ function $1ea6901afdde618b$var$Field(ORDER, bitLen, isLE = false, redef = {}) {\n if (ORDER <= $1ea6901afdde618b$var$_0n) throw new Error('invalid field: expected ORDER > 0, got ' + ORDER);\n const { nBitLength: BITS, nByteLength: BYTES } = $1ea6901afdde618b$var$nLength(ORDER, bitLen);\n if (BYTES > 2048) throw new Error('invalid field: expected ORDER of <= 2048 bytes');\n let sqrtP; // cached sqrtP\n const f = Object.freeze({\n ORDER: ORDER,\n isLE: isLE,\n BITS: BITS,\n BYTES: BYTES,\n MASK: (0, $esaJO.bitMask)(BITS),\n ZERO: $1ea6901afdde618b$var$_0n,\n ONE: $1ea6901afdde618b$var$_1n,\n create: (num)=>$1ea6901afdde618b$var$mod(num, ORDER),\n isValid: (num)=>{\n if (typeof num !== 'bigint') throw new Error('invalid field element: expected bigint, got ' + typeof num);\n return $1ea6901afdde618b$var$_0n <= num && num < ORDER; // 0 is valid element, but it's not invertible\n },\n is0: (num)=>num === $1ea6901afdde618b$var$_0n,\n isOdd: (num)=>(num & $1ea6901afdde618b$var$_1n) === $1ea6901afdde618b$var$_1n,\n neg: (num)=>$1ea6901afdde618b$var$mod(-num, ORDER),\n eql: (lhs, rhs)=>lhs === rhs,\n sqr: (num)=>$1ea6901afdde618b$var$mod(num * num, ORDER),\n add: (lhs, rhs)=>$1ea6901afdde618b$var$mod(lhs + rhs, ORDER),\n sub: (lhs, rhs)=>$1ea6901afdde618b$var$mod(lhs - rhs, ORDER),\n mul: (lhs, rhs)=>$1ea6901afdde618b$var$mod(lhs * rhs, ORDER),\n pow: (num, power)=>$1ea6901afdde618b$var$FpPow(f, num, power),\n div: (lhs, rhs)=>$1ea6901afdde618b$var$mod(lhs * $1ea6901afdde618b$var$invert(rhs, ORDER), ORDER),\n // Same as above, but doesn't normalize\n sqrN: (num)=>num * num,\n addN: (lhs, rhs)=>lhs + rhs,\n subN: (lhs, rhs)=>lhs - rhs,\n mulN: (lhs, rhs)=>lhs * rhs,\n inv: (num)=>$1ea6901afdde618b$var$invert(num, ORDER),\n sqrt: redef.sqrt || ((n)=>{\n if (!sqrtP) sqrtP = $1ea6901afdde618b$var$FpSqrt(ORDER);\n return sqrtP(f, n);\n }),\n invertBatch: (lst)=>$1ea6901afdde618b$var$FpInvertBatch(f, lst),\n // TODO: do we really need constant cmov?\n // We don't have const-time bigints anyway, so probably will be not very useful\n cmov: (a, b, c)=>c ? b : a,\n toBytes: (num)=>isLE ? (0, $esaJO.numberToBytesLE)(num, BYTES) : (0, $esaJO.numberToBytesBE)(num, BYTES),\n fromBytes: (bytes)=>{\n if (bytes.length !== BYTES) throw new Error('Field.fromBytes: expected ' + BYTES + ' bytes, got ' + bytes.length);\n return isLE ? (0, $esaJO.bytesToNumberLE)(bytes) : (0, $esaJO.bytesToNumberBE)(bytes);\n }\n });\n return Object.freeze(f);\n}\nfunction $1ea6901afdde618b$var$FpSqrtOdd(Fp, elm) {\n if (!Fp.isOdd) throw new Error(\"Field doesn't have isOdd\");\n const root = Fp.sqrt(elm);\n return Fp.isOdd(root) ? root : Fp.neg(root);\n}\nfunction $1ea6901afdde618b$var$FpSqrtEven(Fp, elm) {\n if (!Fp.isOdd) throw new Error(\"Field doesn't have isOdd\");\n const root = Fp.sqrt(elm);\n return Fp.isOdd(root) ? Fp.neg(root) : root;\n}\n/**\n * \"Constant-time\" private key generation utility.\n * Same as mapKeyToField, but accepts less bytes (40 instead of 48 for 32-byte field).\n * Which makes it slightly more biased, less secure.\n * @deprecated use `mapKeyToField` instead\n */ function $1ea6901afdde618b$var$hashToPrivateScalar(hash, groupOrder, isLE = false) {\n hash = (0, $esaJO.ensureBytes)('privateHash', hash);\n const hashLen = hash.length;\n const minLen = $1ea6901afdde618b$var$nLength(groupOrder).nByteLength + 8;\n if (minLen < 24 || hashLen < minLen || hashLen > 1024) throw new Error('hashToPrivateScalar: expected ' + minLen + '-1024 bytes of input, got ' + hashLen);\n const num = isLE ? (0, $esaJO.bytesToNumberLE)(hash) : (0, $esaJO.bytesToNumberBE)(hash);\n return $1ea6901afdde618b$var$mod(num, groupOrder - $1ea6901afdde618b$var$_1n) + $1ea6901afdde618b$var$_1n;\n}\n/**\n * Returns total number of bytes consumed by the field element.\n * For example, 32 bytes for usual 256-bit weierstrass curve.\n * @param fieldOrder number of field elements, usually CURVE.n\n * @returns byte length of field\n */ function $1ea6901afdde618b$var$getFieldBytesLength(fieldOrder) {\n if (typeof fieldOrder !== 'bigint') throw new Error('field order must be bigint');\n const bitLength = fieldOrder.toString(2).length;\n return Math.ceil(bitLength / 8);\n}\n/**\n * Returns minimal amount of bytes that can be safely reduced\n * by field order.\n * Should be 2^-128 for 128-bit curve such as P256.\n * @param fieldOrder number of field elements, usually CURVE.n\n * @returns byte length of target hash\n */ function $1ea6901afdde618b$var$getMinHashLength(fieldOrder) {\n const length = $1ea6901afdde618b$var$getFieldBytesLength(fieldOrder);\n return length + Math.ceil(length / 2);\n}\n/**\n * \"Constant-time\" private key generation utility.\n * Can take (n + n/2) or more bytes of uniform input e.g. from CSPRNG or KDF\n * and convert them into private scalar, with the modulo bias being negligible.\n * Needs at least 48 bytes of input for 32-byte private key.\n * https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/\n * FIPS 186-5, A.2 https://csrc.nist.gov/publications/detail/fips/186/5/final\n * RFC 9380, https://www.rfc-editor.org/rfc/rfc9380#section-5\n * @param hash hash output from SHA3 or a similar function\n * @param groupOrder size of subgroup - (e.g. secp256k1.CURVE.n)\n * @param isLE interpret hash bytes as LE num\n * @returns valid private scalar\n */ function $1ea6901afdde618b$var$mapHashToField(key, fieldOrder, isLE = false) {\n const len = key.length;\n const fieldLen = $1ea6901afdde618b$var$getFieldBytesLength(fieldOrder);\n const minLen = $1ea6901afdde618b$var$getMinHashLength(fieldOrder);\n // No small numbers: need to understand bias story. No huge numbers: easier to detect JS timings.\n if (len < 16 || len < minLen || len > 1024) throw new Error('expected ' + minLen + '-1024 bytes of input, got ' + len);\n const num = isLE ? (0, $esaJO.bytesToNumberLE)(key) : (0, $esaJO.bytesToNumberBE)(key);\n // `mod(x, 11)` can sometimes produce 0. `mod(x, 10) + 1` is the same, but no 0\n const reduced = $1ea6901afdde618b$var$mod(num, fieldOrder - $1ea6901afdde618b$var$_1n) + $1ea6901afdde618b$var$_1n;\n return isLE ? (0, $esaJO.numberToBytesLE)(reduced, fieldLen) : (0, $esaJO.numberToBytesBE)(reduced, fieldLen);\n}\n\n});\nparcelRegister(\"esaJO\", function(module, exports) {\n\"use strict\";\n/**\n * Hex, bytes and number utilities.\n * @module\n */ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */ Object.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.notImplemented = module.exports.bitMask = void 0;\nmodule.exports.isBytes = $a85c028f110aa8ce$var$isBytes;\nmodule.exports.abytes = $a85c028f110aa8ce$var$abytes;\nmodule.exports.abool = $a85c028f110aa8ce$var$abool;\nmodule.exports.bytesToHex = $a85c028f110aa8ce$var$bytesToHex;\nmodule.exports.numberToHexUnpadded = $a85c028f110aa8ce$var$numberToHexUnpadded;\nmodule.exports.hexToNumber = $a85c028f110aa8ce$var$hexToNumber;\nmodule.exports.hexToBytes = $a85c028f110aa8ce$var$hexToBytes;\nmodule.exports.bytesToNumberBE = $a85c028f110aa8ce$var$bytesToNumberBE;\nmodule.exports.bytesToNumberLE = $a85c028f110aa8ce$var$bytesToNumberLE;\nmodule.exports.numberToBytesBE = $a85c028f110aa8ce$var$numberToBytesBE;\nmodule.exports.numberToBytesLE = $a85c028f110aa8ce$var$numberToBytesLE;\nmodule.exports.numberToVarBytesBE = $a85c028f110aa8ce$var$numberToVarBytesBE;\nmodule.exports.ensureBytes = $a85c028f110aa8ce$var$ensureBytes;\nmodule.exports.concatBytes = $a85c028f110aa8ce$var$concatBytes;\nmodule.exports.equalBytes = $a85c028f110aa8ce$var$equalBytes;\nmodule.exports.utf8ToBytes = $a85c028f110aa8ce$var$utf8ToBytes;\nmodule.exports.inRange = $a85c028f110aa8ce$var$inRange;\nmodule.exports.aInRange = $a85c028f110aa8ce$var$aInRange;\nmodule.exports.bitLen = $a85c028f110aa8ce$var$bitLen;\nmodule.exports.bitGet = $a85c028f110aa8ce$var$bitGet;\nmodule.exports.bitSet = $a85c028f110aa8ce$var$bitSet;\nmodule.exports.createHmacDrbg = $a85c028f110aa8ce$var$createHmacDrbg;\nmodule.exports.validateObject = $a85c028f110aa8ce$var$validateObject;\nmodule.exports.memoized = $a85c028f110aa8ce$var$memoized;\n// 100 lines of code in the file are duplicated from noble-hashes (utils).\n// This is OK: `abstract` directory does not use noble-hashes.\n// User may opt-in into using different hashing library. This way, noble-hashes\n// won't be included into their bundle.\nconst $a85c028f110aa8ce$var$_0n = /* @__PURE__ */ BigInt(0);\nconst $a85c028f110aa8ce$var$_1n = /* @__PURE__ */ BigInt(1);\nconst $a85c028f110aa8ce$var$_2n = /* @__PURE__ */ BigInt(2);\nfunction $a85c028f110aa8ce$var$isBytes(a) {\n return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array';\n}\nfunction $a85c028f110aa8ce$var$abytes(item) {\n if (!$a85c028f110aa8ce$var$isBytes(item)) throw new Error('Uint8Array expected');\n}\nfunction $a85c028f110aa8ce$var$abool(title, value) {\n if (typeof value !== 'boolean') throw new Error(title + ' boolean expected, got ' + value);\n}\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst $a85c028f110aa8ce$var$hexes = /* @__PURE__ */ Array.from({\n length: 256\n}, (_, i)=>i.toString(16).padStart(2, '0'));\n/**\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */ function $a85c028f110aa8ce$var$bytesToHex(bytes) {\n $a85c028f110aa8ce$var$abytes(bytes);\n // pre-caching improves the speed 6x\n let hex = '';\n for(let i = 0; i < bytes.length; i++)hex += $a85c028f110aa8ce$var$hexes[bytes[i]];\n return hex;\n}\nfunction $a85c028f110aa8ce$var$numberToHexUnpadded(num) {\n const hex = num.toString(16);\n return hex.length & 1 ? '0' + hex : hex;\n}\nfunction $a85c028f110aa8ce$var$hexToNumber(hex) {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n return hex === '' ? $a85c028f110aa8ce$var$_0n : BigInt('0x' + hex); // Big Endian\n}\n// We use optimized technique to convert hex string to byte array\nconst $a85c028f110aa8ce$var$asciis = {\n _0: 48,\n _9: 57,\n A: 65,\n F: 70,\n a: 97,\n f: 102\n};\nfunction $a85c028f110aa8ce$var$asciiToBase16(ch) {\n if (ch >= $a85c028f110aa8ce$var$asciis._0 && ch <= $a85c028f110aa8ce$var$asciis._9) return ch - $a85c028f110aa8ce$var$asciis._0; // '2' => 50-48\n if (ch >= $a85c028f110aa8ce$var$asciis.A && ch <= $a85c028f110aa8ce$var$asciis.F) return ch - ($a85c028f110aa8ce$var$asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= $a85c028f110aa8ce$var$asciis.a && ch <= $a85c028f110aa8ce$var$asciis.f) return ch - ($a85c028f110aa8ce$var$asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n/**\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */ function $a85c028f110aa8ce$var$hexToBytes(hex) {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2) throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for(let ai = 0, hi = 0; ai < al; ai++, hi += 2){\n const n1 = $a85c028f110aa8ce$var$asciiToBase16(hex.charCodeAt(hi));\n const n2 = $a85c028f110aa8ce$var$asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n// BE: Big Endian, LE: Little Endian\nfunction $a85c028f110aa8ce$var$bytesToNumberBE(bytes) {\n return $a85c028f110aa8ce$var$hexToNumber($a85c028f110aa8ce$var$bytesToHex(bytes));\n}\nfunction $a85c028f110aa8ce$var$bytesToNumberLE(bytes) {\n $a85c028f110aa8ce$var$abytes(bytes);\n return $a85c028f110aa8ce$var$hexToNumber($a85c028f110aa8ce$var$bytesToHex(Uint8Array.from(bytes).reverse()));\n}\nfunction $a85c028f110aa8ce$var$numberToBytesBE(n, len) {\n return $a85c028f110aa8ce$var$hexToBytes(n.toString(16).padStart(len * 2, '0'));\n}\nfunction $a85c028f110aa8ce$var$numberToBytesLE(n, len) {\n return $a85c028f110aa8ce$var$numberToBytesBE(n, len).reverse();\n}\n// Unpadded, rarely used\nfunction $a85c028f110aa8ce$var$numberToVarBytesBE(n) {\n return $a85c028f110aa8ce$var$hexToBytes($a85c028f110aa8ce$var$numberToHexUnpadded(n));\n}\n/**\n * Takes hex string or Uint8Array, converts to Uint8Array.\n * Validates output length.\n * Will throw error for other types.\n * @param title descriptive title for an error e.g. 'private key'\n * @param hex hex string or Uint8Array\n * @param expectedLength optional, will compare to result array's length\n * @returns\n */ function $a85c028f110aa8ce$var$ensureBytes(title, hex, expectedLength) {\n let res;\n if (typeof hex === 'string') try {\n res = $a85c028f110aa8ce$var$hexToBytes(hex);\n } catch (e) {\n throw new Error(title + ' must be hex string or Uint8Array, cause: ' + e);\n }\n else if ($a85c028f110aa8ce$var$isBytes(hex)) // Uint8Array.from() instead of hash.slice() because node.js Buffer\n // is instance of Uint8Array, and its slice() creates **mutable** copy\n res = Uint8Array.from(hex);\n else throw new Error(title + ' must be hex string or Uint8Array');\n const len = res.length;\n if (typeof expectedLength === 'number' && len !== expectedLength) throw new Error(title + ' of length ' + expectedLength + ' expected, got ' + len);\n return res;\n}\n/**\n * Copies several Uint8Arrays into one.\n */ function $a85c028f110aa8ce$var$concatBytes(...arrays) {\n let sum = 0;\n for(let i = 0; i < arrays.length; i++){\n const a = arrays[i];\n $a85c028f110aa8ce$var$abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for(let i = 0, pad = 0; i < arrays.length; i++){\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n// Compares 2 u8a-s in kinda constant time\nfunction $a85c028f110aa8ce$var$equalBytes(a, b) {\n if (a.length !== b.length) return false;\n let diff = 0;\n for(let i = 0; i < a.length; i++)diff |= a[i] ^ b[i];\n return diff === 0;\n}\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */ function $a85c028f110aa8ce$var$utf8ToBytes(str) {\n if (typeof str !== 'string') throw new Error('string expected');\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n// Is positive bigint\nconst $a85c028f110aa8ce$var$isPosBig = (n)=>typeof n === 'bigint' && $a85c028f110aa8ce$var$_0n <= n;\nfunction $a85c028f110aa8ce$var$inRange(n, min, max) {\n return $a85c028f110aa8ce$var$isPosBig(n) && $a85c028f110aa8ce$var$isPosBig(min) && $a85c028f110aa8ce$var$isPosBig(max) && min <= n && n < max;\n}\n/**\n * Asserts min <= n < max. NOTE: It's < max and not <= max.\n * @example\n * aInRange('x', x, 1n, 256n); // would assume x is in (1n..255n)\n */ function $a85c028f110aa8ce$var$aInRange(title, n, min, max) {\n // Why min <= n < max and not a (min < n < max) OR b (min <= n <= max)?\n // consider P=256n, min=0n, max=P\n // - a for min=0 would require -1: `inRange('x', x, -1n, P)`\n // - b would commonly require subtraction: `inRange('x', x, 0n, P - 1n)`\n // - our way is the cleanest: `inRange('x', x, 0n, P)\n if (!$a85c028f110aa8ce$var$inRange(n, min, max)) throw new Error('expected valid ' + title + ': ' + min + ' <= n < ' + max + ', got ' + n);\n}\n// Bit operations\n/**\n * Calculates amount of bits in a bigint.\n * Same as `n.toString(2).length`\n */ function $a85c028f110aa8ce$var$bitLen(n) {\n let len;\n for(len = 0; n > $a85c028f110aa8ce$var$_0n; n >>= $a85c028f110aa8ce$var$_1n, len += 1);\n return len;\n}\n/**\n * Gets single bit at position.\n * NOTE: first bit position is 0 (same as arrays)\n * Same as `!!+Array.from(n.toString(2)).reverse()[pos]`\n */ function $a85c028f110aa8ce$var$bitGet(n, pos) {\n return n >> BigInt(pos) & $a85c028f110aa8ce$var$_1n;\n}\n/**\n * Sets single bit at position.\n */ function $a85c028f110aa8ce$var$bitSet(n, pos, value) {\n return n | (value ? $a85c028f110aa8ce$var$_1n : $a85c028f110aa8ce$var$_0n) << BigInt(pos);\n}\n/**\n * Calculate mask for N bits. Not using ** operator with bigints because of old engines.\n * Same as BigInt(`0b${Array(i).fill('1').join('')}`)\n */ const $a85c028f110aa8ce$var$bitMask = (n)=>($a85c028f110aa8ce$var$_2n << BigInt(n - 1)) - $a85c028f110aa8ce$var$_1n;\nmodule.exports.bitMask = $a85c028f110aa8ce$var$bitMask;\n// DRBG\nconst $a85c028f110aa8ce$var$u8n = (data)=>new Uint8Array(data); // creates Uint8Array\nconst $a85c028f110aa8ce$var$u8fr = (arr)=>Uint8Array.from(arr); // another shortcut\n/**\n * Minimal HMAC-DRBG from NIST 800-90 for RFC6979 sigs.\n * @returns function that will call DRBG until 2nd arg returns something meaningful\n * @example\n * const drbg = createHmacDRBG(32, 32, hmac);\n * drbg(seed, bytesToKey); // bytesToKey must return Key or undefined\n */ function $a85c028f110aa8ce$var$createHmacDrbg(hashLen, qByteLen, hmacFn) {\n if (typeof hashLen !== 'number' || hashLen < 2) throw new Error('hashLen must be a number');\n if (typeof qByteLen !== 'number' || qByteLen < 2) throw new Error('qByteLen must be a number');\n if (typeof hmacFn !== 'function') throw new Error('hmacFn must be a function');\n // Step B, Step C: set hashLen to 8*ceil(hlen/8)\n let v = $a85c028f110aa8ce$var$u8n(hashLen); // Minimal non-full-spec HMAC-DRBG from NIST 800-90 for RFC6979 sigs.\n let k = $a85c028f110aa8ce$var$u8n(hashLen); // Steps B and C of RFC6979 3.2: set hashLen, in our case always same\n let i = 0; // Iterations counter, will throw when over 1000\n const reset = ()=>{\n v.fill(1);\n k.fill(0);\n i = 0;\n };\n const h = (...b)=>hmacFn(k, v, ...b); // hmac(k)(v, ...values)\n const reseed = (seed = $a85c028f110aa8ce$var$u8n())=>{\n // HMAC-DRBG reseed() function. Steps D-G\n k = h($a85c028f110aa8ce$var$u8fr([\n 0x00\n ]), seed); // k = hmac(k || v || 0x00 || seed)\n v = h(); // v = hmac(k || v)\n if (seed.length === 0) return;\n k = h($a85c028f110aa8ce$var$u8fr([\n 0x01\n ]), seed); // k = hmac(k || v || 0x01 || seed)\n v = h(); // v = hmac(k || v)\n };\n const gen = ()=>{\n // HMAC-DRBG generate() function\n if (i++ >= 1000) throw new Error('drbg: tried 1000 values');\n let len = 0;\n const out = [];\n while(len < qByteLen){\n v = h();\n const sl = v.slice();\n out.push(sl);\n len += v.length;\n }\n return $a85c028f110aa8ce$var$concatBytes(...out);\n };\n const genUntil = (seed, pred)=>{\n reset();\n reseed(seed); // Steps D-G\n let res = undefined; // Step H: grind until k is in [1..n-1]\n while(!(res = pred(gen())))reseed();\n reset();\n return res;\n };\n return genUntil;\n}\n// Validating curves and fields\nconst $a85c028f110aa8ce$var$validatorFns = {\n bigint: (val)=>typeof val === 'bigint',\n function: (val)=>typeof val === 'function',\n boolean: (val)=>typeof val === 'boolean',\n string: (val)=>typeof val === 'string',\n stringOrUint8Array: (val)=>typeof val === 'string' || $a85c028f110aa8ce$var$isBytes(val),\n isSafeInteger: (val)=>Number.isSafeInteger(val),\n array: (val)=>Array.isArray(val),\n field: (val, object)=>object.Fp.isValid(val),\n hash: (val)=>typeof val === 'function' && Number.isSafeInteger(val.outputLen)\n};\n// type Record = { [P in K]: T; }\nfunction $a85c028f110aa8ce$var$validateObject(object, validators, optValidators = {}) {\n const checkField = (fieldName, type, isOptional)=>{\n const checkVal = $a85c028f110aa8ce$var$validatorFns[type];\n if (typeof checkVal !== 'function') throw new Error('invalid validator function');\n const val = object[fieldName];\n if (isOptional && val === undefined) return;\n if (!checkVal(val, object)) throw new Error('param ' + String(fieldName) + ' is invalid. Expected ' + type + ', got ' + val);\n };\n for (const [fieldName, type] of Object.entries(validators))checkField(fieldName, type, false);\n for (const [fieldName, type] of Object.entries(optValidators))checkField(fieldName, type, true);\n return object;\n}\n// validate type tests\n// const o: { a: number; b: number; c: number } = { a: 1, b: 5, c: 6 };\n// const z0 = validateObject(o, { a: 'isSafeInteger' }, { c: 'bigint' }); // Ok!\n// // Should fail type-check\n// const z1 = validateObject(o, { a: 'tmp' }, { c: 'zz' });\n// const z2 = validateObject(o, { a: 'isSafeInteger' }, { c: 'zz' });\n// const z3 = validateObject(o, { test: 'boolean', z: 'bug' });\n// const z4 = validateObject(o, { a: 'boolean', z: 'bug' });\n/**\n * throws not implemented error\n */ const $a85c028f110aa8ce$var$notImplemented = ()=>{\n throw new Error('not implemented');\n};\nmodule.exports.notImplemented = $a85c028f110aa8ce$var$notImplemented;\n/**\n * Memoizes (caches) computation result.\n * Uses WeakMap: the value is going auto-cleaned by GC after last reference is removed.\n */ function $a85c028f110aa8ce$var$memoized(fn) {\n const map = new WeakMap();\n return (arg, ...args)=>{\n const val = map.get(arg);\n if (val !== undefined) return val;\n const computed = fn(arg, ...args);\n map.set(arg, computed);\n return computed;\n };\n}\n\n});\n\n\n\nparcelRegister(\"qoWOx\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.twistedEdwards = $04f5c7e644575b38$var$twistedEdwards;\n\nvar $lkFCe = parcelRequire(\"lkFCe\");\n\nvar $2D9sF = parcelRequire(\"2D9sF\");\n\nvar $esaJO = parcelRequire(\"esaJO\");\n\nvar $esaJO = parcelRequire(\"esaJO\");\n// Be friendly to bad ECMAScript parsers by not using bigint literals\n// prettier-ignore\nconst $04f5c7e644575b38$var$_0n = BigInt(0), $04f5c7e644575b38$var$_1n = BigInt(1), $04f5c7e644575b38$var$_2n = BigInt(2), $04f5c7e644575b38$var$_8n = BigInt(8);\n// verification rule is either zip215 or rfc8032 / nist186-5. Consult fromHex:\nconst $04f5c7e644575b38$var$VERIFY_DEFAULT = {\n zip215: true\n};\nfunction $04f5c7e644575b38$var$validateOpts(curve) {\n const opts = (0, $lkFCe.validateBasic)(curve);\n $esaJO.validateObject(curve, {\n hash: 'function',\n a: 'bigint',\n d: 'bigint',\n randomBytes: 'function'\n }, {\n adjustScalarBytes: 'function',\n domain: 'function',\n uvRatio: 'function',\n mapToCurve: 'function'\n });\n // Set defaults\n return Object.freeze({\n ...opts\n });\n}\n/**\n * Creates Twisted Edwards curve with EdDSA signatures.\n * @example\n * import { Field } from '@noble/curves/abstract/modular';\n * // Before that, define BigInt-s: a, d, p, n, Gx, Gy, h\n * const curve = twistedEdwards({ a, d, Fp: Field(p), n, Gx, Gy, h })\n */ function $04f5c7e644575b38$var$twistedEdwards(curveDef) {\n const CURVE = $04f5c7e644575b38$var$validateOpts(curveDef);\n const { Fp: Fp, n: CURVE_ORDER, prehash: prehash, hash: cHash, randomBytes: randomBytes, nByteLength: nByteLength, h: cofactor } = CURVE;\n // Important:\n // There are some places where Fp.BYTES is used instead of nByteLength.\n // So far, everything has been tested with curves of Fp.BYTES == nByteLength.\n // TODO: test and find curves which behave otherwise.\n const MASK = $04f5c7e644575b38$var$_2n << BigInt(nByteLength * 8) - $04f5c7e644575b38$var$_1n;\n const modP = Fp.create; // Function overrides\n const Fn = (0, $2D9sF.Field)(CURVE.n, CURVE.nBitLength);\n // sqrt(u/v)\n const uvRatio = CURVE.uvRatio || ((u, v)=>{\n try {\n return {\n isValid: true,\n value: Fp.sqrt(u * Fp.inv(v))\n };\n } catch (e) {\n return {\n isValid: false,\n value: $04f5c7e644575b38$var$_0n\n };\n }\n });\n const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes)=>bytes); // NOOP\n const domain = CURVE.domain || ((data, ctx, phflag)=>{\n (0, $esaJO.abool)('phflag', phflag);\n if (ctx.length || phflag) throw new Error('Contexts/pre-hash are not supported');\n return data;\n }); // NOOP\n // 0 <= n < MASK\n // Coordinates larger than Fp.ORDER are allowed for zip215\n function aCoordinate(title, n) {\n $esaJO.aInRange('coordinate ' + title, n, $04f5c7e644575b38$var$_0n, MASK);\n }\n function assertPoint(other) {\n if (!(other instanceof Point)) throw new Error('ExtendedPoint expected');\n }\n // Converts Extended point to default (x, y) coordinates.\n // Can accept precomputed Z^-1 - for example, from invertBatch.\n const toAffineMemo = (0, $esaJO.memoized)((p, iz)=>{\n const { ex: x, ey: y, ez: z } = p;\n const is0 = p.is0();\n if (iz == null) iz = is0 ? $04f5c7e644575b38$var$_8n : Fp.inv(z); // 8 was chosen arbitrarily\n const ax = modP(x * iz);\n const ay = modP(y * iz);\n const zz = modP(z * iz);\n if (is0) return {\n x: $04f5c7e644575b38$var$_0n,\n y: $04f5c7e644575b38$var$_1n\n };\n if (zz !== $04f5c7e644575b38$var$_1n) throw new Error('invZ was invalid');\n return {\n x: ax,\n y: ay\n };\n });\n const assertValidMemo = (0, $esaJO.memoized)((p)=>{\n const { a: a, d: d } = CURVE;\n if (p.is0()) throw new Error('bad point: ZERO'); // TODO: optimize, with vars below?\n // Equation in affine coordinates: ax² + y² = 1 + dx²y²\n // Equation in projective coordinates (X/Z, Y/Z, Z): (aX² + Y²)Z² = Z⁴ + dX²Y²\n const { ex: X, ey: Y, ez: Z, et: T } = p;\n const X2 = modP(X * X); // X²\n const Y2 = modP(Y * Y); // Y²\n const Z2 = modP(Z * Z); // Z²\n const Z4 = modP(Z2 * Z2); // Z⁴\n const aX2 = modP(X2 * a); // aX²\n const left = modP(Z2 * modP(aX2 + Y2)); // (aX² + Y²)Z²\n const right = modP(Z4 + modP(d * modP(X2 * Y2))); // Z⁴ + dX²Y²\n if (left !== right) throw new Error('bad point: equation left != right (1)');\n // In Extended coordinates we also have T, which is x*y=T/Z: check X*Y == Z*T\n const XY = modP(X * Y);\n const ZT = modP(Z * T);\n if (XY !== ZT) throw new Error('bad point: equation left != right (2)');\n return true;\n });\n // Extended Point works in extended coordinates: (x, y, z, t) ∋ (x=x/z, y=y/z, t=xy).\n // https://en.wikipedia.org/wiki/Twisted_Edwards_curve#Extended_coordinates\n class Point {\n constructor(ex, ey, ez, et){\n this.ex = ex;\n this.ey = ey;\n this.ez = ez;\n this.et = et;\n aCoordinate('x', ex);\n aCoordinate('y', ey);\n aCoordinate('z', ez);\n aCoordinate('t', et);\n Object.freeze(this);\n }\n get x() {\n return this.toAffine().x;\n }\n get y() {\n return this.toAffine().y;\n }\n static fromAffine(p) {\n if (p instanceof Point) throw new Error('extended point not allowed');\n const { x: x, y: y } = p || {};\n aCoordinate('x', x);\n aCoordinate('y', y);\n return new Point(x, y, $04f5c7e644575b38$var$_1n, modP(x * y));\n }\n static normalizeZ(points) {\n const toInv = Fp.invertBatch(points.map((p)=>p.ez));\n return points.map((p, i)=>p.toAffine(toInv[i])).map(Point.fromAffine);\n }\n // Multiscalar Multiplication\n static msm(points, scalars) {\n return (0, $lkFCe.pippenger)(Point, Fn, points, scalars);\n }\n // \"Private method\", don't use it directly\n _setWindowSize(windowSize) {\n wnaf.setWindowSize(this, windowSize);\n }\n // Not required for fromHex(), which always creates valid points.\n // Could be useful for fromAffine().\n assertValidity() {\n assertValidMemo(this);\n }\n // Compare one point to another.\n equals(other) {\n assertPoint(other);\n const { ex: X1, ey: Y1, ez: Z1 } = this;\n const { ex: X2, ey: Y2, ez: Z2 } = other;\n const X1Z2 = modP(X1 * Z2);\n const X2Z1 = modP(X2 * Z1);\n const Y1Z2 = modP(Y1 * Z2);\n const Y2Z1 = modP(Y2 * Z1);\n return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;\n }\n is0() {\n return this.equals(Point.ZERO);\n }\n negate() {\n // Flips point sign to a negative one (-x, y in affine coords)\n return new Point(modP(-this.ex), this.ey, this.ez, modP(-this.et));\n }\n // Fast algo for doubling Extended Point.\n // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#doubling-dbl-2008-hwcd\n // Cost: 4M + 4S + 1*a + 6add + 1*2.\n double() {\n const { a: a } = CURVE;\n const { ex: X1, ey: Y1, ez: Z1 } = this;\n const A = modP(X1 * X1); // A = X12\n const B = modP(Y1 * Y1); // B = Y12\n const C = modP($04f5c7e644575b38$var$_2n * modP(Z1 * Z1)); // C = 2*Z12\n const D = modP(a * A); // D = a*A\n const x1y1 = X1 + Y1;\n const E = modP(modP(x1y1 * x1y1) - A - B); // E = (X1+Y1)2-A-B\n const G = D + B; // G = D+B\n const F = G - C; // F = G-C\n const H = D - B; // H = D-B\n const X3 = modP(E * F); // X3 = E*F\n const Y3 = modP(G * H); // Y3 = G*H\n const T3 = modP(E * H); // T3 = E*H\n const Z3 = modP(F * G); // Z3 = F*G\n return new Point(X3, Y3, Z3, T3);\n }\n // Fast algo for adding 2 Extended Points.\n // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd\n // Cost: 9M + 1*a + 1*d + 7add.\n add(other) {\n assertPoint(other);\n const { a: a, d: d } = CURVE;\n const { ex: X1, ey: Y1, ez: Z1, et: T1 } = this;\n const { ex: X2, ey: Y2, ez: Z2, et: T2 } = other;\n // Faster algo for adding 2 Extended Points when curve's a=-1.\n // http://hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html#addition-add-2008-hwcd-4\n // Cost: 8M + 8add + 2*2.\n // Note: It does not check whether the `other` point is valid.\n if (a === BigInt(-1)) {\n const A = modP((Y1 - X1) * (Y2 + X2));\n const B = modP((Y1 + X1) * (Y2 - X2));\n const F = modP(B - A);\n if (F === $04f5c7e644575b38$var$_0n) return this.double(); // Same point. Tests say it doesn't affect timing\n const C = modP(Z1 * $04f5c7e644575b38$var$_2n * T2);\n const D = modP(T1 * $04f5c7e644575b38$var$_2n * Z2);\n const E = D + C;\n const G = B + A;\n const H = D - C;\n const X3 = modP(E * F);\n const Y3 = modP(G * H);\n const T3 = modP(E * H);\n const Z3 = modP(F * G);\n return new Point(X3, Y3, Z3, T3);\n }\n const A = modP(X1 * X2); // A = X1*X2\n const B = modP(Y1 * Y2); // B = Y1*Y2\n const C = modP(T1 * d * T2); // C = T1*d*T2\n const D = modP(Z1 * Z2); // D = Z1*Z2\n const E = modP((X1 + Y1) * (X2 + Y2) - A - B); // E = (X1+Y1)*(X2+Y2)-A-B\n const F = D - C; // F = D-C\n const G = D + C; // G = D+C\n const H = modP(B - a * A); // H = B-a*A\n const X3 = modP(E * F); // X3 = E*F\n const Y3 = modP(G * H); // Y3 = G*H\n const T3 = modP(E * H); // T3 = E*H\n const Z3 = modP(F * G); // Z3 = F*G\n return new Point(X3, Y3, Z3, T3);\n }\n subtract(other) {\n return this.add(other.negate());\n }\n wNAF(n) {\n return wnaf.wNAFCached(this, n, Point.normalizeZ);\n }\n // Constant-time multiplication.\n multiply(scalar) {\n const n = scalar;\n $esaJO.aInRange('scalar', n, $04f5c7e644575b38$var$_1n, CURVE_ORDER); // 1 <= scalar < L\n const { p: p, f: f } = this.wNAF(n);\n return Point.normalizeZ([\n p,\n f\n ])[0];\n }\n // Non-constant-time multiplication. Uses double-and-add algorithm.\n // It's faster, but should only be used when you don't care about\n // an exposed private key e.g. sig verification.\n // Does NOT allow scalars higher than CURVE.n.\n // Accepts optional accumulator to merge with multiply (important for sparse scalars)\n multiplyUnsafe(scalar, acc = Point.ZERO) {\n const n = scalar;\n $esaJO.aInRange('scalar', n, $04f5c7e644575b38$var$_0n, CURVE_ORDER); // 0 <= scalar < L\n if (n === $04f5c7e644575b38$var$_0n) return I;\n if (this.is0() || n === $04f5c7e644575b38$var$_1n) return this;\n return wnaf.wNAFCachedUnsafe(this, n, Point.normalizeZ, acc);\n }\n // Checks if point is of small order.\n // If you add something to small order point, you will have \"dirty\"\n // point with torsion component.\n // Multiplies point by cofactor and checks if the result is 0.\n isSmallOrder() {\n return this.multiplyUnsafe(cofactor).is0();\n }\n // Multiplies point by curve order and checks if the result is 0.\n // Returns `false` is the point is dirty.\n isTorsionFree() {\n return wnaf.unsafeLadder(this, CURVE_ORDER).is0();\n }\n // Converts Extended point to default (x, y) coordinates.\n // Can accept precomputed Z^-1 - for example, from invertBatch.\n toAffine(iz) {\n return toAffineMemo(this, iz);\n }\n clearCofactor() {\n const { h: cofactor } = CURVE;\n if (cofactor === $04f5c7e644575b38$var$_1n) return this;\n return this.multiplyUnsafe(cofactor);\n }\n // Converts hash string or Uint8Array to Point.\n // Uses algo from RFC8032 5.1.3.\n static fromHex(hex, zip215 = false) {\n const { d: d, a: a } = CURVE;\n const len = Fp.BYTES;\n hex = (0, $esaJO.ensureBytes)('pointHex', hex, len); // copy hex to a new array\n (0, $esaJO.abool)('zip215', zip215);\n const normed = hex.slice(); // copy again, we'll manipulate it\n const lastByte = hex[len - 1]; // select last byte\n normed[len - 1] = lastByte & -129; // clear last bit\n const y = $esaJO.bytesToNumberLE(normed);\n // zip215=true is good for consensus-critical apps. =false follows RFC8032 / NIST186-5.\n // RFC8032 prohibits >= p, but ZIP215 doesn't\n // zip215=true: 0 <= y < MASK (2^256 for ed25519)\n // zip215=false: 0 <= y < P (2^255-19 for ed25519)\n const max = zip215 ? MASK : Fp.ORDER;\n $esaJO.aInRange('pointHex.y', y, $04f5c7e644575b38$var$_0n, max);\n // Ed25519: x² = (y²-1)/(dy²+1) mod p. Ed448: x² = (y²-1)/(dy²-1) mod p. Generic case:\n // ax²+y²=1+dx²y² => y²-1=dx²y²-ax² => y²-1=x²(dy²-a) => x²=(y²-1)/(dy²-a)\n const y2 = modP(y * y); // denominator is always non-0 mod p.\n const u = modP(y2 - $04f5c7e644575b38$var$_1n); // u = y² - 1\n const v = modP(d * y2 - a); // v = d y² + 1.\n let { isValid: isValid, value: x } = uvRatio(u, v); // √(u/v)\n if (!isValid) throw new Error('Point.fromHex: invalid y coordinate');\n const isXOdd = (x & $04f5c7e644575b38$var$_1n) === $04f5c7e644575b38$var$_1n; // There are 2 square roots. Use x_0 bit to select proper\n const isLastByteOdd = (lastByte & 0x80) !== 0; // x_0, last bit\n if (!zip215 && x === $04f5c7e644575b38$var$_0n && isLastByteOdd) // if x=0 and x_0 = 1, fail\n throw new Error('Point.fromHex: x=0 and x_0=1');\n if (isLastByteOdd !== isXOdd) x = modP(-x); // if x_0 != x mod 2, set x = p-x\n return Point.fromAffine({\n x: x,\n y: y\n });\n }\n static fromPrivateKey(privKey) {\n return getExtendedPublicKey(privKey).point;\n }\n toRawBytes() {\n const { x: x, y: y } = this.toAffine();\n const bytes = $esaJO.numberToBytesLE(y, Fp.BYTES); // each y has 2 x values (x, -y)\n bytes[bytes.length - 1] |= x & $04f5c7e644575b38$var$_1n ? 0x80 : 0; // when compressing, it's enough to store y\n return bytes; // and use the last byte to encode sign of x\n }\n toHex() {\n return $esaJO.bytesToHex(this.toRawBytes()); // Same as toRawBytes, but returns string.\n }\n }\n Point.BASE = new Point(CURVE.Gx, CURVE.Gy, $04f5c7e644575b38$var$_1n, modP(CURVE.Gx * CURVE.Gy));\n Point.ZERO = new Point($04f5c7e644575b38$var$_0n, $04f5c7e644575b38$var$_1n, $04f5c7e644575b38$var$_1n, $04f5c7e644575b38$var$_0n); // 0, 1, 1, 0\n const { BASE: G, ZERO: I } = Point;\n const wnaf = (0, $lkFCe.wNAF)(Point, nByteLength * 8);\n function modN(a) {\n return (0, $2D9sF.mod)(a, CURVE_ORDER);\n }\n // Little-endian SHA512 with modulo n\n function modN_LE(hash) {\n return modN($esaJO.bytesToNumberLE(hash));\n }\n /** Convenience method that creates public key and other stuff. RFC8032 5.1.5 */ function getExtendedPublicKey(key) {\n const len = Fp.BYTES;\n key = (0, $esaJO.ensureBytes)('private key', key, len);\n // Hash private key with curve's hash function to produce uniformingly random input\n // Check byte lengths: ensure(64, h(ensure(32, key)))\n const hashed = (0, $esaJO.ensureBytes)('hashed private key', cHash(key), 2 * len);\n const head = adjustScalarBytes(hashed.slice(0, len)); // clear first half bits, produce FE\n const prefix = hashed.slice(len, 2 * len); // second half is called key prefix (5.1.6)\n const scalar = modN_LE(head); // The actual private scalar\n const point = G.multiply(scalar); // Point on Edwards curve aka public key\n const pointBytes = point.toRawBytes(); // Uint8Array representation\n return {\n head: head,\n prefix: prefix,\n scalar: scalar,\n point: point,\n pointBytes: pointBytes\n };\n }\n // Calculates EdDSA pub key. RFC8032 5.1.5. Privkey is hashed. Use first half with 3 bits cleared\n function getPublicKey(privKey) {\n return getExtendedPublicKey(privKey).pointBytes;\n }\n // int('LE', SHA512(dom2(F, C) || msgs)) mod N\n function hashDomainToScalar(context = new Uint8Array(), ...msgs) {\n const msg = $esaJO.concatBytes(...msgs);\n return modN_LE(cHash(domain(msg, (0, $esaJO.ensureBytes)('context', context), !!prehash)));\n }\n /** Signs message with privateKey. RFC8032 5.1.6 */ function sign(msg, privKey, options = {}) {\n msg = (0, $esaJO.ensureBytes)('message', msg);\n if (prehash) msg = prehash(msg); // for ed25519ph etc.\n const { prefix: prefix, scalar: scalar, pointBytes: pointBytes } = getExtendedPublicKey(privKey);\n const r = hashDomainToScalar(options.context, prefix, msg); // r = dom2(F, C) || prefix || PH(M)\n const R = G.multiply(r).toRawBytes(); // R = rG\n const k = hashDomainToScalar(options.context, R, pointBytes, msg); // R || A || PH(M)\n const s = modN(r + k * scalar); // S = (r + k * s) mod L\n $esaJO.aInRange('signature.s', s, $04f5c7e644575b38$var$_0n, CURVE_ORDER); // 0 <= s < l\n const res = $esaJO.concatBytes(R, $esaJO.numberToBytesLE(s, Fp.BYTES));\n return (0, $esaJO.ensureBytes)('result', res, Fp.BYTES * 2); // 64-byte signature\n }\n const verifyOpts = $04f5c7e644575b38$var$VERIFY_DEFAULT;\n /**\n * Verifies EdDSA signature against message and public key. RFC8032 5.1.7.\n * An extended group equation is checked.\n */ function verify(sig, msg, publicKey, options = verifyOpts) {\n const { context: context, zip215: zip215 } = options;\n const len = Fp.BYTES; // Verifies EdDSA signature against message and public key. RFC8032 5.1.7.\n sig = (0, $esaJO.ensureBytes)('signature', sig, 2 * len); // An extended group equation is checked.\n msg = (0, $esaJO.ensureBytes)('message', msg);\n publicKey = (0, $esaJO.ensureBytes)('publicKey', publicKey, len);\n if (zip215 !== undefined) (0, $esaJO.abool)('zip215', zip215);\n if (prehash) msg = prehash(msg); // for ed25519ph, etc\n const s = $esaJO.bytesToNumberLE(sig.slice(len, 2 * len));\n let A, R, SB;\n try {\n // zip215=true is good for consensus-critical apps. =false follows RFC8032 / NIST186-5.\n // zip215=true: 0 <= y < MASK (2^256 for ed25519)\n // zip215=false: 0 <= y < P (2^255-19 for ed25519)\n A = Point.fromHex(publicKey, zip215);\n R = Point.fromHex(sig.slice(0, len), zip215);\n SB = G.multiplyUnsafe(s); // 0 <= s < l is done inside\n } catch (error) {\n return false;\n }\n if (!zip215 && A.isSmallOrder()) return false;\n const k = hashDomainToScalar(context, R.toRawBytes(), A.toRawBytes(), msg);\n const RkA = R.add(A.multiplyUnsafe(k));\n // Extended group equation\n // [8][S]B = [8]R + [8][k]A'\n return RkA.subtract(SB).clearCofactor().equals(Point.ZERO);\n }\n G._setWindowSize(8); // Enable precomputes. Slows down first publicKey computation by 20ms.\n const utils = {\n getExtendedPublicKey: getExtendedPublicKey,\n // ed25519 private keys are uniform 32b. No need to check for modulo bias, like in secp256k1.\n randomPrivateKey: ()=>randomBytes(Fp.BYTES),\n /**\n * We're doing scalar multiplication (used in getPublicKey etc) with precomputed BASE_POINT\n * values. This slows down first getPublicKey() by milliseconds (see Speed section),\n * but allows to speed-up subsequent getPublicKey() calls up to 20x.\n * @param windowSize 2, 4, 8, 16\n */ precompute (windowSize = 8, point = Point.BASE) {\n point._setWindowSize(windowSize);\n point.multiply(BigInt(3));\n return point;\n }\n };\n return {\n CURVE: CURVE,\n getPublicKey: getPublicKey,\n sign: sign,\n verify: verify,\n ExtendedPoint: Point,\n utils: utils\n };\n}\n\n});\n\nparcelRegister(\"rkPJ6\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.expand_message_xmd = $0522aeca5769187c$var$expand_message_xmd;\nmodule.exports.expand_message_xof = $0522aeca5769187c$var$expand_message_xof;\nmodule.exports.hash_to_field = $0522aeca5769187c$var$hash_to_field;\nmodule.exports.isogenyMap = $0522aeca5769187c$var$isogenyMap;\nmodule.exports.createHasher = $0522aeca5769187c$var$createHasher;\n\nvar $2D9sF = parcelRequire(\"2D9sF\");\n\nvar $esaJO = parcelRequire(\"esaJO\");\n// Octet Stream to Integer. \"spec\" implementation of os2ip is 2.5x slower vs bytesToNumberBE.\nconst $0522aeca5769187c$var$os2ip = $esaJO.bytesToNumberBE;\n// Integer to Octet Stream (numberToBytesBE)\nfunction $0522aeca5769187c$var$i2osp(value, length) {\n $0522aeca5769187c$var$anum(value);\n $0522aeca5769187c$var$anum(length);\n if (value < 0 || value >= 1 << 8 * length) throw new Error('invalid I2OSP input: ' + value);\n const res = Array.from({\n length: length\n }).fill(0);\n for(let i = length - 1; i >= 0; i--){\n res[i] = value & 0xff;\n value >>>= 8;\n }\n return new Uint8Array(res);\n}\nfunction $0522aeca5769187c$var$strxor(a, b) {\n const arr = new Uint8Array(a.length);\n for(let i = 0; i < a.length; i++)arr[i] = a[i] ^ b[i];\n return arr;\n}\nfunction $0522aeca5769187c$var$anum(item) {\n if (!Number.isSafeInteger(item)) throw new Error('number expected');\n}\n/**\n * Produces a uniformly random byte string using a cryptographic hash function H that outputs b bits.\n * [RFC 9380 5.3.1](https://www.rfc-editor.org/rfc/rfc9380#section-5.3.1).\n */ function $0522aeca5769187c$var$expand_message_xmd(msg, DST, lenInBytes, H) {\n (0, $esaJO.abytes)(msg);\n (0, $esaJO.abytes)(DST);\n $0522aeca5769187c$var$anum(lenInBytes);\n // https://www.rfc-editor.org/rfc/rfc9380#section-5.3.3\n if (DST.length > 255) DST = H((0, $esaJO.concatBytes)((0, $esaJO.utf8ToBytes)('H2C-OVERSIZE-DST-'), DST));\n const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H;\n const ell = Math.ceil(lenInBytes / b_in_bytes);\n if (lenInBytes > 65535 || ell > 255) throw new Error('expand_message_xmd: invalid lenInBytes');\n const DST_prime = (0, $esaJO.concatBytes)(DST, $0522aeca5769187c$var$i2osp(DST.length, 1));\n const Z_pad = $0522aeca5769187c$var$i2osp(0, r_in_bytes);\n const l_i_b_str = $0522aeca5769187c$var$i2osp(lenInBytes, 2); // len_in_bytes_str\n const b = new Array(ell);\n const b_0 = H((0, $esaJO.concatBytes)(Z_pad, msg, l_i_b_str, $0522aeca5769187c$var$i2osp(0, 1), DST_prime));\n b[0] = H((0, $esaJO.concatBytes)(b_0, $0522aeca5769187c$var$i2osp(1, 1), DST_prime));\n for(let i = 1; i <= ell; i++){\n const args = [\n $0522aeca5769187c$var$strxor(b_0, b[i - 1]),\n $0522aeca5769187c$var$i2osp(i + 1, 1),\n DST_prime\n ];\n b[i] = H((0, $esaJO.concatBytes)(...args));\n }\n const pseudo_random_bytes = (0, $esaJO.concatBytes)(...b);\n return pseudo_random_bytes.slice(0, lenInBytes);\n}\n/**\n * Produces a uniformly random byte string using an extendable-output function (XOF) H.\n * 1. The collision resistance of H MUST be at least k bits.\n * 2. H MUST be an XOF that has been proved indifferentiable from\n * a random oracle under a reasonable cryptographic assumption.\n * [RFC 9380 5.3.2](https://www.rfc-editor.org/rfc/rfc9380#section-5.3.2).\n */ function $0522aeca5769187c$var$expand_message_xof(msg, DST, lenInBytes, k, H) {\n (0, $esaJO.abytes)(msg);\n (0, $esaJO.abytes)(DST);\n $0522aeca5769187c$var$anum(lenInBytes);\n // https://www.rfc-editor.org/rfc/rfc9380#section-5.3.3\n // DST = H('H2C-OVERSIZE-DST-' || a_very_long_DST, Math.ceil((lenInBytes * k) / 8));\n if (DST.length > 255) {\n const dkLen = Math.ceil(2 * k / 8);\n DST = H.create({\n dkLen: dkLen\n }).update((0, $esaJO.utf8ToBytes)('H2C-OVERSIZE-DST-')).update(DST).digest();\n }\n if (lenInBytes > 65535 || DST.length > 255) throw new Error('expand_message_xof: invalid lenInBytes');\n return H.create({\n dkLen: lenInBytes\n }).update(msg).update($0522aeca5769187c$var$i2osp(lenInBytes, 2))// 2. DST_prime = DST || I2OSP(len(DST), 1)\n .update(DST).update($0522aeca5769187c$var$i2osp(DST.length, 1)).digest();\n}\n/**\n * Hashes arbitrary-length byte strings to a list of one or more elements of a finite field F.\n * [RFC 9380 5.2](https://www.rfc-editor.org/rfc/rfc9380#section-5.2).\n * @param msg a byte string containing the message to hash\n * @param count the number of elements of F to output\n * @param options `{DST: string, p: bigint, m: number, k: number, expand: 'xmd' | 'xof', hash: H}`, see above\n * @returns [u_0, ..., u_(count - 1)], a list of field elements.\n */ function $0522aeca5769187c$var$hash_to_field(msg, count, options) {\n (0, $esaJO.validateObject)(options, {\n DST: 'stringOrUint8Array',\n p: 'bigint',\n m: 'isSafeInteger',\n k: 'isSafeInteger',\n hash: 'hash'\n });\n const { p: p, k: k, m: m, hash: hash, expand: expand, DST: _DST } = options;\n (0, $esaJO.abytes)(msg);\n $0522aeca5769187c$var$anum(count);\n const DST = typeof _DST === 'string' ? (0, $esaJO.utf8ToBytes)(_DST) : _DST;\n const log2p = p.toString(2).length;\n const L = Math.ceil((log2p + k) / 8); // section 5.1 of ietf draft link above\n const len_in_bytes = count * m * L;\n let prb; // pseudo_random_bytes\n if (expand === 'xmd') prb = $0522aeca5769187c$var$expand_message_xmd(msg, DST, len_in_bytes, hash);\n else if (expand === 'xof') prb = $0522aeca5769187c$var$expand_message_xof(msg, DST, len_in_bytes, k, hash);\n else if (expand === '_internal_pass') // for internal tests only\n prb = msg;\n else throw new Error('expand must be \"xmd\" or \"xof\"');\n const u = new Array(count);\n for(let i = 0; i < count; i++){\n const e = new Array(m);\n for(let j = 0; j < m; j++){\n const elm_offset = L * (j + i * m);\n const tv = prb.subarray(elm_offset, elm_offset + L);\n e[j] = (0, $2D9sF.mod)($0522aeca5769187c$var$os2ip(tv), p);\n }\n u[i] = e;\n }\n return u;\n}\nfunction $0522aeca5769187c$var$isogenyMap(field, map) {\n // Make same order as in spec\n const COEFF = map.map((i)=>Array.from(i).reverse());\n return (x, y)=>{\n const [xNum, xDen, yNum, yDen] = COEFF.map((val)=>val.reduce((acc, i)=>field.add(field.mul(acc, x), i)));\n x = field.div(xNum, xDen); // xNum / xDen\n y = field.mul(y, field.div(yNum, yDen)); // y * (yNum / yDev)\n return {\n x: x,\n y: y\n };\n };\n}\n/** Creates hash-to-curve methods from EC Point and mapToCurve function. */ function $0522aeca5769187c$var$createHasher(Point, mapToCurve, def) {\n if (typeof mapToCurve !== 'function') throw new Error('mapToCurve() must be defined');\n return {\n // Encodes byte string to elliptic curve.\n // hash_to_curve from https://www.rfc-editor.org/rfc/rfc9380#section-3\n hashToCurve (msg, options) {\n const u = $0522aeca5769187c$var$hash_to_field(msg, 2, {\n ...def,\n DST: def.DST,\n ...options\n });\n const u0 = Point.fromAffine(mapToCurve(u[0]));\n const u1 = Point.fromAffine(mapToCurve(u[1]));\n const P = u0.add(u1).clearCofactor();\n P.assertValidity();\n return P;\n },\n // Encodes byte string to elliptic curve.\n // encode_to_curve from https://www.rfc-editor.org/rfc/rfc9380#section-3\n encodeToCurve (msg, options) {\n const u = $0522aeca5769187c$var$hash_to_field(msg, 1, {\n ...def,\n DST: def.encodeDST,\n ...options\n });\n const P = Point.fromAffine(mapToCurve(u[0])).clearCofactor();\n P.assertValidity();\n return P;\n },\n // Same as encodeToCurve, but without hash\n mapToCurve (scalars) {\n if (!Array.isArray(scalars)) throw new Error('mapToCurve: expected array of bigints');\n for (const i of scalars)if (typeof i !== 'bigint') throw new Error('mapToCurve: expected array of bigints');\n const P = Point.fromAffine(mapToCurve(scalars)).clearCofactor();\n P.assertValidity();\n return P;\n }\n };\n}\n\n});\n\nparcelRegister(\"kiLeO\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.montgomery = $ec7a218c4f0875a8$var$montgomery;\n\nvar $2D9sF = parcelRequire(\"2D9sF\");\n\nvar $esaJO = parcelRequire(\"esaJO\");\nconst $ec7a218c4f0875a8$var$_0n = BigInt(0);\nconst $ec7a218c4f0875a8$var$_1n = BigInt(1);\nfunction $ec7a218c4f0875a8$var$validateOpts(curve) {\n (0, $esaJO.validateObject)(curve, {\n a: 'bigint'\n }, {\n montgomeryBits: 'isSafeInteger',\n nByteLength: 'isSafeInteger',\n adjustScalarBytes: 'function',\n domain: 'function',\n powPminus2: 'function',\n Gu: 'bigint'\n });\n // Set defaults\n return Object.freeze({\n ...curve\n });\n}\n// Uses only one coordinate instead of two\nfunction $ec7a218c4f0875a8$var$montgomery(curveDef) {\n const CURVE = $ec7a218c4f0875a8$var$validateOpts(curveDef);\n const { P: P } = CURVE;\n const modP = (n)=>(0, $2D9sF.mod)(n, P);\n const montgomeryBits = CURVE.montgomeryBits;\n const montgomeryBytes = Math.ceil(montgomeryBits / 8);\n const fieldLen = CURVE.nByteLength;\n const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes)=>bytes);\n const powPminus2 = CURVE.powPminus2 || ((x)=>(0, $2D9sF.pow)(x, P - BigInt(2), P));\n // cswap from RFC7748. But it is not from RFC7748!\n /*\n cswap(swap, x_2, x_3):\n dummy = mask(swap) AND (x_2 XOR x_3)\n x_2 = x_2 XOR dummy\n x_3 = x_3 XOR dummy\n Return (x_2, x_3)\n Where mask(swap) is the all-1 or all-0 word of the same length as x_2\n and x_3, computed, e.g., as mask(swap) = 0 - swap.\n */ function cswap(swap, x_2, x_3) {\n const dummy = modP(swap * (x_2 - x_3));\n x_2 = modP(x_2 - dummy);\n x_3 = modP(x_3 + dummy);\n return [\n x_2,\n x_3\n ];\n }\n // x25519 from 4\n // The constant a24 is (486662 - 2) / 4 = 121665 for curve25519/X25519\n const a24 = (CURVE.a - BigInt(2)) / BigInt(4);\n /**\n *\n * @param pointU u coordinate (x) on Montgomery Curve 25519\n * @param scalar by which the point would be multiplied\n * @returns new Point on Montgomery curve\n */ function montgomeryLadder(u, scalar) {\n (0, $esaJO.aInRange)('u', u, $ec7a218c4f0875a8$var$_0n, P);\n (0, $esaJO.aInRange)('scalar', scalar, $ec7a218c4f0875a8$var$_0n, P);\n // Section 5: Implementations MUST accept non-canonical values and process them as\n // if they had been reduced modulo the field prime.\n const k = scalar;\n const x_1 = u;\n let x_2 = $ec7a218c4f0875a8$var$_1n;\n let z_2 = $ec7a218c4f0875a8$var$_0n;\n let x_3 = u;\n let z_3 = $ec7a218c4f0875a8$var$_1n;\n let swap = $ec7a218c4f0875a8$var$_0n;\n let sw;\n for(let t = BigInt(montgomeryBits - 1); t >= $ec7a218c4f0875a8$var$_0n; t--){\n const k_t = k >> t & $ec7a218c4f0875a8$var$_1n;\n swap ^= k_t;\n sw = cswap(swap, x_2, x_3);\n x_2 = sw[0];\n x_3 = sw[1];\n sw = cswap(swap, z_2, z_3);\n z_2 = sw[0];\n z_3 = sw[1];\n swap = k_t;\n const A = x_2 + z_2;\n const AA = modP(A * A);\n const B = x_2 - z_2;\n const BB = modP(B * B);\n const E = AA - BB;\n const C = x_3 + z_3;\n const D = x_3 - z_3;\n const DA = modP(D * A);\n const CB = modP(C * B);\n const dacb = DA + CB;\n const da_cb = DA - CB;\n x_3 = modP(dacb * dacb);\n z_3 = modP(x_1 * modP(da_cb * da_cb));\n x_2 = modP(AA * BB);\n z_2 = modP(E * (AA + modP(a24 * E)));\n }\n // (x_2, x_3) = cswap(swap, x_2, x_3)\n sw = cswap(swap, x_2, x_3);\n x_2 = sw[0];\n x_3 = sw[1];\n // (z_2, z_3) = cswap(swap, z_2, z_3)\n sw = cswap(swap, z_2, z_3);\n z_2 = sw[0];\n z_3 = sw[1];\n // z_2^(p - 2)\n const z2 = powPminus2(z_2);\n // Return x_2 * (z_2^(p - 2))\n return modP(x_2 * z2);\n }\n function encodeUCoordinate(u) {\n return (0, $esaJO.numberToBytesLE)(modP(u), montgomeryBytes);\n }\n function decodeUCoordinate(uEnc) {\n // Section 5: When receiving such an array, implementations of X25519\n // MUST mask the most significant bit in the final byte.\n const u = (0, $esaJO.ensureBytes)('u coordinate', uEnc, montgomeryBytes);\n if (fieldLen === 32) u[31] &= 127; // 0b0111_1111\n return (0, $esaJO.bytesToNumberLE)(u);\n }\n function decodeScalar(n) {\n const bytes = (0, $esaJO.ensureBytes)('scalar', n);\n const len = bytes.length;\n if (len !== montgomeryBytes && len !== fieldLen) {\n let valid = '' + montgomeryBytes + ' or ' + fieldLen;\n throw new Error('invalid scalar, expected ' + valid + ' bytes, got ' + len);\n }\n return (0, $esaJO.bytesToNumberLE)(adjustScalarBytes(bytes));\n }\n function scalarMult(scalar, u) {\n const pointU = decodeUCoordinate(u);\n const _scalar = decodeScalar(scalar);\n const pu = montgomeryLadder(pointU, _scalar);\n // The result was not contributory\n // https://cr.yp.to/ecdh.html#validate\n if (pu === $ec7a218c4f0875a8$var$_0n) throw new Error('invalid private or public key received');\n return encodeUCoordinate(pu);\n }\n // Computes public key from private. By doing scalar multiplication of base point.\n const GuBytes = encodeUCoordinate(CURVE.Gu);\n function scalarMultBase(scalar) {\n return scalarMult(scalar, GuBytes);\n }\n return {\n scalarMult: scalarMult,\n scalarMultBase: scalarMultBase,\n getSharedSecret: (privateKey, publicKey)=>scalarMult(privateKey, publicKey),\n getPublicKey: (privateKey)=>scalarMultBase(privateKey),\n utils: {\n randomPrivateKey: ()=>CURVE.randomBytes(CURVE.nByteLength)\n },\n GuBytes: GuBytes\n };\n}\n\n});\n\n\nparcelRegister(\"dEXSZ\", function(module, exports) {\n\n(function(module1, exports) {\n 'use strict';\n // Utils\n function assert(val, msg) {\n if (!val) throw new Error(msg || 'Assertion failed');\n }\n // Could use `inherits` module, but don't want to move from single file\n // architecture yet.\n function inherits(ctor, superCtor) {\n ctor.super_ = superCtor;\n var TempCtor = function() {};\n TempCtor.prototype = superCtor.prototype;\n ctor.prototype = new TempCtor();\n ctor.prototype.constructor = ctor;\n }\n // BN\n function BN(number, base, endian) {\n if (BN.isBN(number)) return number;\n this.negative = 0;\n this.words = null;\n this.length = 0;\n // Reduction context\n this.red = null;\n if (number !== null) {\n if (base === 'le' || base === 'be') {\n endian = base;\n base = 10;\n }\n this._init(number || 0, base || 10, endian || 'be');\n }\n }\n if (typeof module1 === 'object') module1.exports = BN;\n else exports.BN = BN;\n BN.BN = BN;\n BN.wordSize = 26;\n var Buffer;\n try {\n if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') Buffer = window.Buffer;\n else Buffer = (parcelRequire(\"kjyEk\")).Buffer;\n } catch (e) {}\n BN.isBN = function isBN(num) {\n if (num instanceof BN) return true;\n return num !== null && typeof num === 'object' && num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);\n };\n BN.max = function max(left, right) {\n if (left.cmp(right) > 0) return left;\n return right;\n };\n BN.min = function min(left, right) {\n if (left.cmp(right) < 0) return left;\n return right;\n };\n BN.prototype._init = function init(number, base, endian) {\n if (typeof number === 'number') return this._initNumber(number, base, endian);\n if (typeof number === 'object') return this._initArray(number, base, endian);\n if (base === 'hex') base = 16;\n assert(base === (base | 0) && base >= 2 && base <= 36);\n number = number.toString().replace(/\\s+/g, '');\n var start = 0;\n if (number[0] === '-') {\n start++;\n this.negative = 1;\n }\n if (start < number.length) {\n if (base === 16) this._parseHex(number, start, endian);\n else {\n this._parseBase(number, base, start);\n if (endian === 'le') this._initArray(this.toArray(), base, endian);\n }\n }\n };\n BN.prototype._initNumber = function _initNumber(number, base, endian) {\n if (number < 0) {\n this.negative = 1;\n number = -number;\n }\n if (number < 0x4000000) {\n this.words = [\n number & 0x3ffffff\n ];\n this.length = 1;\n } else if (number < 0x10000000000000) {\n this.words = [\n number & 0x3ffffff,\n number / 0x4000000 & 0x3ffffff\n ];\n this.length = 2;\n } else {\n assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)\n this.words = [\n number & 0x3ffffff,\n number / 0x4000000 & 0x3ffffff,\n 1\n ];\n this.length = 3;\n }\n if (endian !== 'le') return;\n // Reverse the bytes\n this._initArray(this.toArray(), base, endian);\n };\n BN.prototype._initArray = function _initArray(number, base, endian) {\n // Perhaps a Uint8Array\n assert(typeof number.length === 'number');\n if (number.length <= 0) {\n this.words = [\n 0\n ];\n this.length = 1;\n return this;\n }\n this.length = Math.ceil(number.length / 3);\n this.words = new Array(this.length);\n for(var i = 0; i < this.length; i++)this.words[i] = 0;\n var j, w;\n var off = 0;\n if (endian === 'be') for(i = number.length - 1, j = 0; i >= 0; i -= 3){\n w = number[i] | number[i - 1] << 8 | number[i - 2] << 16;\n this.words[j] |= w << off & 0x3ffffff;\n this.words[j + 1] = w >>> 26 - off & 0x3ffffff;\n off += 24;\n if (off >= 26) {\n off -= 26;\n j++;\n }\n }\n else if (endian === 'le') for(i = 0, j = 0; i < number.length; i += 3){\n w = number[i] | number[i + 1] << 8 | number[i + 2] << 16;\n this.words[j] |= w << off & 0x3ffffff;\n this.words[j + 1] = w >>> 26 - off & 0x3ffffff;\n off += 24;\n if (off >= 26) {\n off -= 26;\n j++;\n }\n }\n return this._strip();\n };\n function parseHex4Bits(string, index) {\n var c = string.charCodeAt(index);\n // '0' - '9'\n if (c >= 48 && c <= 57) return c - 48;\n else if (c >= 65 && c <= 70) return c - 55;\n else if (c >= 97 && c <= 102) return c - 87;\n else assert(false, 'Invalid character in ' + string);\n }\n function parseHexByte(string, lowerBound, index) {\n var r = parseHex4Bits(string, index);\n if (index - 1 >= lowerBound) r |= parseHex4Bits(string, index - 1) << 4;\n return r;\n }\n BN.prototype._parseHex = function _parseHex(number, start, endian) {\n // Create possibly bigger array to ensure that it fits the number\n this.length = Math.ceil((number.length - start) / 6);\n this.words = new Array(this.length);\n for(var i = 0; i < this.length; i++)this.words[i] = 0;\n // 24-bits chunks\n var off = 0;\n var j = 0;\n var w;\n if (endian === 'be') for(i = number.length - 1; i >= start; i -= 2){\n w = parseHexByte(number, start, i) << off;\n this.words[j] |= w & 0x3ffffff;\n if (off >= 18) {\n off -= 18;\n j += 1;\n this.words[j] |= w >>> 26;\n } else off += 8;\n }\n else {\n var parseLength = number.length - start;\n for(i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2){\n w = parseHexByte(number, start, i) << off;\n this.words[j] |= w & 0x3ffffff;\n if (off >= 18) {\n off -= 18;\n j += 1;\n this.words[j] |= w >>> 26;\n } else off += 8;\n }\n }\n this._strip();\n };\n function parseBase(str, start, end, mul) {\n var r = 0;\n var b = 0;\n var len = Math.min(str.length, end);\n for(var i = start; i < len; i++){\n var c = str.charCodeAt(i) - 48;\n r *= mul;\n // 'a'\n if (c >= 49) b = c - 49 + 0xa;\n else if (c >= 17) b = c - 17 + 0xa;\n else b = c;\n assert(c >= 0 && b < mul, 'Invalid character');\n r += b;\n }\n return r;\n }\n BN.prototype._parseBase = function _parseBase(number, base, start) {\n // Initialize as zero\n this.words = [\n 0\n ];\n this.length = 1;\n // Find length of limb in base\n for(var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base)limbLen++;\n limbLen--;\n limbPow = limbPow / base | 0;\n var total = number.length - start;\n var mod = total % limbLen;\n var end = Math.min(total, total - mod) + start;\n var word = 0;\n for(var i = start; i < end; i += limbLen){\n word = parseBase(number, i, i + limbLen, base);\n this.imuln(limbPow);\n if (this.words[0] + word < 0x4000000) this.words[0] += word;\n else this._iaddn(word);\n }\n if (mod !== 0) {\n var pow = 1;\n word = parseBase(number, i, number.length, base);\n for(i = 0; i < mod; i++)pow *= base;\n this.imuln(pow);\n if (this.words[0] + word < 0x4000000) this.words[0] += word;\n else this._iaddn(word);\n }\n this._strip();\n };\n BN.prototype.copy = function copy(dest) {\n dest.words = new Array(this.length);\n for(var i = 0; i < this.length; i++)dest.words[i] = this.words[i];\n dest.length = this.length;\n dest.negative = this.negative;\n dest.red = this.red;\n };\n function move(dest, src) {\n dest.words = src.words;\n dest.length = src.length;\n dest.negative = src.negative;\n dest.red = src.red;\n }\n BN.prototype._move = function _move(dest) {\n move(dest, this);\n };\n BN.prototype.clone = function clone() {\n var r = new BN(null);\n this.copy(r);\n return r;\n };\n BN.prototype._expand = function _expand(size) {\n while(this.length < size)this.words[this.length++] = 0;\n return this;\n };\n // Remove leading `0` from `this`\n BN.prototype._strip = function strip() {\n while(this.length > 1 && this.words[this.length - 1] === 0)this.length--;\n return this._normSign();\n };\n BN.prototype._normSign = function _normSign() {\n // -0 = 0\n if (this.length === 1 && this.words[0] === 0) this.negative = 0;\n return this;\n };\n // Check Symbol.for because not everywhere where Symbol defined\n // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility\n if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') try {\n BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect;\n } catch (e) {\n BN.prototype.inspect = inspect;\n }\n else BN.prototype.inspect = inspect;\n function inspect() {\n return (this.red ? '';\n }\n /*\n\n var zeros = [];\n var groupSizes = [];\n var groupBases = [];\n\n var s = '';\n var i = -1;\n while (++i < BN.wordSize) {\n zeros[i] = s;\n s += '0';\n }\n groupSizes[0] = 0;\n groupSizes[1] = 0;\n groupBases[0] = 0;\n groupBases[1] = 0;\n var base = 2 - 1;\n while (++base < 36 + 1) {\n var groupSize = 0;\n var groupBase = 1;\n while (groupBase < (1 << BN.wordSize) / base) {\n groupBase *= base;\n groupSize += 1;\n }\n groupSizes[base] = groupSize;\n groupBases[base] = groupBase;\n }\n\n */ var zeros = [\n '',\n '0',\n '00',\n '000',\n '0000',\n '00000',\n '000000',\n '0000000',\n '00000000',\n '000000000',\n '0000000000',\n '00000000000',\n '000000000000',\n '0000000000000',\n '00000000000000',\n '000000000000000',\n '0000000000000000',\n '00000000000000000',\n '000000000000000000',\n '0000000000000000000',\n '00000000000000000000',\n '000000000000000000000',\n '0000000000000000000000',\n '00000000000000000000000',\n '000000000000000000000000',\n '0000000000000000000000000'\n ];\n var groupSizes = [\n 0,\n 0,\n 25,\n 16,\n 12,\n 11,\n 10,\n 9,\n 8,\n 8,\n 7,\n 7,\n 7,\n 7,\n 6,\n 6,\n 6,\n 6,\n 6,\n 6,\n 6,\n 5,\n 5,\n 5,\n 5,\n 5,\n 5,\n 5,\n 5,\n 5,\n 5,\n 5,\n 5,\n 5,\n 5,\n 5,\n 5\n ];\n var groupBases = [\n 0,\n 0,\n 33554432,\n 43046721,\n 16777216,\n 48828125,\n 60466176,\n 40353607,\n 16777216,\n 43046721,\n 10000000,\n 19487171,\n 35831808,\n 62748517,\n 7529536,\n 11390625,\n 16777216,\n 24137569,\n 34012224,\n 47045881,\n 64000000,\n 4084101,\n 5153632,\n 6436343,\n 7962624,\n 9765625,\n 11881376,\n 14348907,\n 17210368,\n 20511149,\n 24300000,\n 28629151,\n 33554432,\n 39135393,\n 45435424,\n 52521875,\n 60466176\n ];\n BN.prototype.toString = function toString(base, padding) {\n base = base || 10;\n padding = padding | 0 || 1;\n var out;\n if (base === 16 || base === 'hex') {\n out = '';\n var off = 0;\n var carry = 0;\n for(var i = 0; i < this.length; i++){\n var w = this.words[i];\n var word = ((w << off | carry) & 0xffffff).toString(16);\n carry = w >>> 24 - off & 0xffffff;\n off += 2;\n if (off >= 26) {\n off -= 26;\n i--;\n }\n if (carry !== 0 || i !== this.length - 1) out = zeros[6 - word.length] + word + out;\n else out = word + out;\n }\n if (carry !== 0) out = carry.toString(16) + out;\n while(out.length % padding !== 0)out = '0' + out;\n if (this.negative !== 0) out = '-' + out;\n return out;\n }\n if (base === (base | 0) && base >= 2 && base <= 36) {\n // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));\n var groupSize = groupSizes[base];\n // var groupBase = Math.pow(base, groupSize);\n var groupBase = groupBases[base];\n out = '';\n var c = this.clone();\n c.negative = 0;\n while(!c.isZero()){\n var r = c.modrn(groupBase).toString(base);\n c = c.idivn(groupBase);\n if (!c.isZero()) out = zeros[groupSize - r.length] + r + out;\n else out = r + out;\n }\n if (this.isZero()) out = '0' + out;\n while(out.length % padding !== 0)out = '0' + out;\n if (this.negative !== 0) out = '-' + out;\n return out;\n }\n assert(false, 'Base should be between 2 and 36');\n };\n BN.prototype.toNumber = function toNumber() {\n var ret = this.words[0];\n if (this.length === 2) ret += this.words[1] * 0x4000000;\n else if (this.length === 3 && this.words[2] === 0x01) // NOTE: at this stage it is known that the top bit is set\n ret += 0x10000000000000 + this.words[1] * 0x4000000;\n else if (this.length > 2) assert(false, 'Number can only safely store up to 53 bits');\n return this.negative !== 0 ? -ret : ret;\n };\n BN.prototype.toJSON = function toJSON() {\n return this.toString(16, 2);\n };\n if (Buffer) BN.prototype.toBuffer = function toBuffer(endian, length) {\n return this.toArrayLike(Buffer, endian, length);\n };\n BN.prototype.toArray = function toArray(endian, length) {\n return this.toArrayLike(Array, endian, length);\n };\n var allocate = function allocate(ArrayType, size) {\n if (ArrayType.allocUnsafe) return ArrayType.allocUnsafe(size);\n return new ArrayType(size);\n };\n BN.prototype.toArrayLike = function toArrayLike(ArrayType, endian, length) {\n this._strip();\n var byteLength = this.byteLength();\n var reqLength = length || Math.max(1, byteLength);\n assert(byteLength <= reqLength, 'byte array longer than desired length');\n assert(reqLength > 0, 'Requested array length <= 0');\n var res = allocate(ArrayType, reqLength);\n var postfix = endian === 'le' ? 'LE' : 'BE';\n this['_toArrayLike' + postfix](res, byteLength);\n return res;\n };\n BN.prototype._toArrayLikeLE = function _toArrayLikeLE(res, byteLength) {\n var position = 0;\n var carry = 0;\n for(var i = 0, shift = 0; i < this.length; i++){\n var word = this.words[i] << shift | carry;\n res[position++] = word & 0xff;\n if (position < res.length) res[position++] = word >> 8 & 0xff;\n if (position < res.length) res[position++] = word >> 16 & 0xff;\n if (shift === 6) {\n if (position < res.length) res[position++] = word >> 24 & 0xff;\n carry = 0;\n shift = 0;\n } else {\n carry = word >>> 24;\n shift += 2;\n }\n }\n if (position < res.length) {\n res[position++] = carry;\n while(position < res.length)res[position++] = 0;\n }\n };\n BN.prototype._toArrayLikeBE = function _toArrayLikeBE(res, byteLength) {\n var position = res.length - 1;\n var carry = 0;\n for(var i = 0, shift = 0; i < this.length; i++){\n var word = this.words[i] << shift | carry;\n res[position--] = word & 0xff;\n if (position >= 0) res[position--] = word >> 8 & 0xff;\n if (position >= 0) res[position--] = word >> 16 & 0xff;\n if (shift === 6) {\n if (position >= 0) res[position--] = word >> 24 & 0xff;\n carry = 0;\n shift = 0;\n } else {\n carry = word >>> 24;\n shift += 2;\n }\n }\n if (position >= 0) {\n res[position--] = carry;\n while(position >= 0)res[position--] = 0;\n }\n };\n if (Math.clz32) BN.prototype._countBits = function _countBits(w) {\n return 32 - Math.clz32(w);\n };\n else BN.prototype._countBits = function _countBits(w) {\n var t = w;\n var r = 0;\n if (t >= 0x1000) {\n r += 13;\n t >>>= 13;\n }\n if (t >= 0x40) {\n r += 7;\n t >>>= 7;\n }\n if (t >= 0x8) {\n r += 4;\n t >>>= 4;\n }\n if (t >= 0x02) {\n r += 2;\n t >>>= 2;\n }\n return r + t;\n };\n BN.prototype._zeroBits = function _zeroBits(w) {\n // Short-cut\n if (w === 0) return 26;\n var t = w;\n var r = 0;\n if ((t & 0x1fff) === 0) {\n r += 13;\n t >>>= 13;\n }\n if ((t & 0x7f) === 0) {\n r += 7;\n t >>>= 7;\n }\n if ((t & 0xf) === 0) {\n r += 4;\n t >>>= 4;\n }\n if ((t & 0x3) === 0) {\n r += 2;\n t >>>= 2;\n }\n if ((t & 0x1) === 0) r++;\n return r;\n };\n // Return number of used bits in a BN\n BN.prototype.bitLength = function bitLength() {\n var w = this.words[this.length - 1];\n var hi = this._countBits(w);\n return (this.length - 1) * 26 + hi;\n };\n function toBitArray(num) {\n var w = new Array(num.bitLength());\n for(var bit = 0; bit < w.length; bit++){\n var off = bit / 26 | 0;\n var wbit = bit % 26;\n w[bit] = num.words[off] >>> wbit & 0x01;\n }\n return w;\n }\n // Number of trailing zero bits\n BN.prototype.zeroBits = function zeroBits() {\n if (this.isZero()) return 0;\n var r = 0;\n for(var i = 0; i < this.length; i++){\n var b = this._zeroBits(this.words[i]);\n r += b;\n if (b !== 26) break;\n }\n return r;\n };\n BN.prototype.byteLength = function byteLength() {\n return Math.ceil(this.bitLength() / 8);\n };\n BN.prototype.toTwos = function toTwos(width) {\n if (this.negative !== 0) return this.abs().inotn(width).iaddn(1);\n return this.clone();\n };\n BN.prototype.fromTwos = function fromTwos(width) {\n if (this.testn(width - 1)) return this.notn(width).iaddn(1).ineg();\n return this.clone();\n };\n BN.prototype.isNeg = function isNeg() {\n return this.negative !== 0;\n };\n // Return negative clone of `this`\n BN.prototype.neg = function neg() {\n return this.clone().ineg();\n };\n BN.prototype.ineg = function ineg() {\n if (!this.isZero()) this.negative ^= 1;\n return this;\n };\n // Or `num` with `this` in-place\n BN.prototype.iuor = function iuor(num) {\n while(this.length < num.length)this.words[this.length++] = 0;\n for(var i = 0; i < num.length; i++)this.words[i] = this.words[i] | num.words[i];\n return this._strip();\n };\n BN.prototype.ior = function ior(num) {\n assert((this.negative | num.negative) === 0);\n return this.iuor(num);\n };\n // Or `num` with `this`\n BN.prototype.or = function or(num) {\n if (this.length > num.length) return this.clone().ior(num);\n return num.clone().ior(this);\n };\n BN.prototype.uor = function uor(num) {\n if (this.length > num.length) return this.clone().iuor(num);\n return num.clone().iuor(this);\n };\n // And `num` with `this` in-place\n BN.prototype.iuand = function iuand(num) {\n // b = min-length(num, this)\n var b;\n if (this.length > num.length) b = num;\n else b = this;\n for(var i = 0; i < b.length; i++)this.words[i] = this.words[i] & num.words[i];\n this.length = b.length;\n return this._strip();\n };\n BN.prototype.iand = function iand(num) {\n assert((this.negative | num.negative) === 0);\n return this.iuand(num);\n };\n // And `num` with `this`\n BN.prototype.and = function and(num) {\n if (this.length > num.length) return this.clone().iand(num);\n return num.clone().iand(this);\n };\n BN.prototype.uand = function uand(num) {\n if (this.length > num.length) return this.clone().iuand(num);\n return num.clone().iuand(this);\n };\n // Xor `num` with `this` in-place\n BN.prototype.iuxor = function iuxor(num) {\n // a.length > b.length\n var a;\n var b;\n if (this.length > num.length) {\n a = this;\n b = num;\n } else {\n a = num;\n b = this;\n }\n for(var i = 0; i < b.length; i++)this.words[i] = a.words[i] ^ b.words[i];\n if (this !== a) for(; i < a.length; i++)this.words[i] = a.words[i];\n this.length = a.length;\n return this._strip();\n };\n BN.prototype.ixor = function ixor(num) {\n assert((this.negative | num.negative) === 0);\n return this.iuxor(num);\n };\n // Xor `num` with `this`\n BN.prototype.xor = function xor(num) {\n if (this.length > num.length) return this.clone().ixor(num);\n return num.clone().ixor(this);\n };\n BN.prototype.uxor = function uxor(num) {\n if (this.length > num.length) return this.clone().iuxor(num);\n return num.clone().iuxor(this);\n };\n // Not ``this`` with ``width`` bitwidth\n BN.prototype.inotn = function inotn(width) {\n assert(typeof width === 'number' && width >= 0);\n var bytesNeeded = Math.ceil(width / 26) | 0;\n var bitsLeft = width % 26;\n // Extend the buffer with leading zeroes\n this._expand(bytesNeeded);\n if (bitsLeft > 0) bytesNeeded--;\n // Handle complete words\n for(var i = 0; i < bytesNeeded; i++)this.words[i] = ~this.words[i] & 0x3ffffff;\n // Handle the residue\n if (bitsLeft > 0) this.words[i] = ~this.words[i] & 0x3ffffff >> 26 - bitsLeft;\n // And remove leading zeroes\n return this._strip();\n };\n BN.prototype.notn = function notn(width) {\n return this.clone().inotn(width);\n };\n // Set `bit` of `this`\n BN.prototype.setn = function setn(bit, val) {\n assert(typeof bit === 'number' && bit >= 0);\n var off = bit / 26 | 0;\n var wbit = bit % 26;\n this._expand(off + 1);\n if (val) this.words[off] = this.words[off] | 1 << wbit;\n else this.words[off] = this.words[off] & ~(1 << wbit);\n return this._strip();\n };\n // Add `num` to `this` in-place\n BN.prototype.iadd = function iadd(num) {\n var r;\n // negative + positive\n if (this.negative !== 0 && num.negative === 0) {\n this.negative = 0;\n r = this.isub(num);\n this.negative ^= 1;\n return this._normSign();\n // positive + negative\n } else if (this.negative === 0 && num.negative !== 0) {\n num.negative = 0;\n r = this.isub(num);\n num.negative = 1;\n return r._normSign();\n }\n // a.length > b.length\n var a, b;\n if (this.length > num.length) {\n a = this;\n b = num;\n } else {\n a = num;\n b = this;\n }\n var carry = 0;\n for(var i = 0; i < b.length; i++){\n r = (a.words[i] | 0) + (b.words[i] | 0) + carry;\n this.words[i] = r & 0x3ffffff;\n carry = r >>> 26;\n }\n for(; carry !== 0 && i < a.length; i++){\n r = (a.words[i] | 0) + carry;\n this.words[i] = r & 0x3ffffff;\n carry = r >>> 26;\n }\n this.length = a.length;\n if (carry !== 0) {\n this.words[this.length] = carry;\n this.length++;\n // Copy the rest of the words\n } else if (a !== this) for(; i < a.length; i++)this.words[i] = a.words[i];\n return this;\n };\n // Add `num` to `this`\n BN.prototype.add = function add(num) {\n var res;\n if (num.negative !== 0 && this.negative === 0) {\n num.negative = 0;\n res = this.sub(num);\n num.negative ^= 1;\n return res;\n } else if (num.negative === 0 && this.negative !== 0) {\n this.negative = 0;\n res = num.sub(this);\n this.negative = 1;\n return res;\n }\n if (this.length > num.length) return this.clone().iadd(num);\n return num.clone().iadd(this);\n };\n // Subtract `num` from `this` in-place\n BN.prototype.isub = function isub(num) {\n // this - (-num) = this + num\n if (num.negative !== 0) {\n num.negative = 0;\n var r = this.iadd(num);\n num.negative = 1;\n return r._normSign();\n // -this - num = -(this + num)\n } else if (this.negative !== 0) {\n this.negative = 0;\n this.iadd(num);\n this.negative = 1;\n return this._normSign();\n }\n // At this point both numbers are positive\n var cmp = this.cmp(num);\n // Optimization - zeroify\n if (cmp === 0) {\n this.negative = 0;\n this.length = 1;\n this.words[0] = 0;\n return this;\n }\n // a > b\n var a, b;\n if (cmp > 0) {\n a = this;\n b = num;\n } else {\n a = num;\n b = this;\n }\n var carry = 0;\n for(var i = 0; i < b.length; i++){\n r = (a.words[i] | 0) - (b.words[i] | 0) + carry;\n carry = r >> 26;\n this.words[i] = r & 0x3ffffff;\n }\n for(; carry !== 0 && i < a.length; i++){\n r = (a.words[i] | 0) + carry;\n carry = r >> 26;\n this.words[i] = r & 0x3ffffff;\n }\n // Copy rest of the words\n if (carry === 0 && i < a.length && a !== this) for(; i < a.length; i++)this.words[i] = a.words[i];\n this.length = Math.max(this.length, i);\n if (a !== this) this.negative = 1;\n return this._strip();\n };\n // Subtract `num` from `this`\n BN.prototype.sub = function sub(num) {\n return this.clone().isub(num);\n };\n function smallMulTo(self, num, out) {\n out.negative = num.negative ^ self.negative;\n var len = self.length + num.length | 0;\n out.length = len;\n len = len - 1 | 0;\n // Peel one iteration (compiler can't do it, because of code complexity)\n var a = self.words[0] | 0;\n var b = num.words[0] | 0;\n var r = a * b;\n var lo = r & 0x3ffffff;\n var carry = r / 0x4000000 | 0;\n out.words[0] = lo;\n for(var k = 1; k < len; k++){\n // Sum all words with the same `i + j = k` and accumulate `ncarry`,\n // note that ncarry could be >= 0x3ffffff\n var ncarry = carry >>> 26;\n var rword = carry & 0x3ffffff;\n var maxJ = Math.min(k, num.length - 1);\n for(var j = Math.max(0, k - self.length + 1); j <= maxJ; j++){\n var i = k - j | 0;\n a = self.words[i] | 0;\n b = num.words[j] | 0;\n r = a * b + rword;\n ncarry += r / 0x4000000 | 0;\n rword = r & 0x3ffffff;\n }\n out.words[k] = rword | 0;\n carry = ncarry | 0;\n }\n if (carry !== 0) out.words[k] = carry | 0;\n else out.length--;\n return out._strip();\n }\n // TODO(indutny): it may be reasonable to omit it for users who don't need\n // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit\n // multiplication (like elliptic secp256k1).\n var comb10MulTo = function comb10MulTo(self, num, out) {\n var a = self.words;\n var b = num.words;\n var o = out.words;\n var c = 0;\n var lo;\n var mid;\n var hi;\n var a0 = a[0] | 0;\n var al0 = a0 & 0x1fff;\n var ah0 = a0 >>> 13;\n var a1 = a[1] | 0;\n var al1 = a1 & 0x1fff;\n var ah1 = a1 >>> 13;\n var a2 = a[2] | 0;\n var al2 = a2 & 0x1fff;\n var ah2 = a2 >>> 13;\n var a3 = a[3] | 0;\n var al3 = a3 & 0x1fff;\n var ah3 = a3 >>> 13;\n var a4 = a[4] | 0;\n var al4 = a4 & 0x1fff;\n var ah4 = a4 >>> 13;\n var a5 = a[5] | 0;\n var al5 = a5 & 0x1fff;\n var ah5 = a5 >>> 13;\n var a6 = a[6] | 0;\n var al6 = a6 & 0x1fff;\n var ah6 = a6 >>> 13;\n var a7 = a[7] | 0;\n var al7 = a7 & 0x1fff;\n var ah7 = a7 >>> 13;\n var a8 = a[8] | 0;\n var al8 = a8 & 0x1fff;\n var ah8 = a8 >>> 13;\n var a9 = a[9] | 0;\n var al9 = a9 & 0x1fff;\n var ah9 = a9 >>> 13;\n var b0 = b[0] | 0;\n var bl0 = b0 & 0x1fff;\n var bh0 = b0 >>> 13;\n var b1 = b[1] | 0;\n var bl1 = b1 & 0x1fff;\n var bh1 = b1 >>> 13;\n var b2 = b[2] | 0;\n var bl2 = b2 & 0x1fff;\n var bh2 = b2 >>> 13;\n var b3 = b[3] | 0;\n var bl3 = b3 & 0x1fff;\n var bh3 = b3 >>> 13;\n var b4 = b[4] | 0;\n var bl4 = b4 & 0x1fff;\n var bh4 = b4 >>> 13;\n var b5 = b[5] | 0;\n var bl5 = b5 & 0x1fff;\n var bh5 = b5 >>> 13;\n var b6 = b[6] | 0;\n var bl6 = b6 & 0x1fff;\n var bh6 = b6 >>> 13;\n var b7 = b[7] | 0;\n var bl7 = b7 & 0x1fff;\n var bh7 = b7 >>> 13;\n var b8 = b[8] | 0;\n var bl8 = b8 & 0x1fff;\n var bh8 = b8 >>> 13;\n var b9 = b[9] | 0;\n var bl9 = b9 & 0x1fff;\n var bh9 = b9 >>> 13;\n out.negative = self.negative ^ num.negative;\n out.length = 19;\n /* k = 0 */ lo = Math.imul(al0, bl0);\n mid = Math.imul(al0, bh0);\n mid = mid + Math.imul(ah0, bl0) | 0;\n hi = Math.imul(ah0, bh0);\n var w0 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w0 >>> 26) | 0;\n w0 &= 0x3ffffff;\n /* k = 1 */ lo = Math.imul(al1, bl0);\n mid = Math.imul(al1, bh0);\n mid = mid + Math.imul(ah1, bl0) | 0;\n hi = Math.imul(ah1, bh0);\n lo = lo + Math.imul(al0, bl1) | 0;\n mid = mid + Math.imul(al0, bh1) | 0;\n mid = mid + Math.imul(ah0, bl1) | 0;\n hi = hi + Math.imul(ah0, bh1) | 0;\n var w1 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w1 >>> 26) | 0;\n w1 &= 0x3ffffff;\n /* k = 2 */ lo = Math.imul(al2, bl0);\n mid = Math.imul(al2, bh0);\n mid = mid + Math.imul(ah2, bl0) | 0;\n hi = Math.imul(ah2, bh0);\n lo = lo + Math.imul(al1, bl1) | 0;\n mid = mid + Math.imul(al1, bh1) | 0;\n mid = mid + Math.imul(ah1, bl1) | 0;\n hi = hi + Math.imul(ah1, bh1) | 0;\n lo = lo + Math.imul(al0, bl2) | 0;\n mid = mid + Math.imul(al0, bh2) | 0;\n mid = mid + Math.imul(ah0, bl2) | 0;\n hi = hi + Math.imul(ah0, bh2) | 0;\n var w2 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w2 >>> 26) | 0;\n w2 &= 0x3ffffff;\n /* k = 3 */ lo = Math.imul(al3, bl0);\n mid = Math.imul(al3, bh0);\n mid = mid + Math.imul(ah3, bl0) | 0;\n hi = Math.imul(ah3, bh0);\n lo = lo + Math.imul(al2, bl1) | 0;\n mid = mid + Math.imul(al2, bh1) | 0;\n mid = mid + Math.imul(ah2, bl1) | 0;\n hi = hi + Math.imul(ah2, bh1) | 0;\n lo = lo + Math.imul(al1, bl2) | 0;\n mid = mid + Math.imul(al1, bh2) | 0;\n mid = mid + Math.imul(ah1, bl2) | 0;\n hi = hi + Math.imul(ah1, bh2) | 0;\n lo = lo + Math.imul(al0, bl3) | 0;\n mid = mid + Math.imul(al0, bh3) | 0;\n mid = mid + Math.imul(ah0, bl3) | 0;\n hi = hi + Math.imul(ah0, bh3) | 0;\n var w3 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w3 >>> 26) | 0;\n w3 &= 0x3ffffff;\n /* k = 4 */ lo = Math.imul(al4, bl0);\n mid = Math.imul(al4, bh0);\n mid = mid + Math.imul(ah4, bl0) | 0;\n hi = Math.imul(ah4, bh0);\n lo = lo + Math.imul(al3, bl1) | 0;\n mid = mid + Math.imul(al3, bh1) | 0;\n mid = mid + Math.imul(ah3, bl1) | 0;\n hi = hi + Math.imul(ah3, bh1) | 0;\n lo = lo + Math.imul(al2, bl2) | 0;\n mid = mid + Math.imul(al2, bh2) | 0;\n mid = mid + Math.imul(ah2, bl2) | 0;\n hi = hi + Math.imul(ah2, bh2) | 0;\n lo = lo + Math.imul(al1, bl3) | 0;\n mid = mid + Math.imul(al1, bh3) | 0;\n mid = mid + Math.imul(ah1, bl3) | 0;\n hi = hi + Math.imul(ah1, bh3) | 0;\n lo = lo + Math.imul(al0, bl4) | 0;\n mid = mid + Math.imul(al0, bh4) | 0;\n mid = mid + Math.imul(ah0, bl4) | 0;\n hi = hi + Math.imul(ah0, bh4) | 0;\n var w4 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w4 >>> 26) | 0;\n w4 &= 0x3ffffff;\n /* k = 5 */ lo = Math.imul(al5, bl0);\n mid = Math.imul(al5, bh0);\n mid = mid + Math.imul(ah5, bl0) | 0;\n hi = Math.imul(ah5, bh0);\n lo = lo + Math.imul(al4, bl1) | 0;\n mid = mid + Math.imul(al4, bh1) | 0;\n mid = mid + Math.imul(ah4, bl1) | 0;\n hi = hi + Math.imul(ah4, bh1) | 0;\n lo = lo + Math.imul(al3, bl2) | 0;\n mid = mid + Math.imul(al3, bh2) | 0;\n mid = mid + Math.imul(ah3, bl2) | 0;\n hi = hi + Math.imul(ah3, bh2) | 0;\n lo = lo + Math.imul(al2, bl3) | 0;\n mid = mid + Math.imul(al2, bh3) | 0;\n mid = mid + Math.imul(ah2, bl3) | 0;\n hi = hi + Math.imul(ah2, bh3) | 0;\n lo = lo + Math.imul(al1, bl4) | 0;\n mid = mid + Math.imul(al1, bh4) | 0;\n mid = mid + Math.imul(ah1, bl4) | 0;\n hi = hi + Math.imul(ah1, bh4) | 0;\n lo = lo + Math.imul(al0, bl5) | 0;\n mid = mid + Math.imul(al0, bh5) | 0;\n mid = mid + Math.imul(ah0, bl5) | 0;\n hi = hi + Math.imul(ah0, bh5) | 0;\n var w5 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w5 >>> 26) | 0;\n w5 &= 0x3ffffff;\n /* k = 6 */ lo = Math.imul(al6, bl0);\n mid = Math.imul(al6, bh0);\n mid = mid + Math.imul(ah6, bl0) | 0;\n hi = Math.imul(ah6, bh0);\n lo = lo + Math.imul(al5, bl1) | 0;\n mid = mid + Math.imul(al5, bh1) | 0;\n mid = mid + Math.imul(ah5, bl1) | 0;\n hi = hi + Math.imul(ah5, bh1) | 0;\n lo = lo + Math.imul(al4, bl2) | 0;\n mid = mid + Math.imul(al4, bh2) | 0;\n mid = mid + Math.imul(ah4, bl2) | 0;\n hi = hi + Math.imul(ah4, bh2) | 0;\n lo = lo + Math.imul(al3, bl3) | 0;\n mid = mid + Math.imul(al3, bh3) | 0;\n mid = mid + Math.imul(ah3, bl3) | 0;\n hi = hi + Math.imul(ah3, bh3) | 0;\n lo = lo + Math.imul(al2, bl4) | 0;\n mid = mid + Math.imul(al2, bh4) | 0;\n mid = mid + Math.imul(ah2, bl4) | 0;\n hi = hi + Math.imul(ah2, bh4) | 0;\n lo = lo + Math.imul(al1, bl5) | 0;\n mid = mid + Math.imul(al1, bh5) | 0;\n mid = mid + Math.imul(ah1, bl5) | 0;\n hi = hi + Math.imul(ah1, bh5) | 0;\n lo = lo + Math.imul(al0, bl6) | 0;\n mid = mid + Math.imul(al0, bh6) | 0;\n mid = mid + Math.imul(ah0, bl6) | 0;\n hi = hi + Math.imul(ah0, bh6) | 0;\n var w6 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w6 >>> 26) | 0;\n w6 &= 0x3ffffff;\n /* k = 7 */ lo = Math.imul(al7, bl0);\n mid = Math.imul(al7, bh0);\n mid = mid + Math.imul(ah7, bl0) | 0;\n hi = Math.imul(ah7, bh0);\n lo = lo + Math.imul(al6, bl1) | 0;\n mid = mid + Math.imul(al6, bh1) | 0;\n mid = mid + Math.imul(ah6, bl1) | 0;\n hi = hi + Math.imul(ah6, bh1) | 0;\n lo = lo + Math.imul(al5, bl2) | 0;\n mid = mid + Math.imul(al5, bh2) | 0;\n mid = mid + Math.imul(ah5, bl2) | 0;\n hi = hi + Math.imul(ah5, bh2) | 0;\n lo = lo + Math.imul(al4, bl3) | 0;\n mid = mid + Math.imul(al4, bh3) | 0;\n mid = mid + Math.imul(ah4, bl3) | 0;\n hi = hi + Math.imul(ah4, bh3) | 0;\n lo = lo + Math.imul(al3, bl4) | 0;\n mid = mid + Math.imul(al3, bh4) | 0;\n mid = mid + Math.imul(ah3, bl4) | 0;\n hi = hi + Math.imul(ah3, bh4) | 0;\n lo = lo + Math.imul(al2, bl5) | 0;\n mid = mid + Math.imul(al2, bh5) | 0;\n mid = mid + Math.imul(ah2, bl5) | 0;\n hi = hi + Math.imul(ah2, bh5) | 0;\n lo = lo + Math.imul(al1, bl6) | 0;\n mid = mid + Math.imul(al1, bh6) | 0;\n mid = mid + Math.imul(ah1, bl6) | 0;\n hi = hi + Math.imul(ah1, bh6) | 0;\n lo = lo + Math.imul(al0, bl7) | 0;\n mid = mid + Math.imul(al0, bh7) | 0;\n mid = mid + Math.imul(ah0, bl7) | 0;\n hi = hi + Math.imul(ah0, bh7) | 0;\n var w7 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w7 >>> 26) | 0;\n w7 &= 0x3ffffff;\n /* k = 8 */ lo = Math.imul(al8, bl0);\n mid = Math.imul(al8, bh0);\n mid = mid + Math.imul(ah8, bl0) | 0;\n hi = Math.imul(ah8, bh0);\n lo = lo + Math.imul(al7, bl1) | 0;\n mid = mid + Math.imul(al7, bh1) | 0;\n mid = mid + Math.imul(ah7, bl1) | 0;\n hi = hi + Math.imul(ah7, bh1) | 0;\n lo = lo + Math.imul(al6, bl2) | 0;\n mid = mid + Math.imul(al6, bh2) | 0;\n mid = mid + Math.imul(ah6, bl2) | 0;\n hi = hi + Math.imul(ah6, bh2) | 0;\n lo = lo + Math.imul(al5, bl3) | 0;\n mid = mid + Math.imul(al5, bh3) | 0;\n mid = mid + Math.imul(ah5, bl3) | 0;\n hi = hi + Math.imul(ah5, bh3) | 0;\n lo = lo + Math.imul(al4, bl4) | 0;\n mid = mid + Math.imul(al4, bh4) | 0;\n mid = mid + Math.imul(ah4, bl4) | 0;\n hi = hi + Math.imul(ah4, bh4) | 0;\n lo = lo + Math.imul(al3, bl5) | 0;\n mid = mid + Math.imul(al3, bh5) | 0;\n mid = mid + Math.imul(ah3, bl5) | 0;\n hi = hi + Math.imul(ah3, bh5) | 0;\n lo = lo + Math.imul(al2, bl6) | 0;\n mid = mid + Math.imul(al2, bh6) | 0;\n mid = mid + Math.imul(ah2, bl6) | 0;\n hi = hi + Math.imul(ah2, bh6) | 0;\n lo = lo + Math.imul(al1, bl7) | 0;\n mid = mid + Math.imul(al1, bh7) | 0;\n mid = mid + Math.imul(ah1, bl7) | 0;\n hi = hi + Math.imul(ah1, bh7) | 0;\n lo = lo + Math.imul(al0, bl8) | 0;\n mid = mid + Math.imul(al0, bh8) | 0;\n mid = mid + Math.imul(ah0, bl8) | 0;\n hi = hi + Math.imul(ah0, bh8) | 0;\n var w8 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w8 >>> 26) | 0;\n w8 &= 0x3ffffff;\n /* k = 9 */ lo = Math.imul(al9, bl0);\n mid = Math.imul(al9, bh0);\n mid = mid + Math.imul(ah9, bl0) | 0;\n hi = Math.imul(ah9, bh0);\n lo = lo + Math.imul(al8, bl1) | 0;\n mid = mid + Math.imul(al8, bh1) | 0;\n mid = mid + Math.imul(ah8, bl1) | 0;\n hi = hi + Math.imul(ah8, bh1) | 0;\n lo = lo + Math.imul(al7, bl2) | 0;\n mid = mid + Math.imul(al7, bh2) | 0;\n mid = mid + Math.imul(ah7, bl2) | 0;\n hi = hi + Math.imul(ah7, bh2) | 0;\n lo = lo + Math.imul(al6, bl3) | 0;\n mid = mid + Math.imul(al6, bh3) | 0;\n mid = mid + Math.imul(ah6, bl3) | 0;\n hi = hi + Math.imul(ah6, bh3) | 0;\n lo = lo + Math.imul(al5, bl4) | 0;\n mid = mid + Math.imul(al5, bh4) | 0;\n mid = mid + Math.imul(ah5, bl4) | 0;\n hi = hi + Math.imul(ah5, bh4) | 0;\n lo = lo + Math.imul(al4, bl5) | 0;\n mid = mid + Math.imul(al4, bh5) | 0;\n mid = mid + Math.imul(ah4, bl5) | 0;\n hi = hi + Math.imul(ah4, bh5) | 0;\n lo = lo + Math.imul(al3, bl6) | 0;\n mid = mid + Math.imul(al3, bh6) | 0;\n mid = mid + Math.imul(ah3, bl6) | 0;\n hi = hi + Math.imul(ah3, bh6) | 0;\n lo = lo + Math.imul(al2, bl7) | 0;\n mid = mid + Math.imul(al2, bh7) | 0;\n mid = mid + Math.imul(ah2, bl7) | 0;\n hi = hi + Math.imul(ah2, bh7) | 0;\n lo = lo + Math.imul(al1, bl8) | 0;\n mid = mid + Math.imul(al1, bh8) | 0;\n mid = mid + Math.imul(ah1, bl8) | 0;\n hi = hi + Math.imul(ah1, bh8) | 0;\n lo = lo + Math.imul(al0, bl9) | 0;\n mid = mid + Math.imul(al0, bh9) | 0;\n mid = mid + Math.imul(ah0, bl9) | 0;\n hi = hi + Math.imul(ah0, bh9) | 0;\n var w9 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w9 >>> 26) | 0;\n w9 &= 0x3ffffff;\n /* k = 10 */ lo = Math.imul(al9, bl1);\n mid = Math.imul(al9, bh1);\n mid = mid + Math.imul(ah9, bl1) | 0;\n hi = Math.imul(ah9, bh1);\n lo = lo + Math.imul(al8, bl2) | 0;\n mid = mid + Math.imul(al8, bh2) | 0;\n mid = mid + Math.imul(ah8, bl2) | 0;\n hi = hi + Math.imul(ah8, bh2) | 0;\n lo = lo + Math.imul(al7, bl3) | 0;\n mid = mid + Math.imul(al7, bh3) | 0;\n mid = mid + Math.imul(ah7, bl3) | 0;\n hi = hi + Math.imul(ah7, bh3) | 0;\n lo = lo + Math.imul(al6, bl4) | 0;\n mid = mid + Math.imul(al6, bh4) | 0;\n mid = mid + Math.imul(ah6, bl4) | 0;\n hi = hi + Math.imul(ah6, bh4) | 0;\n lo = lo + Math.imul(al5, bl5) | 0;\n mid = mid + Math.imul(al5, bh5) | 0;\n mid = mid + Math.imul(ah5, bl5) | 0;\n hi = hi + Math.imul(ah5, bh5) | 0;\n lo = lo + Math.imul(al4, bl6) | 0;\n mid = mid + Math.imul(al4, bh6) | 0;\n mid = mid + Math.imul(ah4, bl6) | 0;\n hi = hi + Math.imul(ah4, bh6) | 0;\n lo = lo + Math.imul(al3, bl7) | 0;\n mid = mid + Math.imul(al3, bh7) | 0;\n mid = mid + Math.imul(ah3, bl7) | 0;\n hi = hi + Math.imul(ah3, bh7) | 0;\n lo = lo + Math.imul(al2, bl8) | 0;\n mid = mid + Math.imul(al2, bh8) | 0;\n mid = mid + Math.imul(ah2, bl8) | 0;\n hi = hi + Math.imul(ah2, bh8) | 0;\n lo = lo + Math.imul(al1, bl9) | 0;\n mid = mid + Math.imul(al1, bh9) | 0;\n mid = mid + Math.imul(ah1, bl9) | 0;\n hi = hi + Math.imul(ah1, bh9) | 0;\n var w10 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w10 >>> 26) | 0;\n w10 &= 0x3ffffff;\n /* k = 11 */ lo = Math.imul(al9, bl2);\n mid = Math.imul(al9, bh2);\n mid = mid + Math.imul(ah9, bl2) | 0;\n hi = Math.imul(ah9, bh2);\n lo = lo + Math.imul(al8, bl3) | 0;\n mid = mid + Math.imul(al8, bh3) | 0;\n mid = mid + Math.imul(ah8, bl3) | 0;\n hi = hi + Math.imul(ah8, bh3) | 0;\n lo = lo + Math.imul(al7, bl4) | 0;\n mid = mid + Math.imul(al7, bh4) | 0;\n mid = mid + Math.imul(ah7, bl4) | 0;\n hi = hi + Math.imul(ah7, bh4) | 0;\n lo = lo + Math.imul(al6, bl5) | 0;\n mid = mid + Math.imul(al6, bh5) | 0;\n mid = mid + Math.imul(ah6, bl5) | 0;\n hi = hi + Math.imul(ah6, bh5) | 0;\n lo = lo + Math.imul(al5, bl6) | 0;\n mid = mid + Math.imul(al5, bh6) | 0;\n mid = mid + Math.imul(ah5, bl6) | 0;\n hi = hi + Math.imul(ah5, bh6) | 0;\n lo = lo + Math.imul(al4, bl7) | 0;\n mid = mid + Math.imul(al4, bh7) | 0;\n mid = mid + Math.imul(ah4, bl7) | 0;\n hi = hi + Math.imul(ah4, bh7) | 0;\n lo = lo + Math.imul(al3, bl8) | 0;\n mid = mid + Math.imul(al3, bh8) | 0;\n mid = mid + Math.imul(ah3, bl8) | 0;\n hi = hi + Math.imul(ah3, bh8) | 0;\n lo = lo + Math.imul(al2, bl9) | 0;\n mid = mid + Math.imul(al2, bh9) | 0;\n mid = mid + Math.imul(ah2, bl9) | 0;\n hi = hi + Math.imul(ah2, bh9) | 0;\n var w11 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w11 >>> 26) | 0;\n w11 &= 0x3ffffff;\n /* k = 12 */ lo = Math.imul(al9, bl3);\n mid = Math.imul(al9, bh3);\n mid = mid + Math.imul(ah9, bl3) | 0;\n hi = Math.imul(ah9, bh3);\n lo = lo + Math.imul(al8, bl4) | 0;\n mid = mid + Math.imul(al8, bh4) | 0;\n mid = mid + Math.imul(ah8, bl4) | 0;\n hi = hi + Math.imul(ah8, bh4) | 0;\n lo = lo + Math.imul(al7, bl5) | 0;\n mid = mid + Math.imul(al7, bh5) | 0;\n mid = mid + Math.imul(ah7, bl5) | 0;\n hi = hi + Math.imul(ah7, bh5) | 0;\n lo = lo + Math.imul(al6, bl6) | 0;\n mid = mid + Math.imul(al6, bh6) | 0;\n mid = mid + Math.imul(ah6, bl6) | 0;\n hi = hi + Math.imul(ah6, bh6) | 0;\n lo = lo + Math.imul(al5, bl7) | 0;\n mid = mid + Math.imul(al5, bh7) | 0;\n mid = mid + Math.imul(ah5, bl7) | 0;\n hi = hi + Math.imul(ah5, bh7) | 0;\n lo = lo + Math.imul(al4, bl8) | 0;\n mid = mid + Math.imul(al4, bh8) | 0;\n mid = mid + Math.imul(ah4, bl8) | 0;\n hi = hi + Math.imul(ah4, bh8) | 0;\n lo = lo + Math.imul(al3, bl9) | 0;\n mid = mid + Math.imul(al3, bh9) | 0;\n mid = mid + Math.imul(ah3, bl9) | 0;\n hi = hi + Math.imul(ah3, bh9) | 0;\n var w12 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w12 >>> 26) | 0;\n w12 &= 0x3ffffff;\n /* k = 13 */ lo = Math.imul(al9, bl4);\n mid = Math.imul(al9, bh4);\n mid = mid + Math.imul(ah9, bl4) | 0;\n hi = Math.imul(ah9, bh4);\n lo = lo + Math.imul(al8, bl5) | 0;\n mid = mid + Math.imul(al8, bh5) | 0;\n mid = mid + Math.imul(ah8, bl5) | 0;\n hi = hi + Math.imul(ah8, bh5) | 0;\n lo = lo + Math.imul(al7, bl6) | 0;\n mid = mid + Math.imul(al7, bh6) | 0;\n mid = mid + Math.imul(ah7, bl6) | 0;\n hi = hi + Math.imul(ah7, bh6) | 0;\n lo = lo + Math.imul(al6, bl7) | 0;\n mid = mid + Math.imul(al6, bh7) | 0;\n mid = mid + Math.imul(ah6, bl7) | 0;\n hi = hi + Math.imul(ah6, bh7) | 0;\n lo = lo + Math.imul(al5, bl8) | 0;\n mid = mid + Math.imul(al5, bh8) | 0;\n mid = mid + Math.imul(ah5, bl8) | 0;\n hi = hi + Math.imul(ah5, bh8) | 0;\n lo = lo + Math.imul(al4, bl9) | 0;\n mid = mid + Math.imul(al4, bh9) | 0;\n mid = mid + Math.imul(ah4, bl9) | 0;\n hi = hi + Math.imul(ah4, bh9) | 0;\n var w13 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w13 >>> 26) | 0;\n w13 &= 0x3ffffff;\n /* k = 14 */ lo = Math.imul(al9, bl5);\n mid = Math.imul(al9, bh5);\n mid = mid + Math.imul(ah9, bl5) | 0;\n hi = Math.imul(ah9, bh5);\n lo = lo + Math.imul(al8, bl6) | 0;\n mid = mid + Math.imul(al8, bh6) | 0;\n mid = mid + Math.imul(ah8, bl6) | 0;\n hi = hi + Math.imul(ah8, bh6) | 0;\n lo = lo + Math.imul(al7, bl7) | 0;\n mid = mid + Math.imul(al7, bh7) | 0;\n mid = mid + Math.imul(ah7, bl7) | 0;\n hi = hi + Math.imul(ah7, bh7) | 0;\n lo = lo + Math.imul(al6, bl8) | 0;\n mid = mid + Math.imul(al6, bh8) | 0;\n mid = mid + Math.imul(ah6, bl8) | 0;\n hi = hi + Math.imul(ah6, bh8) | 0;\n lo = lo + Math.imul(al5, bl9) | 0;\n mid = mid + Math.imul(al5, bh9) | 0;\n mid = mid + Math.imul(ah5, bl9) | 0;\n hi = hi + Math.imul(ah5, bh9) | 0;\n var w14 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w14 >>> 26) | 0;\n w14 &= 0x3ffffff;\n /* k = 15 */ lo = Math.imul(al9, bl6);\n mid = Math.imul(al9, bh6);\n mid = mid + Math.imul(ah9, bl6) | 0;\n hi = Math.imul(ah9, bh6);\n lo = lo + Math.imul(al8, bl7) | 0;\n mid = mid + Math.imul(al8, bh7) | 0;\n mid = mid + Math.imul(ah8, bl7) | 0;\n hi = hi + Math.imul(ah8, bh7) | 0;\n lo = lo + Math.imul(al7, bl8) | 0;\n mid = mid + Math.imul(al7, bh8) | 0;\n mid = mid + Math.imul(ah7, bl8) | 0;\n hi = hi + Math.imul(ah7, bh8) | 0;\n lo = lo + Math.imul(al6, bl9) | 0;\n mid = mid + Math.imul(al6, bh9) | 0;\n mid = mid + Math.imul(ah6, bl9) | 0;\n hi = hi + Math.imul(ah6, bh9) | 0;\n var w15 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w15 >>> 26) | 0;\n w15 &= 0x3ffffff;\n /* k = 16 */ lo = Math.imul(al9, bl7);\n mid = Math.imul(al9, bh7);\n mid = mid + Math.imul(ah9, bl7) | 0;\n hi = Math.imul(ah9, bh7);\n lo = lo + Math.imul(al8, bl8) | 0;\n mid = mid + Math.imul(al8, bh8) | 0;\n mid = mid + Math.imul(ah8, bl8) | 0;\n hi = hi + Math.imul(ah8, bh8) | 0;\n lo = lo + Math.imul(al7, bl9) | 0;\n mid = mid + Math.imul(al7, bh9) | 0;\n mid = mid + Math.imul(ah7, bl9) | 0;\n hi = hi + Math.imul(ah7, bh9) | 0;\n var w16 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w16 >>> 26) | 0;\n w16 &= 0x3ffffff;\n /* k = 17 */ lo = Math.imul(al9, bl8);\n mid = Math.imul(al9, bh8);\n mid = mid + Math.imul(ah9, bl8) | 0;\n hi = Math.imul(ah9, bh8);\n lo = lo + Math.imul(al8, bl9) | 0;\n mid = mid + Math.imul(al8, bh9) | 0;\n mid = mid + Math.imul(ah8, bl9) | 0;\n hi = hi + Math.imul(ah8, bh9) | 0;\n var w17 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w17 >>> 26) | 0;\n w17 &= 0x3ffffff;\n /* k = 18 */ lo = Math.imul(al9, bl9);\n mid = Math.imul(al9, bh9);\n mid = mid + Math.imul(ah9, bl9) | 0;\n hi = Math.imul(ah9, bh9);\n var w18 = (c + lo | 0) + ((mid & 0x1fff) << 13) | 0;\n c = (hi + (mid >>> 13) | 0) + (w18 >>> 26) | 0;\n w18 &= 0x3ffffff;\n o[0] = w0;\n o[1] = w1;\n o[2] = w2;\n o[3] = w3;\n o[4] = w4;\n o[5] = w5;\n o[6] = w6;\n o[7] = w7;\n o[8] = w8;\n o[9] = w9;\n o[10] = w10;\n o[11] = w11;\n o[12] = w12;\n o[13] = w13;\n o[14] = w14;\n o[15] = w15;\n o[16] = w16;\n o[17] = w17;\n o[18] = w18;\n if (c !== 0) {\n o[19] = c;\n out.length++;\n }\n return out;\n };\n // Polyfill comb\n if (!Math.imul) comb10MulTo = smallMulTo;\n function bigMulTo(self, num, out) {\n out.negative = num.negative ^ self.negative;\n out.length = self.length + num.length;\n var carry = 0;\n var hncarry = 0;\n for(var k = 0; k < out.length - 1; k++){\n // Sum all words with the same `i + j = k` and accumulate `ncarry`,\n // note that ncarry could be >= 0x3ffffff\n var ncarry = hncarry;\n hncarry = 0;\n var rword = carry & 0x3ffffff;\n var maxJ = Math.min(k, num.length - 1);\n for(var j = Math.max(0, k - self.length + 1); j <= maxJ; j++){\n var i = k - j;\n var a = self.words[i] | 0;\n var b = num.words[j] | 0;\n var r = a * b;\n var lo = r & 0x3ffffff;\n ncarry = ncarry + (r / 0x4000000 | 0) | 0;\n lo = lo + rword | 0;\n rword = lo & 0x3ffffff;\n ncarry = ncarry + (lo >>> 26) | 0;\n hncarry += ncarry >>> 26;\n ncarry &= 0x3ffffff;\n }\n out.words[k] = rword;\n carry = ncarry;\n ncarry = hncarry;\n }\n if (carry !== 0) out.words[k] = carry;\n else out.length--;\n return out._strip();\n }\n function jumboMulTo(self, num, out) {\n // Temporary disable, see https://github.com/indutny/bn.js/issues/211\n // var fftm = new FFTM();\n // return fftm.mulp(self, num, out);\n return bigMulTo(self, num, out);\n }\n BN.prototype.mulTo = function mulTo(num, out) {\n var res;\n var len = this.length + num.length;\n if (this.length === 10 && num.length === 10) res = comb10MulTo(this, num, out);\n else if (len < 63) res = smallMulTo(this, num, out);\n else if (len < 1024) res = bigMulTo(this, num, out);\n else res = jumboMulTo(this, num, out);\n return res;\n };\n // Cooley-Tukey algorithm for FFT\n // slightly revisited to rely on looping instead of recursion\n function FFTM(x, y) {\n this.x = x;\n this.y = y;\n }\n FFTM.prototype.makeRBT = function makeRBT(N) {\n var t = new Array(N);\n var l = BN.prototype._countBits(N) - 1;\n for(var i = 0; i < N; i++)t[i] = this.revBin(i, l, N);\n return t;\n };\n // Returns binary-reversed representation of `x`\n FFTM.prototype.revBin = function revBin(x, l, N) {\n if (x === 0 || x === N - 1) return x;\n var rb = 0;\n for(var i = 0; i < l; i++){\n rb |= (x & 1) << l - i - 1;\n x >>= 1;\n }\n return rb;\n };\n // Performs \"tweedling\" phase, therefore 'emulating'\n // behaviour of the recursive algorithm\n FFTM.prototype.permute = function permute(rbt, rws, iws, rtws, itws, N) {\n for(var i = 0; i < N; i++){\n rtws[i] = rws[rbt[i]];\n itws[i] = iws[rbt[i]];\n }\n };\n FFTM.prototype.transform = function transform(rws, iws, rtws, itws, N, rbt) {\n this.permute(rbt, rws, iws, rtws, itws, N);\n for(var s = 1; s < N; s <<= 1){\n var l = s << 1;\n var rtwdf = Math.cos(2 * Math.PI / l);\n var itwdf = Math.sin(2 * Math.PI / l);\n for(var p = 0; p < N; p += l){\n var rtwdf_ = rtwdf;\n var itwdf_ = itwdf;\n for(var j = 0; j < s; j++){\n var re = rtws[p + j];\n var ie = itws[p + j];\n var ro = rtws[p + j + s];\n var io = itws[p + j + s];\n var rx = rtwdf_ * ro - itwdf_ * io;\n io = rtwdf_ * io + itwdf_ * ro;\n ro = rx;\n rtws[p + j] = re + ro;\n itws[p + j] = ie + io;\n rtws[p + j + s] = re - ro;\n itws[p + j + s] = ie - io;\n /* jshint maxdepth : false */ if (j !== l) {\n rx = rtwdf * rtwdf_ - itwdf * itwdf_;\n itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;\n rtwdf_ = rx;\n }\n }\n }\n }\n };\n FFTM.prototype.guessLen13b = function guessLen13b(n, m) {\n var N = Math.max(m, n) | 1;\n var odd = N & 1;\n var i = 0;\n for(N = N / 2 | 0; N; N = N >>> 1)i++;\n return 1 << i + 1 + odd;\n };\n FFTM.prototype.conjugate = function conjugate(rws, iws, N) {\n if (N <= 1) return;\n for(var i = 0; i < N / 2; i++){\n var t = rws[i];\n rws[i] = rws[N - i - 1];\n rws[N - i - 1] = t;\n t = iws[i];\n iws[i] = -iws[N - i - 1];\n iws[N - i - 1] = -t;\n }\n };\n FFTM.prototype.normalize13b = function normalize13b(ws, N) {\n var carry = 0;\n for(var i = 0; i < N / 2; i++){\n var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + Math.round(ws[2 * i] / N) + carry;\n ws[i] = w & 0x3ffffff;\n if (w < 0x4000000) carry = 0;\n else carry = w / 0x4000000 | 0;\n }\n return ws;\n };\n FFTM.prototype.convert13b = function convert13b(ws, len, rws, N) {\n var carry = 0;\n for(var i = 0; i < len; i++){\n carry = carry + (ws[i] | 0);\n rws[2 * i] = carry & 0x1fff;\n carry = carry >>> 13;\n rws[2 * i + 1] = carry & 0x1fff;\n carry = carry >>> 13;\n }\n // Pad with zeroes\n for(i = 2 * len; i < N; ++i)rws[i] = 0;\n assert(carry === 0);\n assert((carry & -8192) === 0);\n };\n FFTM.prototype.stub = function stub(N) {\n var ph = new Array(N);\n for(var i = 0; i < N; i++)ph[i] = 0;\n return ph;\n };\n FFTM.prototype.mulp = function mulp(x, y, out) {\n var N = 2 * this.guessLen13b(x.length, y.length);\n var rbt = this.makeRBT(N);\n var _ = this.stub(N);\n var rws = new Array(N);\n var rwst = new Array(N);\n var iwst = new Array(N);\n var nrws = new Array(N);\n var nrwst = new Array(N);\n var niwst = new Array(N);\n var rmws = out.words;\n rmws.length = N;\n this.convert13b(x.words, x.length, rws, N);\n this.convert13b(y.words, y.length, nrws, N);\n this.transform(rws, _, rwst, iwst, N, rbt);\n this.transform(nrws, _, nrwst, niwst, N, rbt);\n for(var i = 0; i < N; i++){\n var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];\n iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];\n rwst[i] = rx;\n }\n this.conjugate(rwst, iwst, N);\n this.transform(rwst, iwst, rmws, _, N, rbt);\n this.conjugate(rmws, _, N);\n this.normalize13b(rmws, N);\n out.negative = x.negative ^ y.negative;\n out.length = x.length + y.length;\n return out._strip();\n };\n // Multiply `this` by `num`\n BN.prototype.mul = function mul(num) {\n var out = new BN(null);\n out.words = new Array(this.length + num.length);\n return this.mulTo(num, out);\n };\n // Multiply employing FFT\n BN.prototype.mulf = function mulf(num) {\n var out = new BN(null);\n out.words = new Array(this.length + num.length);\n return jumboMulTo(this, num, out);\n };\n // In-place Multiplication\n BN.prototype.imul = function imul(num) {\n return this.clone().mulTo(num, this);\n };\n BN.prototype.imuln = function imuln(num) {\n var isNegNum = num < 0;\n if (isNegNum) num = -num;\n assert(typeof num === 'number');\n assert(num < 0x4000000);\n // Carry\n var carry = 0;\n for(var i = 0; i < this.length; i++){\n var w = (this.words[i] | 0) * num;\n var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);\n carry >>= 26;\n carry += w / 0x4000000 | 0;\n // NOTE: lo is 27bit maximum\n carry += lo >>> 26;\n this.words[i] = lo & 0x3ffffff;\n }\n if (carry !== 0) {\n this.words[i] = carry;\n this.length++;\n }\n return isNegNum ? this.ineg() : this;\n };\n BN.prototype.muln = function muln(num) {\n return this.clone().imuln(num);\n };\n // `this` * `this`\n BN.prototype.sqr = function sqr() {\n return this.mul(this);\n };\n // `this` * `this` in-place\n BN.prototype.isqr = function isqr() {\n return this.imul(this.clone());\n };\n // Math.pow(`this`, `num`)\n BN.prototype.pow = function pow(num) {\n var w = toBitArray(num);\n if (w.length === 0) return new BN(1);\n // Skip leading zeroes\n var res = this;\n for(var i = 0; i < w.length; i++, res = res.sqr()){\n if (w[i] !== 0) break;\n }\n if (++i < w.length) for(var q = res.sqr(); i < w.length; i++, q = q.sqr()){\n if (w[i] === 0) continue;\n res = res.mul(q);\n }\n return res;\n };\n // Shift-left in-place\n BN.prototype.iushln = function iushln(bits) {\n assert(typeof bits === 'number' && bits >= 0);\n var r = bits % 26;\n var s = (bits - r) / 26;\n var carryMask = 0x3ffffff >>> 26 - r << 26 - r;\n var i;\n if (r !== 0) {\n var carry = 0;\n for(i = 0; i < this.length; i++){\n var newCarry = this.words[i] & carryMask;\n var c = (this.words[i] | 0) - newCarry << r;\n this.words[i] = c | carry;\n carry = newCarry >>> 26 - r;\n }\n if (carry) {\n this.words[i] = carry;\n this.length++;\n }\n }\n if (s !== 0) {\n for(i = this.length - 1; i >= 0; i--)this.words[i + s] = this.words[i];\n for(i = 0; i < s; i++)this.words[i] = 0;\n this.length += s;\n }\n return this._strip();\n };\n BN.prototype.ishln = function ishln(bits) {\n // TODO(indutny): implement me\n assert(this.negative === 0);\n return this.iushln(bits);\n };\n // Shift-right in-place\n // NOTE: `hint` is a lowest bit before trailing zeroes\n // NOTE: if `extended` is present - it will be filled with destroyed bits\n BN.prototype.iushrn = function iushrn(bits, hint, extended) {\n assert(typeof bits === 'number' && bits >= 0);\n var h;\n if (hint) h = (hint - hint % 26) / 26;\n else h = 0;\n var r = bits % 26;\n var s = Math.min((bits - r) / 26, this.length);\n var mask = 0x3ffffff ^ 0x3ffffff >>> r << r;\n var maskedWords = extended;\n h -= s;\n h = Math.max(0, h);\n // Extended mode, copy masked part\n if (maskedWords) {\n for(var i = 0; i < s; i++)maskedWords.words[i] = this.words[i];\n maskedWords.length = s;\n }\n if (s === 0) ;\n else if (this.length > s) {\n this.length -= s;\n for(i = 0; i < this.length; i++)this.words[i] = this.words[i + s];\n } else {\n this.words[0] = 0;\n this.length = 1;\n }\n var carry = 0;\n for(i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--){\n var word = this.words[i] | 0;\n this.words[i] = carry << 26 - r | word >>> r;\n carry = word & mask;\n }\n // Push carried bits as a mask\n if (maskedWords && carry !== 0) maskedWords.words[maskedWords.length++] = carry;\n if (this.length === 0) {\n this.words[0] = 0;\n this.length = 1;\n }\n return this._strip();\n };\n BN.prototype.ishrn = function ishrn(bits, hint, extended) {\n // TODO(indutny): implement me\n assert(this.negative === 0);\n return this.iushrn(bits, hint, extended);\n };\n // Shift-left\n BN.prototype.shln = function shln(bits) {\n return this.clone().ishln(bits);\n };\n BN.prototype.ushln = function ushln(bits) {\n return this.clone().iushln(bits);\n };\n // Shift-right\n BN.prototype.shrn = function shrn(bits) {\n return this.clone().ishrn(bits);\n };\n BN.prototype.ushrn = function ushrn(bits) {\n return this.clone().iushrn(bits);\n };\n // Test if n bit is set\n BN.prototype.testn = function testn(bit) {\n assert(typeof bit === 'number' && bit >= 0);\n var r = bit % 26;\n var s = (bit - r) / 26;\n var q = 1 << r;\n // Fast case: bit is much higher than all existing words\n if (this.length <= s) return false;\n // Check bit and return\n var w = this.words[s];\n return !!(w & q);\n };\n // Return only lowers bits of number (in-place)\n BN.prototype.imaskn = function imaskn(bits) {\n assert(typeof bits === 'number' && bits >= 0);\n var r = bits % 26;\n var s = (bits - r) / 26;\n assert(this.negative === 0, 'imaskn works only with positive numbers');\n if (this.length <= s) return this;\n if (r !== 0) s++;\n this.length = Math.min(s, this.length);\n if (r !== 0) {\n var mask = 0x3ffffff ^ 0x3ffffff >>> r << r;\n this.words[this.length - 1] &= mask;\n }\n return this._strip();\n };\n // Return only lowers bits of number\n BN.prototype.maskn = function maskn(bits) {\n return this.clone().imaskn(bits);\n };\n // Add plain number `num` to `this`\n BN.prototype.iaddn = function iaddn(num) {\n assert(typeof num === 'number');\n assert(num < 0x4000000);\n if (num < 0) return this.isubn(-num);\n // Possible sign change\n if (this.negative !== 0) {\n if (this.length === 1 && (this.words[0] | 0) <= num) {\n this.words[0] = num - (this.words[0] | 0);\n this.negative = 0;\n return this;\n }\n this.negative = 0;\n this.isubn(num);\n this.negative = 1;\n return this;\n }\n // Add without checks\n return this._iaddn(num);\n };\n BN.prototype._iaddn = function _iaddn(num) {\n this.words[0] += num;\n // Carry\n for(var i = 0; i < this.length && this.words[i] >= 0x4000000; i++){\n this.words[i] -= 0x4000000;\n if (i === this.length - 1) this.words[i + 1] = 1;\n else this.words[i + 1]++;\n }\n this.length = Math.max(this.length, i + 1);\n return this;\n };\n // Subtract plain number `num` from `this`\n BN.prototype.isubn = function isubn(num) {\n assert(typeof num === 'number');\n assert(num < 0x4000000);\n if (num < 0) return this.iaddn(-num);\n if (this.negative !== 0) {\n this.negative = 0;\n this.iaddn(num);\n this.negative = 1;\n return this;\n }\n this.words[0] -= num;\n if (this.length === 1 && this.words[0] < 0) {\n this.words[0] = -this.words[0];\n this.negative = 1;\n } else // Carry\n for(var i = 0; i < this.length && this.words[i] < 0; i++){\n this.words[i] += 0x4000000;\n this.words[i + 1] -= 1;\n }\n return this._strip();\n };\n BN.prototype.addn = function addn(num) {\n return this.clone().iaddn(num);\n };\n BN.prototype.subn = function subn(num) {\n return this.clone().isubn(num);\n };\n BN.prototype.iabs = function iabs() {\n this.negative = 0;\n return this;\n };\n BN.prototype.abs = function abs() {\n return this.clone().iabs();\n };\n BN.prototype._ishlnsubmul = function _ishlnsubmul(num, mul, shift) {\n var len = num.length + shift;\n var i;\n this._expand(len);\n var w;\n var carry = 0;\n for(i = 0; i < num.length; i++){\n w = (this.words[i + shift] | 0) + carry;\n var right = (num.words[i] | 0) * mul;\n w -= right & 0x3ffffff;\n carry = (w >> 26) - (right / 0x4000000 | 0);\n this.words[i + shift] = w & 0x3ffffff;\n }\n for(; i < this.length - shift; i++){\n w = (this.words[i + shift] | 0) + carry;\n carry = w >> 26;\n this.words[i + shift] = w & 0x3ffffff;\n }\n if (carry === 0) return this._strip();\n // Subtraction overflow\n assert(carry === -1);\n carry = 0;\n for(i = 0; i < this.length; i++){\n w = -(this.words[i] | 0) + carry;\n carry = w >> 26;\n this.words[i] = w & 0x3ffffff;\n }\n this.negative = 1;\n return this._strip();\n };\n BN.prototype._wordDiv = function _wordDiv(num, mode) {\n var shift = this.length - num.length;\n var a = this.clone();\n var b = num;\n // Normalize\n var bhi = b.words[b.length - 1] | 0;\n var bhiBits = this._countBits(bhi);\n shift = 26 - bhiBits;\n if (shift !== 0) {\n b = b.ushln(shift);\n a.iushln(shift);\n bhi = b.words[b.length - 1] | 0;\n }\n // Initialize quotient\n var m = a.length - b.length;\n var q;\n if (mode !== 'mod') {\n q = new BN(null);\n q.length = m + 1;\n q.words = new Array(q.length);\n for(var i = 0; i < q.length; i++)q.words[i] = 0;\n }\n var diff = a.clone()._ishlnsubmul(b, 1, m);\n if (diff.negative === 0) {\n a = diff;\n if (q) q.words[m] = 1;\n }\n for(var j = m - 1; j >= 0; j--){\n var qj = (a.words[b.length + j] | 0) * 0x4000000 + (a.words[b.length + j - 1] | 0);\n // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max\n // (0x7ffffff)\n qj = Math.min(qj / bhi | 0, 0x3ffffff);\n a._ishlnsubmul(b, qj, j);\n while(a.negative !== 0){\n qj--;\n a.negative = 0;\n a._ishlnsubmul(b, 1, j);\n if (!a.isZero()) a.negative ^= 1;\n }\n if (q) q.words[j] = qj;\n }\n if (q) q._strip();\n a._strip();\n // Denormalize\n if (mode !== 'div' && shift !== 0) a.iushrn(shift);\n return {\n div: q || null,\n mod: a\n };\n };\n // NOTE: 1) `mode` can be set to `mod` to request mod only,\n // to `div` to request div only, or be absent to\n // request both div & mod\n // 2) `positive` is true if unsigned mod is requested\n BN.prototype.divmod = function divmod(num, mode, positive) {\n assert(!num.isZero());\n if (this.isZero()) return {\n div: new BN(0),\n mod: new BN(0)\n };\n var div, mod, res;\n if (this.negative !== 0 && num.negative === 0) {\n res = this.neg().divmod(num, mode);\n if (mode !== 'mod') div = res.div.neg();\n if (mode !== 'div') {\n mod = res.mod.neg();\n if (positive && mod.negative !== 0) mod.iadd(num);\n }\n return {\n div: div,\n mod: mod\n };\n }\n if (this.negative === 0 && num.negative !== 0) {\n res = this.divmod(num.neg(), mode);\n if (mode !== 'mod') div = res.div.neg();\n return {\n div: div,\n mod: res.mod\n };\n }\n if ((this.negative & num.negative) !== 0) {\n res = this.neg().divmod(num.neg(), mode);\n if (mode !== 'div') {\n mod = res.mod.neg();\n if (positive && mod.negative !== 0) mod.isub(num);\n }\n return {\n div: res.div,\n mod: mod\n };\n }\n // Both numbers are positive at this point\n // Strip both numbers to approximate shift value\n if (num.length > this.length || this.cmp(num) < 0) return {\n div: new BN(0),\n mod: this\n };\n // Very short reduction\n if (num.length === 1) {\n if (mode === 'div') return {\n div: this.divn(num.words[0]),\n mod: null\n };\n if (mode === 'mod') return {\n div: null,\n mod: new BN(this.modrn(num.words[0]))\n };\n return {\n div: this.divn(num.words[0]),\n mod: new BN(this.modrn(num.words[0]))\n };\n }\n return this._wordDiv(num, mode);\n };\n // Find `this` / `num`\n BN.prototype.div = function div(num) {\n return this.divmod(num, 'div', false).div;\n };\n // Find `this` % `num`\n BN.prototype.mod = function mod(num) {\n return this.divmod(num, 'mod', false).mod;\n };\n BN.prototype.umod = function umod(num) {\n return this.divmod(num, 'mod', true).mod;\n };\n // Find Round(`this` / `num`)\n BN.prototype.divRound = function divRound(num) {\n var dm = this.divmod(num);\n // Fast case - exact division\n if (dm.mod.isZero()) return dm.div;\n var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;\n var half = num.ushrn(1);\n var r2 = num.andln(1);\n var cmp = mod.cmp(half);\n // Round down\n if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;\n // Round up\n return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);\n };\n BN.prototype.modrn = function modrn(num) {\n var isNegNum = num < 0;\n if (isNegNum) num = -num;\n assert(num <= 0x3ffffff);\n var p = 67108864 % num;\n var acc = 0;\n for(var i = this.length - 1; i >= 0; i--)acc = (p * acc + (this.words[i] | 0)) % num;\n return isNegNum ? -acc : acc;\n };\n // WARNING: DEPRECATED\n BN.prototype.modn = function modn(num) {\n return this.modrn(num);\n };\n // In-place division by number\n BN.prototype.idivn = function idivn(num) {\n var isNegNum = num < 0;\n if (isNegNum) num = -num;\n assert(num <= 0x3ffffff);\n var carry = 0;\n for(var i = this.length - 1; i >= 0; i--){\n var w = (this.words[i] | 0) + carry * 0x4000000;\n this.words[i] = w / num | 0;\n carry = w % num;\n }\n this._strip();\n return isNegNum ? this.ineg() : this;\n };\n BN.prototype.divn = function divn(num) {\n return this.clone().idivn(num);\n };\n BN.prototype.egcd = function egcd(p) {\n assert(p.negative === 0);\n assert(!p.isZero());\n var x = this;\n var y = p.clone();\n if (x.negative !== 0) x = x.umod(p);\n else x = x.clone();\n // A * x + B * y = x\n var A = new BN(1);\n var B = new BN(0);\n // C * x + D * y = y\n var C = new BN(0);\n var D = new BN(1);\n var g = 0;\n while(x.isEven() && y.isEven()){\n x.iushrn(1);\n y.iushrn(1);\n ++g;\n }\n var yp = y.clone();\n var xp = x.clone();\n while(!x.isZero()){\n for(var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);\n if (i > 0) {\n x.iushrn(i);\n while(i-- > 0){\n if (A.isOdd() || B.isOdd()) {\n A.iadd(yp);\n B.isub(xp);\n }\n A.iushrn(1);\n B.iushrn(1);\n }\n }\n for(var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);\n if (j > 0) {\n y.iushrn(j);\n while(j-- > 0){\n if (C.isOdd() || D.isOdd()) {\n C.iadd(yp);\n D.isub(xp);\n }\n C.iushrn(1);\n D.iushrn(1);\n }\n }\n if (x.cmp(y) >= 0) {\n x.isub(y);\n A.isub(C);\n B.isub(D);\n } else {\n y.isub(x);\n C.isub(A);\n D.isub(B);\n }\n }\n return {\n a: C,\n b: D,\n gcd: y.iushln(g)\n };\n };\n // This is reduced incarnation of the binary EEA\n // above, designated to invert members of the\n // _prime_ fields F(p) at a maximal speed\n BN.prototype._invmp = function _invmp(p) {\n assert(p.negative === 0);\n assert(!p.isZero());\n var a = this;\n var b = p.clone();\n if (a.negative !== 0) a = a.umod(p);\n else a = a.clone();\n var x1 = new BN(1);\n var x2 = new BN(0);\n var delta = b.clone();\n while(a.cmpn(1) > 0 && b.cmpn(1) > 0){\n for(var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);\n if (i > 0) {\n a.iushrn(i);\n while(i-- > 0){\n if (x1.isOdd()) x1.iadd(delta);\n x1.iushrn(1);\n }\n }\n for(var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);\n if (j > 0) {\n b.iushrn(j);\n while(j-- > 0){\n if (x2.isOdd()) x2.iadd(delta);\n x2.iushrn(1);\n }\n }\n if (a.cmp(b) >= 0) {\n a.isub(b);\n x1.isub(x2);\n } else {\n b.isub(a);\n x2.isub(x1);\n }\n }\n var res;\n if (a.cmpn(1) === 0) res = x1;\n else res = x2;\n if (res.cmpn(0) < 0) res.iadd(p);\n return res;\n };\n BN.prototype.gcd = function gcd(num) {\n if (this.isZero()) return num.abs();\n if (num.isZero()) return this.abs();\n var a = this.clone();\n var b = num.clone();\n a.negative = 0;\n b.negative = 0;\n // Remove common factor of two\n for(var shift = 0; a.isEven() && b.isEven(); shift++){\n a.iushrn(1);\n b.iushrn(1);\n }\n do {\n while(a.isEven())a.iushrn(1);\n while(b.isEven())b.iushrn(1);\n var r = a.cmp(b);\n if (r < 0) {\n // Swap `a` and `b` to make `a` always bigger than `b`\n var t = a;\n a = b;\n b = t;\n } else if (r === 0 || b.cmpn(1) === 0) break;\n a.isub(b);\n }while (true);\n return b.iushln(shift);\n };\n // Invert number in the field F(num)\n BN.prototype.invm = function invm(num) {\n return this.egcd(num).a.umod(num);\n };\n BN.prototype.isEven = function isEven() {\n return (this.words[0] & 1) === 0;\n };\n BN.prototype.isOdd = function isOdd() {\n return (this.words[0] & 1) === 1;\n };\n // And first word and num\n BN.prototype.andln = function andln(num) {\n return this.words[0] & num;\n };\n // Increment at the bit position in-line\n BN.prototype.bincn = function bincn(bit) {\n assert(typeof bit === 'number');\n var r = bit % 26;\n var s = (bit - r) / 26;\n var q = 1 << r;\n // Fast case: bit is much higher than all existing words\n if (this.length <= s) {\n this._expand(s + 1);\n this.words[s] |= q;\n return this;\n }\n // Add bit and propagate, if needed\n var carry = q;\n for(var i = s; carry !== 0 && i < this.length; i++){\n var w = this.words[i] | 0;\n w += carry;\n carry = w >>> 26;\n w &= 0x3ffffff;\n this.words[i] = w;\n }\n if (carry !== 0) {\n this.words[i] = carry;\n this.length++;\n }\n return this;\n };\n BN.prototype.isZero = function isZero() {\n return this.length === 1 && this.words[0] === 0;\n };\n BN.prototype.cmpn = function cmpn(num) {\n var negative = num < 0;\n if (this.negative !== 0 && !negative) return -1;\n if (this.negative === 0 && negative) return 1;\n this._strip();\n var res;\n if (this.length > 1) res = 1;\n else {\n if (negative) num = -num;\n assert(num <= 0x3ffffff, 'Number is too big');\n var w = this.words[0] | 0;\n res = w === num ? 0 : w < num ? -1 : 1;\n }\n if (this.negative !== 0) return -res | 0;\n return res;\n };\n // Compare two numbers and return:\n // 1 - if `this` > `num`\n // 0 - if `this` == `num`\n // -1 - if `this` < `num`\n BN.prototype.cmp = function cmp(num) {\n if (this.negative !== 0 && num.negative === 0) return -1;\n if (this.negative === 0 && num.negative !== 0) return 1;\n var res = this.ucmp(num);\n if (this.negative !== 0) return -res | 0;\n return res;\n };\n // Unsigned comparison\n BN.prototype.ucmp = function ucmp(num) {\n // At this point both numbers have the same sign\n if (this.length > num.length) return 1;\n if (this.length < num.length) return -1;\n var res = 0;\n for(var i = this.length - 1; i >= 0; i--){\n var a = this.words[i] | 0;\n var b = num.words[i] | 0;\n if (a === b) continue;\n if (a < b) res = -1;\n else if (a > b) res = 1;\n break;\n }\n return res;\n };\n BN.prototype.gtn = function gtn(num) {\n return this.cmpn(num) === 1;\n };\n BN.prototype.gt = function gt(num) {\n return this.cmp(num) === 1;\n };\n BN.prototype.gten = function gten(num) {\n return this.cmpn(num) >= 0;\n };\n BN.prototype.gte = function gte(num) {\n return this.cmp(num) >= 0;\n };\n BN.prototype.ltn = function ltn(num) {\n return this.cmpn(num) === -1;\n };\n BN.prototype.lt = function lt(num) {\n return this.cmp(num) === -1;\n };\n BN.prototype.lten = function lten(num) {\n return this.cmpn(num) <= 0;\n };\n BN.prototype.lte = function lte(num) {\n return this.cmp(num) <= 0;\n };\n BN.prototype.eqn = function eqn(num) {\n return this.cmpn(num) === 0;\n };\n BN.prototype.eq = function eq(num) {\n return this.cmp(num) === 0;\n };\n //\n // A reduce context, could be using montgomery or something better, depending\n // on the `m` itself.\n //\n BN.red = function red(num) {\n return new Red(num);\n };\n BN.prototype.toRed = function toRed(ctx) {\n assert(!this.red, 'Already a number in reduction context');\n assert(this.negative === 0, 'red works only with positives');\n return ctx.convertTo(this)._forceRed(ctx);\n };\n BN.prototype.fromRed = function fromRed() {\n assert(this.red, 'fromRed works only with numbers in reduction context');\n return this.red.convertFrom(this);\n };\n BN.prototype._forceRed = function _forceRed(ctx) {\n this.red = ctx;\n return this;\n };\n BN.prototype.forceRed = function forceRed(ctx) {\n assert(!this.red, 'Already a number in reduction context');\n return this._forceRed(ctx);\n };\n BN.prototype.redAdd = function redAdd(num) {\n assert(this.red, 'redAdd works only with red numbers');\n return this.red.add(this, num);\n };\n BN.prototype.redIAdd = function redIAdd(num) {\n assert(this.red, 'redIAdd works only with red numbers');\n return this.red.iadd(this, num);\n };\n BN.prototype.redSub = function redSub(num) {\n assert(this.red, 'redSub works only with red numbers');\n return this.red.sub(this, num);\n };\n BN.prototype.redISub = function redISub(num) {\n assert(this.red, 'redISub works only with red numbers');\n return this.red.isub(this, num);\n };\n BN.prototype.redShl = function redShl(num) {\n assert(this.red, 'redShl works only with red numbers');\n return this.red.shl(this, num);\n };\n BN.prototype.redMul = function redMul(num) {\n assert(this.red, 'redMul works only with red numbers');\n this.red._verify2(this, num);\n return this.red.mul(this, num);\n };\n BN.prototype.redIMul = function redIMul(num) {\n assert(this.red, 'redMul works only with red numbers');\n this.red._verify2(this, num);\n return this.red.imul(this, num);\n };\n BN.prototype.redSqr = function redSqr() {\n assert(this.red, 'redSqr works only with red numbers');\n this.red._verify1(this);\n return this.red.sqr(this);\n };\n BN.prototype.redISqr = function redISqr() {\n assert(this.red, 'redISqr works only with red numbers');\n this.red._verify1(this);\n return this.red.isqr(this);\n };\n // Square root over p\n BN.prototype.redSqrt = function redSqrt() {\n assert(this.red, 'redSqrt works only with red numbers');\n this.red._verify1(this);\n return this.red.sqrt(this);\n };\n BN.prototype.redInvm = function redInvm() {\n assert(this.red, 'redInvm works only with red numbers');\n this.red._verify1(this);\n return this.red.invm(this);\n };\n // Return negative clone of `this` % `red modulo`\n BN.prototype.redNeg = function redNeg() {\n assert(this.red, 'redNeg works only with red numbers');\n this.red._verify1(this);\n return this.red.neg(this);\n };\n BN.prototype.redPow = function redPow(num) {\n assert(this.red && !num.red, 'redPow(normalNum)');\n this.red._verify1(this);\n return this.red.pow(this, num);\n };\n // Prime numbers with efficient reduction\n var primes = {\n k256: null,\n p224: null,\n p192: null,\n p25519: null\n };\n // Pseudo-Mersenne prime\n function MPrime(name, p) {\n // P = 2 ^ N - K\n this.name = name;\n this.p = new BN(p, 16);\n this.n = this.p.bitLength();\n this.k = new BN(1).iushln(this.n).isub(this.p);\n this.tmp = this._tmp();\n }\n MPrime.prototype._tmp = function _tmp() {\n var tmp = new BN(null);\n tmp.words = new Array(Math.ceil(this.n / 13));\n return tmp;\n };\n MPrime.prototype.ireduce = function ireduce(num) {\n // Assumes that `num` is less than `P^2`\n // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)\n var r = num;\n var rlen;\n do {\n this.split(r, this.tmp);\n r = this.imulK(r);\n r = r.iadd(this.tmp);\n rlen = r.bitLength();\n }while (rlen > this.n);\n var cmp = rlen < this.n ? -1 : r.ucmp(this.p);\n if (cmp === 0) {\n r.words[0] = 0;\n r.length = 1;\n } else if (cmp > 0) r.isub(this.p);\n else if (r.strip !== undefined) // r is a BN v4 instance\n r.strip();\n else // r is a BN v5 instance\n r._strip();\n return r;\n };\n MPrime.prototype.split = function split(input, out) {\n input.iushrn(this.n, 0, out);\n };\n MPrime.prototype.imulK = function imulK(num) {\n return num.imul(this.k);\n };\n function K256() {\n MPrime.call(this, 'k256', 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');\n }\n inherits(K256, MPrime);\n K256.prototype.split = function split(input, output) {\n // 256 = 9 * 26 + 22\n var mask = 0x3fffff;\n var outLen = Math.min(input.length, 9);\n for(var i = 0; i < outLen; i++)output.words[i] = input.words[i];\n output.length = outLen;\n if (input.length <= 9) {\n input.words[0] = 0;\n input.length = 1;\n return;\n }\n // Shift by 9 limbs\n var prev = input.words[9];\n output.words[output.length++] = prev & mask;\n for(i = 10; i < input.length; i++){\n var next = input.words[i] | 0;\n input.words[i - 10] = (next & mask) << 4 | prev >>> 22;\n prev = next;\n }\n prev >>>= 22;\n input.words[i - 10] = prev;\n if (prev === 0 && input.length > 10) input.length -= 10;\n else input.length -= 9;\n };\n K256.prototype.imulK = function imulK(num) {\n // K = 0x1000003d1 = [ 0x40, 0x3d1 ]\n num.words[num.length] = 0;\n num.words[num.length + 1] = 0;\n num.length += 2;\n // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390\n var lo = 0;\n for(var i = 0; i < num.length; i++){\n var w = num.words[i] | 0;\n lo += w * 0x3d1;\n num.words[i] = lo & 0x3ffffff;\n lo = w * 0x40 + (lo / 0x4000000 | 0);\n }\n // Fast length reduction\n if (num.words[num.length - 1] === 0) {\n num.length--;\n if (num.words[num.length - 1] === 0) num.length--;\n }\n return num;\n };\n function P224() {\n MPrime.call(this, 'p224', 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');\n }\n inherits(P224, MPrime);\n function P192() {\n MPrime.call(this, 'p192', 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');\n }\n inherits(P192, MPrime);\n function P25519() {\n // 2 ^ 255 - 19\n MPrime.call(this, '25519', '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');\n }\n inherits(P25519, MPrime);\n P25519.prototype.imulK = function imulK(num) {\n // K = 0x13\n var carry = 0;\n for(var i = 0; i < num.length; i++){\n var hi = (num.words[i] | 0) * 0x13 + carry;\n var lo = hi & 0x3ffffff;\n hi >>>= 26;\n num.words[i] = lo;\n carry = hi;\n }\n if (carry !== 0) num.words[num.length++] = carry;\n return num;\n };\n // Exported mostly for testing purposes, use plain name instead\n BN._prime = function prime(name) {\n // Cached version of prime\n if (primes[name]) return primes[name];\n var prime;\n if (name === 'k256') prime = new K256();\n else if (name === 'p224') prime = new P224();\n else if (name === 'p192') prime = new P192();\n else if (name === 'p25519') prime = new P25519();\n else throw new Error('Unknown prime ' + name);\n primes[name] = prime;\n return prime;\n };\n //\n // Base reduction engine\n //\n function Red(m) {\n if (typeof m === 'string') {\n var prime = BN._prime(m);\n this.m = prime.p;\n this.prime = prime;\n } else {\n assert(m.gtn(1), 'modulus must be greater than 1');\n this.m = m;\n this.prime = null;\n }\n }\n Red.prototype._verify1 = function _verify1(a) {\n assert(a.negative === 0, 'red works only with positives');\n assert(a.red, 'red works only with red numbers');\n };\n Red.prototype._verify2 = function _verify2(a, b) {\n assert((a.negative | b.negative) === 0, 'red works only with positives');\n assert(a.red && a.red === b.red, 'red works only with red numbers');\n };\n Red.prototype.imod = function imod(a) {\n if (this.prime) return this.prime.ireduce(a)._forceRed(this);\n move(a, a.umod(this.m)._forceRed(this));\n return a;\n };\n Red.prototype.neg = function neg(a) {\n if (a.isZero()) return a.clone();\n return this.m.sub(a)._forceRed(this);\n };\n Red.prototype.add = function add(a, b) {\n this._verify2(a, b);\n var res = a.add(b);\n if (res.cmp(this.m) >= 0) res.isub(this.m);\n return res._forceRed(this);\n };\n Red.prototype.iadd = function iadd(a, b) {\n this._verify2(a, b);\n var res = a.iadd(b);\n if (res.cmp(this.m) >= 0) res.isub(this.m);\n return res;\n };\n Red.prototype.sub = function sub(a, b) {\n this._verify2(a, b);\n var res = a.sub(b);\n if (res.cmpn(0) < 0) res.iadd(this.m);\n return res._forceRed(this);\n };\n Red.prototype.isub = function isub(a, b) {\n this._verify2(a, b);\n var res = a.isub(b);\n if (res.cmpn(0) < 0) res.iadd(this.m);\n return res;\n };\n Red.prototype.shl = function shl(a, num) {\n this._verify1(a);\n return this.imod(a.ushln(num));\n };\n Red.prototype.imul = function imul(a, b) {\n this._verify2(a, b);\n return this.imod(a.imul(b));\n };\n Red.prototype.mul = function mul(a, b) {\n this._verify2(a, b);\n return this.imod(a.mul(b));\n };\n Red.prototype.isqr = function isqr(a) {\n return this.imul(a, a.clone());\n };\n Red.prototype.sqr = function sqr(a) {\n return this.mul(a, a);\n };\n Red.prototype.sqrt = function sqrt(a) {\n if (a.isZero()) return a.clone();\n var mod3 = this.m.andln(3);\n assert(mod3 % 2 === 1);\n // Fast case\n if (mod3 === 3) {\n var pow = this.m.add(new BN(1)).iushrn(2);\n return this.pow(a, pow);\n }\n // Tonelli-Shanks algorithm (Totally unoptimized and slow)\n //\n // Find Q and S, that Q * 2 ^ S = (P - 1)\n var q = this.m.subn(1);\n var s = 0;\n while(!q.isZero() && q.andln(1) === 0){\n s++;\n q.iushrn(1);\n }\n assert(!q.isZero());\n var one = new BN(1).toRed(this);\n var nOne = one.redNeg();\n // Find quadratic non-residue\n // NOTE: Max is such because of generalized Riemann hypothesis.\n var lpow = this.m.subn(1).iushrn(1);\n var z = this.m.bitLength();\n z = new BN(2 * z * z).toRed(this);\n while(this.pow(z, lpow).cmp(nOne) !== 0)z.redIAdd(nOne);\n var c = this.pow(z, q);\n var r = this.pow(a, q.addn(1).iushrn(1));\n var t = this.pow(a, q);\n var m = s;\n while(t.cmp(one) !== 0){\n var tmp = t;\n for(var i = 0; tmp.cmp(one) !== 0; i++)tmp = tmp.redSqr();\n assert(i < m);\n var b = this.pow(c, new BN(1).iushln(m - i - 1));\n r = r.redMul(b);\n c = b.redSqr();\n t = t.redMul(c);\n m = i;\n }\n return r;\n };\n Red.prototype.invm = function invm(a) {\n var inv = a._invmp(this.m);\n if (inv.negative !== 0) {\n inv.negative = 0;\n return this.imod(inv).redNeg();\n } else return this.imod(inv);\n };\n Red.prototype.pow = function pow(a, num) {\n if (num.isZero()) return new BN(1).toRed(this);\n if (num.cmpn(1) === 0) return a.clone();\n var windowSize = 4;\n var wnd = new Array(1 << windowSize);\n wnd[0] = new BN(1).toRed(this);\n wnd[1] = a;\n for(var i = 2; i < wnd.length; i++)wnd[i] = this.mul(wnd[i - 1], a);\n var res = wnd[0];\n var current = 0;\n var currentLen = 0;\n var start = num.bitLength() % 26;\n if (start === 0) start = 26;\n for(i = num.length - 1; i >= 0; i--){\n var word = num.words[i];\n for(var j = start - 1; j >= 0; j--){\n var bit = word >> j & 1;\n if (res !== wnd[0]) res = this.sqr(res);\n if (bit === 0 && current === 0) {\n currentLen = 0;\n continue;\n }\n current <<= 1;\n current |= bit;\n currentLen++;\n if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;\n res = this.mul(res, wnd[current]);\n currentLen = 0;\n current = 0;\n }\n start = 26;\n }\n return res;\n };\n Red.prototype.convertTo = function convertTo(num) {\n var r = num.umod(this.m);\n return r === num ? r.clone() : r;\n };\n Red.prototype.convertFrom = function convertFrom(num) {\n var res = num.clone();\n res.red = null;\n return res;\n };\n //\n // Montgomery method engine\n //\n BN.mont = function mont(num) {\n return new Mont(num);\n };\n function Mont(m) {\n Red.call(this, m);\n this.shift = this.m.bitLength();\n if (this.shift % 26 !== 0) this.shift += 26 - this.shift % 26;\n this.r = new BN(1).iushln(this.shift);\n this.r2 = this.imod(this.r.sqr());\n this.rinv = this.r._invmp(this.m);\n this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);\n this.minv = this.minv.umod(this.r);\n this.minv = this.r.sub(this.minv);\n }\n inherits(Mont, Red);\n Mont.prototype.convertTo = function convertTo(num) {\n return this.imod(num.ushln(this.shift));\n };\n Mont.prototype.convertFrom = function convertFrom(num) {\n var r = this.imod(num.mul(this.rinv));\n r.red = null;\n return r;\n };\n Mont.prototype.imul = function imul(a, b) {\n if (a.isZero() || b.isZero()) {\n a.words[0] = 0;\n a.length = 1;\n return a;\n }\n var t = a.imul(b);\n var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);\n var u = t.isub(c).iushrn(this.shift);\n var res = u;\n if (u.cmp(this.m) >= 0) res = u.isub(this.m);\n else if (u.cmpn(0) < 0) res = u.iadd(this.m);\n return res._forceRed(this);\n };\n Mont.prototype.mul = function mul(a, b) {\n if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);\n var t = a.mul(b);\n var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);\n var u = t.isub(c).iushrn(this.shift);\n var res = u;\n if (u.cmp(this.m) >= 0) res = u.isub(this.m);\n else if (u.cmpn(0) < 0) res = u.iadd(this.m);\n return res._forceRed(this);\n };\n Mont.prototype.invm = function invm(a) {\n // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R\n var res = this.imod(a._invmp(this.m).mul(this.r2));\n return res._forceRed(this);\n };\n})(module, this);\n\n});\nparcelRegister(\"kjyEk\", function(module, exports) {\n\"use strict\";\n\n});\n\n\nparcelRegister(\"bYkMz\", function(module, exports) {\n\nvar $0DhcF = parcelRequire(\"0DhcF\");\nvar $8b756b3b8ee97947$var$ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\nmodule.exports = $0DhcF($8b756b3b8ee97947$var$ALPHABET);\n\n});\nparcelRegister(\"0DhcF\", function(module, exports) {\n'use strict';\n\nvar $1U9GM = parcelRequire(\"1U9GM\");\nvar $001e77b0dfd1bf3d$require$_Buffer = $1U9GM.Buffer;\nfunction $001e77b0dfd1bf3d$var$base(ALPHABET) {\n if (ALPHABET.length >= 255) throw new TypeError('Alphabet too long');\n var BASE_MAP = new Uint8Array(256);\n for(var j = 0; j < BASE_MAP.length; j++)BASE_MAP[j] = 255;\n for(var i = 0; i < ALPHABET.length; i++){\n var x = ALPHABET.charAt(i);\n var xc = x.charCodeAt(0);\n if (BASE_MAP[xc] !== 255) throw new TypeError(x + ' is ambiguous');\n BASE_MAP[xc] = i;\n }\n var BASE = ALPHABET.length;\n var LEADER = ALPHABET.charAt(0);\n var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up\n ;\n var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up\n ;\n function encode(source) {\n if (Array.isArray(source) || source instanceof Uint8Array) source = $001e77b0dfd1bf3d$require$_Buffer.from(source);\n if (!$001e77b0dfd1bf3d$require$_Buffer.isBuffer(source)) throw new TypeError('Expected Buffer');\n if (source.length === 0) return '';\n // Skip & count leading zeroes.\n var zeroes = 0;\n var length = 0;\n var pbegin = 0;\n var pend = source.length;\n while(pbegin !== pend && source[pbegin] === 0){\n pbegin++;\n zeroes++;\n }\n // Allocate enough space in big-endian base58 representation.\n var size = (pend - pbegin) * iFACTOR + 1 >>> 0;\n var b58 = new Uint8Array(size);\n // Process the bytes.\n while(pbegin !== pend){\n var carry = source[pbegin];\n // Apply \"b58 = b58 * 256 + ch\".\n var i = 0;\n for(var it1 = size - 1; (carry !== 0 || i < length) && it1 !== -1; it1--, i++){\n carry += 256 * b58[it1] >>> 0;\n b58[it1] = carry % BASE >>> 0;\n carry = carry / BASE >>> 0;\n }\n if (carry !== 0) throw new Error('Non-zero carry');\n length = i;\n pbegin++;\n }\n // Skip leading zeroes in base58 result.\n var it2 = size - length;\n while(it2 !== size && b58[it2] === 0)it2++;\n // Translate the result into a string.\n var str = LEADER.repeat(zeroes);\n for(; it2 < size; ++it2)str += ALPHABET.charAt(b58[it2]);\n return str;\n }\n function decodeUnsafe(source) {\n if (typeof source !== 'string') throw new TypeError('Expected String');\n if (source.length === 0) return $001e77b0dfd1bf3d$require$_Buffer.alloc(0);\n var psz = 0;\n // Skip and count leading '1's.\n var zeroes = 0;\n var length = 0;\n while(source[psz] === LEADER){\n zeroes++;\n psz++;\n }\n // Allocate enough space in big-endian base256 representation.\n var size = (source.length - psz) * FACTOR + 1 >>> 0 // log(58) / log(256), rounded up.\n ;\n var b256 = new Uint8Array(size);\n // Process the characters.\n while(psz < source.length){\n // Decode character\n var carry = BASE_MAP[source.charCodeAt(psz)];\n // Invalid character\n if (carry === 255) return;\n var i = 0;\n for(var it3 = size - 1; (carry !== 0 || i < length) && it3 !== -1; it3--, i++){\n carry += BASE * b256[it3] >>> 0;\n b256[it3] = carry % 256 >>> 0;\n carry = carry / 256 >>> 0;\n }\n if (carry !== 0) throw new Error('Non-zero carry');\n length = i;\n psz++;\n }\n // Skip leading zeroes in b256.\n var it4 = size - length;\n while(it4 !== size && b256[it4] === 0)it4++;\n var vch = $001e77b0dfd1bf3d$require$_Buffer.allocUnsafe(zeroes + (size - it4));\n vch.fill(0x00, 0, zeroes);\n var j = zeroes;\n while(it4 !== size)vch[j++] = b256[it4++];\n return vch;\n }\n function decode(string) {\n var buffer = decodeUnsafe(string);\n if (buffer) return buffer;\n throw new Error('Non-base' + BASE + ' character');\n }\n return {\n encode: encode,\n decodeUnsafe: decodeUnsafe,\n decode: decode\n };\n}\nmodule.exports = $001e77b0dfd1bf3d$var$base;\n\n});\nparcelRegister(\"1U9GM\", function(module, exports) {\n/*! safe-buffer. MIT License. Feross Aboukhadijeh */ /* eslint-disable node/no-deprecated-api */ \nvar $6ZWSX = parcelRequire(\"6ZWSX\");\nvar $1632896ed805433d$var$Buffer = $6ZWSX.Buffer;\n// alternative to using Object.keys for old browsers\nfunction $1632896ed805433d$var$copyProps(src, dst) {\n for(var key in src)dst[key] = src[key];\n}\nif ($1632896ed805433d$var$Buffer.from && $1632896ed805433d$var$Buffer.alloc && $1632896ed805433d$var$Buffer.allocUnsafe && $1632896ed805433d$var$Buffer.allocUnsafeSlow) module.exports = $6ZWSX;\nelse {\n // Copy properties from require('buffer')\n $1632896ed805433d$var$copyProps($6ZWSX, module.exports);\n module.exports.Buffer = $1632896ed805433d$var$SafeBuffer;\n}\nfunction $1632896ed805433d$var$SafeBuffer(arg, encodingOrOffset, length) {\n return $1632896ed805433d$var$Buffer(arg, encodingOrOffset, length);\n}\n$1632896ed805433d$var$SafeBuffer.prototype = Object.create($1632896ed805433d$var$Buffer.prototype);\n// Copy static methods from Buffer\n$1632896ed805433d$var$copyProps($1632896ed805433d$var$Buffer, $1632896ed805433d$var$SafeBuffer);\n$1632896ed805433d$var$SafeBuffer.from = function(arg, encodingOrOffset, length) {\n if (typeof arg === 'number') throw new TypeError('Argument must not be a number');\n return $1632896ed805433d$var$Buffer(arg, encodingOrOffset, length);\n};\n$1632896ed805433d$var$SafeBuffer.alloc = function(size, fill, encoding) {\n if (typeof size !== 'number') throw new TypeError('Argument must be a number');\n var buf = $1632896ed805433d$var$Buffer(size);\n if (fill !== undefined) {\n if (typeof encoding === 'string') buf.fill(fill, encoding);\n else buf.fill(fill);\n } else buf.fill(0);\n return buf;\n};\n$1632896ed805433d$var$SafeBuffer.allocUnsafe = function(size) {\n if (typeof size !== 'number') throw new TypeError('Argument must be a number');\n return $1632896ed805433d$var$Buffer(size);\n};\n$1632896ed805433d$var$SafeBuffer.allocUnsafeSlow = function(size) {\n if (typeof size !== 'number') throw new TypeError('Argument must be a number');\n return $6ZWSX.SlowBuffer(size);\n};\n\n});\n\n\n\nparcelRegister(\"6XnWx\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.sha224 = module.exports.sha256 = module.exports.SHA256 = void 0;\n\nvar $iYRTw = parcelRequire(\"iYRTw\");\n\nvar $3Bcdj = parcelRequire(\"3Bcdj\");\n/** Round constants: first 32 bits of fractional parts of the cube roots of the first 64 primes 2..311). */ // prettier-ignore\nconst $510ad3657d73a9d2$var$SHA256_K = /* @__PURE__ */ new Uint32Array([\n 0x428a2f98,\n 0x71374491,\n 0xb5c0fbcf,\n 0xe9b5dba5,\n 0x3956c25b,\n 0x59f111f1,\n 0x923f82a4,\n 0xab1c5ed5,\n 0xd807aa98,\n 0x12835b01,\n 0x243185be,\n 0x550c7dc3,\n 0x72be5d74,\n 0x80deb1fe,\n 0x9bdc06a7,\n 0xc19bf174,\n 0xe49b69c1,\n 0xefbe4786,\n 0x0fc19dc6,\n 0x240ca1cc,\n 0x2de92c6f,\n 0x4a7484aa,\n 0x5cb0a9dc,\n 0x76f988da,\n 0x983e5152,\n 0xa831c66d,\n 0xb00327c8,\n 0xbf597fc7,\n 0xc6e00bf3,\n 0xd5a79147,\n 0x06ca6351,\n 0x14292967,\n 0x27b70a85,\n 0x2e1b2138,\n 0x4d2c6dfc,\n 0x53380d13,\n 0x650a7354,\n 0x766a0abb,\n 0x81c2c92e,\n 0x92722c85,\n 0xa2bfe8a1,\n 0xa81a664b,\n 0xc24b8b70,\n 0xc76c51a3,\n 0xd192e819,\n 0xd6990624,\n 0xf40e3585,\n 0x106aa070,\n 0x19a4c116,\n 0x1e376c08,\n 0x2748774c,\n 0x34b0bcb5,\n 0x391c0cb3,\n 0x4ed8aa4a,\n 0x5b9cca4f,\n 0x682e6ff3,\n 0x748f82ee,\n 0x78a5636f,\n 0x84c87814,\n 0x8cc70208,\n 0x90befffa,\n 0xa4506ceb,\n 0xbef9a3f7,\n 0xc67178f2\n]);\n/** Initial state: first 32 bits of fractional parts of the square roots of the first 8 primes 2..19. */ // prettier-ignore\nconst $510ad3657d73a9d2$var$SHA256_IV = /* @__PURE__ */ new Uint32Array([\n 0x6a09e667,\n 0xbb67ae85,\n 0x3c6ef372,\n 0xa54ff53a,\n 0x510e527f,\n 0x9b05688c,\n 0x1f83d9ab,\n 0x5be0cd19\n]);\n/**\n * Temporary buffer, not used to store anything between runs.\n * Named this way because it matches specification.\n */ const $510ad3657d73a9d2$var$SHA256_W = /* @__PURE__ */ new Uint32Array(64);\nclass $510ad3657d73a9d2$var$SHA256 extends $iYRTw.HashMD {\n constructor(){\n super(64, 32, 8, false);\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n this.A = $510ad3657d73a9d2$var$SHA256_IV[0] | 0;\n this.B = $510ad3657d73a9d2$var$SHA256_IV[1] | 0;\n this.C = $510ad3657d73a9d2$var$SHA256_IV[2] | 0;\n this.D = $510ad3657d73a9d2$var$SHA256_IV[3] | 0;\n this.E = $510ad3657d73a9d2$var$SHA256_IV[4] | 0;\n this.F = $510ad3657d73a9d2$var$SHA256_IV[5] | 0;\n this.G = $510ad3657d73a9d2$var$SHA256_IV[6] | 0;\n this.H = $510ad3657d73a9d2$var$SHA256_IV[7] | 0;\n }\n get() {\n const { A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H } = this;\n return [\n A,\n B,\n C,\n D,\n E,\n F,\n G,\n H\n ];\n }\n // prettier-ignore\n set(A, B, C, D, E, F, G, H) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for(let i = 0; i < 16; i++, offset += 4)$510ad3657d73a9d2$var$SHA256_W[i] = view.getUint32(offset, false);\n for(let i = 16; i < 64; i++){\n const W15 = $510ad3657d73a9d2$var$SHA256_W[i - 15];\n const W2 = $510ad3657d73a9d2$var$SHA256_W[i - 2];\n const s0 = (0, $3Bcdj.rotr)(W15, 7) ^ (0, $3Bcdj.rotr)(W15, 18) ^ W15 >>> 3;\n const s1 = (0, $3Bcdj.rotr)(W2, 17) ^ (0, $3Bcdj.rotr)(W2, 19) ^ W2 >>> 10;\n $510ad3657d73a9d2$var$SHA256_W[i] = s1 + $510ad3657d73a9d2$var$SHA256_W[i - 7] + s0 + $510ad3657d73a9d2$var$SHA256_W[i - 16] | 0;\n }\n // Compression function main loop, 64 rounds\n let { A: A, B: B, C: C, D: D, E: E, F: F, G: G, H: H } = this;\n for(let i = 0; i < 64; i++){\n const sigma1 = (0, $3Bcdj.rotr)(E, 6) ^ (0, $3Bcdj.rotr)(E, 11) ^ (0, $3Bcdj.rotr)(E, 25);\n const T1 = H + sigma1 + (0, $iYRTw.Chi)(E, F, G) + $510ad3657d73a9d2$var$SHA256_K[i] + $510ad3657d73a9d2$var$SHA256_W[i] | 0;\n const sigma0 = (0, $3Bcdj.rotr)(A, 2) ^ (0, $3Bcdj.rotr)(A, 13) ^ (0, $3Bcdj.rotr)(A, 22);\n const T2 = sigma0 + (0, $iYRTw.Maj)(A, B, C) | 0;\n H = G;\n G = F;\n F = E;\n E = D + T1 | 0;\n D = C;\n C = B;\n B = A;\n A = T1 + T2 | 0;\n }\n // Add the compressed chunk to the current hash value\n A = A + this.A | 0;\n B = B + this.B | 0;\n C = C + this.C | 0;\n D = D + this.D | 0;\n E = E + this.E | 0;\n F = F + this.F | 0;\n G = G + this.G | 0;\n H = H + this.H | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n roundClean() {\n $510ad3657d73a9d2$var$SHA256_W.fill(0);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\nmodule.exports.SHA256 = $510ad3657d73a9d2$var$SHA256;\n/**\n * Constants taken from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf.\n */ class $510ad3657d73a9d2$var$SHA224 extends $510ad3657d73a9d2$var$SHA256 {\n constructor(){\n super();\n this.A = -1056596264;\n this.B = 914150663;\n this.C = 812702999;\n this.D = -150054599;\n this.E = -4191439;\n this.F = 1750603025;\n this.G = 1694076839;\n this.H = -1090891868;\n this.outputLen = 28;\n }\n}\n/** SHA2-256 hash function */ module.exports.sha256 = (0, $3Bcdj.wrapConstructor)(()=>new $510ad3657d73a9d2$var$SHA256());\n/** SHA2-224 hash function */ module.exports.sha224 = (0, $3Bcdj.wrapConstructor)(()=>new $510ad3657d73a9d2$var$SHA224());\n\n});\n\nparcelRegister(\"75BJw\", function(module, exports) {\n\nvar $6ZWSX = parcelRequire(\"6ZWSX\");\nvar $5296450c35a171ab$require$Buffer = $6ZWSX.Buffer;\n\"use strict\";\nvar $5296450c35a171ab$var$__createBinding = module.exports && module.exports.__createBinding || (Object.create ? function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, {\n enumerable: true,\n get: function() {\n return m[k];\n }\n });\n} : function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n});\nvar $5296450c35a171ab$var$__setModuleDefault = module.exports && module.exports.__setModuleDefault || (Object.create ? function(o, v) {\n Object.defineProperty(o, \"default\", {\n enumerable: true,\n value: v\n });\n} : function(o, v) {\n o[\"default\"] = v;\n});\nvar $5296450c35a171ab$var$__decorate = module.exports && module.exports.__decorate || function(decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar $5296450c35a171ab$var$__importStar = module.exports && module.exports.__importStar || function(mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) {\n for(var k in mod)if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) $5296450c35a171ab$var$__createBinding(result, mod, k);\n }\n $5296450c35a171ab$var$__setModuleDefault(result, mod);\n return result;\n};\nvar $5296450c35a171ab$var$__importDefault = module.exports && module.exports.__importDefault || function(mod) {\n return mod && mod.__esModule ? mod : {\n \"default\": mod\n };\n};\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.deserializeUnchecked = module.exports.deserialize = module.exports.serialize = module.exports.BinaryReader = module.exports.BinaryWriter = module.exports.BorshError = module.exports.baseDecode = module.exports.baseEncode = void 0;\n\nconst $5296450c35a171ab$var$bn_js_1 = $5296450c35a171ab$var$__importDefault((parcelRequire(\"dEXSZ\")));\n\nconst $5296450c35a171ab$var$bs58_1 = $5296450c35a171ab$var$__importDefault((parcelRequire(\"bYkMz\")));\n\n// TODO: Make sure this polyfill not included when not required\nconst $5296450c35a171ab$var$encoding = $5296450c35a171ab$var$__importStar((parcelRequire(\"kOaA4\")));\nconst $5296450c35a171ab$var$ResolvedTextDecoder = typeof TextDecoder !== \"function\" ? $5296450c35a171ab$var$encoding.TextDecoder : TextDecoder;\nconst $5296450c35a171ab$var$textDecoder = new $5296450c35a171ab$var$ResolvedTextDecoder(\"utf-8\", {\n fatal: true\n});\nfunction $5296450c35a171ab$var$baseEncode(value) {\n if (typeof value === \"string\") value = $5296450c35a171ab$require$Buffer.from(value, \"utf8\");\n return $5296450c35a171ab$var$bs58_1.default.encode($5296450c35a171ab$require$Buffer.from(value));\n}\nmodule.exports.baseEncode = $5296450c35a171ab$var$baseEncode;\nfunction $5296450c35a171ab$var$baseDecode(value) {\n return $5296450c35a171ab$require$Buffer.from($5296450c35a171ab$var$bs58_1.default.decode(value));\n}\nmodule.exports.baseDecode = $5296450c35a171ab$var$baseDecode;\nconst $5296450c35a171ab$var$INITIAL_LENGTH = 1024;\nclass $5296450c35a171ab$var$BorshError extends Error {\n constructor(message){\n super(message);\n this.fieldPath = [];\n this.originalMessage = message;\n }\n addToFieldPath(fieldName) {\n this.fieldPath.splice(0, 0, fieldName);\n // NOTE: Modifying message directly as jest doesn't use .toString()\n this.message = this.originalMessage + \": \" + this.fieldPath.join(\".\");\n }\n}\nmodule.exports.BorshError = $5296450c35a171ab$var$BorshError;\n/// Binary encoder.\nclass $5296450c35a171ab$var$BinaryWriter {\n constructor(){\n this.buf = $5296450c35a171ab$require$Buffer.alloc($5296450c35a171ab$var$INITIAL_LENGTH);\n this.length = 0;\n }\n maybeResize() {\n if (this.buf.length < 16 + this.length) this.buf = $5296450c35a171ab$require$Buffer.concat([\n this.buf,\n $5296450c35a171ab$require$Buffer.alloc($5296450c35a171ab$var$INITIAL_LENGTH)\n ]);\n }\n writeU8(value) {\n this.maybeResize();\n this.buf.writeUInt8(value, this.length);\n this.length += 1;\n }\n writeU16(value) {\n this.maybeResize();\n this.buf.writeUInt16LE(value, this.length);\n this.length += 2;\n }\n writeU32(value) {\n this.maybeResize();\n this.buf.writeUInt32LE(value, this.length);\n this.length += 4;\n }\n writeU64(value) {\n this.maybeResize();\n this.writeBuffer($5296450c35a171ab$require$Buffer.from(new $5296450c35a171ab$var$bn_js_1.default(value).toArray(\"le\", 8)));\n }\n writeU128(value) {\n this.maybeResize();\n this.writeBuffer($5296450c35a171ab$require$Buffer.from(new $5296450c35a171ab$var$bn_js_1.default(value).toArray(\"le\", 16)));\n }\n writeU256(value) {\n this.maybeResize();\n this.writeBuffer($5296450c35a171ab$require$Buffer.from(new $5296450c35a171ab$var$bn_js_1.default(value).toArray(\"le\", 32)));\n }\n writeU512(value) {\n this.maybeResize();\n this.writeBuffer($5296450c35a171ab$require$Buffer.from(new $5296450c35a171ab$var$bn_js_1.default(value).toArray(\"le\", 64)));\n }\n writeBuffer(buffer) {\n // Buffer.from is needed as this.buf.subarray can return plain Uint8Array in browser\n this.buf = $5296450c35a171ab$require$Buffer.concat([\n $5296450c35a171ab$require$Buffer.from(this.buf.subarray(0, this.length)),\n buffer,\n $5296450c35a171ab$require$Buffer.alloc($5296450c35a171ab$var$INITIAL_LENGTH)\n ]);\n this.length += buffer.length;\n }\n writeString(str) {\n this.maybeResize();\n const b = $5296450c35a171ab$require$Buffer.from(str, \"utf8\");\n this.writeU32(b.length);\n this.writeBuffer(b);\n }\n writeFixedArray(array) {\n this.writeBuffer($5296450c35a171ab$require$Buffer.from(array));\n }\n writeArray(array, fn) {\n this.maybeResize();\n this.writeU32(array.length);\n for (const elem of array){\n this.maybeResize();\n fn(elem);\n }\n }\n toArray() {\n return this.buf.subarray(0, this.length);\n }\n}\nmodule.exports.BinaryWriter = $5296450c35a171ab$var$BinaryWriter;\nfunction $5296450c35a171ab$var$handlingRangeError(target, propertyKey, propertyDescriptor) {\n const originalMethod = propertyDescriptor.value;\n propertyDescriptor.value = function(...args) {\n try {\n return originalMethod.apply(this, args);\n } catch (e) {\n if (e instanceof RangeError) {\n const code = e.code;\n if ([\n \"ERR_BUFFER_OUT_OF_BOUNDS\",\n \"ERR_OUT_OF_RANGE\"\n ].indexOf(code) >= 0) throw new $5296450c35a171ab$var$BorshError(\"Reached the end of buffer when deserializing\");\n }\n throw e;\n }\n };\n}\nclass $5296450c35a171ab$var$BinaryReader {\n constructor(buf){\n this.buf = buf;\n this.offset = 0;\n }\n readU8() {\n const value = this.buf.readUInt8(this.offset);\n this.offset += 1;\n return value;\n }\n readU16() {\n const value = this.buf.readUInt16LE(this.offset);\n this.offset += 2;\n return value;\n }\n readU32() {\n const value = this.buf.readUInt32LE(this.offset);\n this.offset += 4;\n return value;\n }\n readU64() {\n const buf = this.readBuffer(8);\n return new $5296450c35a171ab$var$bn_js_1.default(buf, \"le\");\n }\n readU128() {\n const buf = this.readBuffer(16);\n return new $5296450c35a171ab$var$bn_js_1.default(buf, \"le\");\n }\n readU256() {\n const buf = this.readBuffer(32);\n return new $5296450c35a171ab$var$bn_js_1.default(buf, \"le\");\n }\n readU512() {\n const buf = this.readBuffer(64);\n return new $5296450c35a171ab$var$bn_js_1.default(buf, \"le\");\n }\n readBuffer(len) {\n if (this.offset + len > this.buf.length) throw new $5296450c35a171ab$var$BorshError(`Expected buffer length ${len} isn't within bounds`);\n const result = this.buf.slice(this.offset, this.offset + len);\n this.offset += len;\n return result;\n }\n readString() {\n const len = this.readU32();\n const buf = this.readBuffer(len);\n try {\n // NOTE: Using TextDecoder to fail on invalid UTF-8\n return $5296450c35a171ab$var$textDecoder.decode(buf);\n } catch (e) {\n throw new $5296450c35a171ab$var$BorshError(`Error decoding UTF-8 string: ${e}`);\n }\n }\n readFixedArray(len) {\n return new Uint8Array(this.readBuffer(len));\n }\n readArray(fn) {\n const len = this.readU32();\n const result = Array();\n for(let i = 0; i < len; ++i)result.push(fn());\n return result;\n }\n}\n$5296450c35a171ab$var$__decorate([\n $5296450c35a171ab$var$handlingRangeError\n], $5296450c35a171ab$var$BinaryReader.prototype, \"readU8\", null);\n$5296450c35a171ab$var$__decorate([\n $5296450c35a171ab$var$handlingRangeError\n], $5296450c35a171ab$var$BinaryReader.prototype, \"readU16\", null);\n$5296450c35a171ab$var$__decorate([\n $5296450c35a171ab$var$handlingRangeError\n], $5296450c35a171ab$var$BinaryReader.prototype, \"readU32\", null);\n$5296450c35a171ab$var$__decorate([\n $5296450c35a171ab$var$handlingRangeError\n], $5296450c35a171ab$var$BinaryReader.prototype, \"readU64\", null);\n$5296450c35a171ab$var$__decorate([\n $5296450c35a171ab$var$handlingRangeError\n], $5296450c35a171ab$var$BinaryReader.prototype, \"readU128\", null);\n$5296450c35a171ab$var$__decorate([\n $5296450c35a171ab$var$handlingRangeError\n], $5296450c35a171ab$var$BinaryReader.prototype, \"readU256\", null);\n$5296450c35a171ab$var$__decorate([\n $5296450c35a171ab$var$handlingRangeError\n], $5296450c35a171ab$var$BinaryReader.prototype, \"readU512\", null);\n$5296450c35a171ab$var$__decorate([\n $5296450c35a171ab$var$handlingRangeError\n], $5296450c35a171ab$var$BinaryReader.prototype, \"readString\", null);\n$5296450c35a171ab$var$__decorate([\n $5296450c35a171ab$var$handlingRangeError\n], $5296450c35a171ab$var$BinaryReader.prototype, \"readFixedArray\", null);\n$5296450c35a171ab$var$__decorate([\n $5296450c35a171ab$var$handlingRangeError\n], $5296450c35a171ab$var$BinaryReader.prototype, \"readArray\", null);\nmodule.exports.BinaryReader = $5296450c35a171ab$var$BinaryReader;\nfunction $5296450c35a171ab$var$capitalizeFirstLetter(string) {\n return string.charAt(0).toUpperCase() + string.slice(1);\n}\nfunction $5296450c35a171ab$var$serializeField(schema, fieldName, value, fieldType, writer) {\n try {\n // TODO: Handle missing values properly (make sure they never result in just skipped write)\n if (typeof fieldType === \"string\") writer[`write${$5296450c35a171ab$var$capitalizeFirstLetter(fieldType)}`](value);\n else if (fieldType instanceof Array) {\n if (typeof fieldType[0] === \"number\") {\n if (value.length !== fieldType[0]) throw new $5296450c35a171ab$var$BorshError(`Expecting byte array of length ${fieldType[0]}, but got ${value.length} bytes`);\n writer.writeFixedArray(value);\n } else if (fieldType.length === 2 && typeof fieldType[1] === \"number\") {\n if (value.length !== fieldType[1]) throw new $5296450c35a171ab$var$BorshError(`Expecting byte array of length ${fieldType[1]}, but got ${value.length} bytes`);\n for(let i = 0; i < fieldType[1]; i++)$5296450c35a171ab$var$serializeField(schema, null, value[i], fieldType[0], writer);\n } else writer.writeArray(value, (item)=>{\n $5296450c35a171ab$var$serializeField(schema, fieldName, item, fieldType[0], writer);\n });\n } else if (fieldType.kind !== undefined) switch(fieldType.kind){\n case \"option\":\n if (value === null || value === undefined) writer.writeU8(0);\n else {\n writer.writeU8(1);\n $5296450c35a171ab$var$serializeField(schema, fieldName, value, fieldType.type, writer);\n }\n break;\n case \"map\":\n writer.writeU32(value.size);\n value.forEach((val, key)=>{\n $5296450c35a171ab$var$serializeField(schema, fieldName, key, fieldType.key, writer);\n $5296450c35a171ab$var$serializeField(schema, fieldName, val, fieldType.value, writer);\n });\n break;\n default:\n throw new $5296450c35a171ab$var$BorshError(`FieldType ${fieldType} unrecognized`);\n }\n else $5296450c35a171ab$var$serializeStruct(schema, value, writer);\n } catch (error) {\n if (error instanceof $5296450c35a171ab$var$BorshError) error.addToFieldPath(fieldName);\n throw error;\n }\n}\nfunction $5296450c35a171ab$var$serializeStruct(schema, obj, writer) {\n if (typeof obj.borshSerialize === \"function\") {\n obj.borshSerialize(writer);\n return;\n }\n const structSchema = schema.get(obj.constructor);\n if (!structSchema) throw new $5296450c35a171ab$var$BorshError(`Class ${obj.constructor.name} is missing in schema`);\n if (structSchema.kind === \"struct\") structSchema.fields.map(([fieldName, fieldType])=>{\n $5296450c35a171ab$var$serializeField(schema, fieldName, obj[fieldName], fieldType, writer);\n });\n else if (structSchema.kind === \"enum\") {\n const name = obj[structSchema.field];\n for(let idx = 0; idx < structSchema.values.length; ++idx){\n const [fieldName, fieldType] = structSchema.values[idx];\n if (fieldName === name) {\n writer.writeU8(idx);\n $5296450c35a171ab$var$serializeField(schema, fieldName, obj[fieldName], fieldType, writer);\n break;\n }\n }\n } else throw new $5296450c35a171ab$var$BorshError(`Unexpected schema kind: ${structSchema.kind} for ${obj.constructor.name}`);\n}\n/// Serialize given object using schema of the form:\n/// { class_name -> [ [field_name, field_type], .. ], .. }\nfunction $5296450c35a171ab$var$serialize(schema, obj, Writer = $5296450c35a171ab$var$BinaryWriter) {\n const writer = new Writer();\n $5296450c35a171ab$var$serializeStruct(schema, obj, writer);\n return writer.toArray();\n}\nmodule.exports.serialize = $5296450c35a171ab$var$serialize;\nfunction $5296450c35a171ab$var$deserializeField(schema, fieldName, fieldType, reader) {\n try {\n if (typeof fieldType === \"string\") return reader[`read${$5296450c35a171ab$var$capitalizeFirstLetter(fieldType)}`]();\n if (fieldType instanceof Array) {\n if (typeof fieldType[0] === \"number\") return reader.readFixedArray(fieldType[0]);\n else if (typeof fieldType[1] === \"number\") {\n const arr = [];\n for(let i = 0; i < fieldType[1]; i++)arr.push($5296450c35a171ab$var$deserializeField(schema, null, fieldType[0], reader));\n return arr;\n } else return reader.readArray(()=>$5296450c35a171ab$var$deserializeField(schema, fieldName, fieldType[0], reader));\n }\n if (fieldType.kind === \"option\") {\n const option = reader.readU8();\n if (option) return $5296450c35a171ab$var$deserializeField(schema, fieldName, fieldType.type, reader);\n return undefined;\n }\n if (fieldType.kind === \"map\") {\n let map = new Map();\n const length = reader.readU32();\n for(let i = 0; i < length; i++){\n const key = $5296450c35a171ab$var$deserializeField(schema, fieldName, fieldType.key, reader);\n const val = $5296450c35a171ab$var$deserializeField(schema, fieldName, fieldType.value, reader);\n map.set(key, val);\n }\n return map;\n }\n return $5296450c35a171ab$var$deserializeStruct(schema, fieldType, reader);\n } catch (error) {\n if (error instanceof $5296450c35a171ab$var$BorshError) error.addToFieldPath(fieldName);\n throw error;\n }\n}\nfunction $5296450c35a171ab$var$deserializeStruct(schema, classType, reader) {\n if (typeof classType.borshDeserialize === \"function\") return classType.borshDeserialize(reader);\n const structSchema = schema.get(classType);\n if (!structSchema) throw new $5296450c35a171ab$var$BorshError(`Class ${classType.name} is missing in schema`);\n if (structSchema.kind === \"struct\") {\n const result = {};\n for (const [fieldName, fieldType] of schema.get(classType).fields)result[fieldName] = $5296450c35a171ab$var$deserializeField(schema, fieldName, fieldType, reader);\n return new classType(result);\n }\n if (structSchema.kind === \"enum\") {\n const idx = reader.readU8();\n if (idx >= structSchema.values.length) throw new $5296450c35a171ab$var$BorshError(`Enum index: ${idx} is out of range`);\n const [fieldName, fieldType] = structSchema.values[idx];\n const fieldValue = $5296450c35a171ab$var$deserializeField(schema, fieldName, fieldType, reader);\n return new classType({\n [fieldName]: fieldValue\n });\n }\n throw new $5296450c35a171ab$var$BorshError(`Unexpected schema kind: ${structSchema.kind} for ${classType.constructor.name}`);\n}\n/// Deserializes object from bytes using schema.\nfunction $5296450c35a171ab$var$deserialize(schema, classType, buffer, Reader = $5296450c35a171ab$var$BinaryReader) {\n const reader = new Reader(buffer);\n const result = $5296450c35a171ab$var$deserializeStruct(schema, classType, reader);\n if (reader.offset < buffer.length) throw new $5296450c35a171ab$var$BorshError(`Unexpected ${buffer.length - reader.offset} bytes after deserialized data`);\n return result;\n}\nmodule.exports.deserialize = $5296450c35a171ab$var$deserialize;\n/// Deserializes object from bytes using schema, without checking the length read\nfunction $5296450c35a171ab$var$deserializeUnchecked(schema, classType, buffer, Reader = $5296450c35a171ab$var$BinaryReader) {\n const reader = new Reader(buffer);\n return $5296450c35a171ab$var$deserializeStruct(schema, classType, reader);\n}\nmodule.exports.deserializeUnchecked = $5296450c35a171ab$var$deserializeUnchecked;\n\n});\nparcelRegister(\"kOaA4\", function(module, exports) {\n\n$parcel$export(module.exports, \"TextEncoder\", () => $f260af419b27244f$export$88fb0cfd153261a7, (v) => $f260af419b27244f$export$88fb0cfd153261a7 = v);\n$parcel$export(module.exports, \"TextDecoder\", () => $f260af419b27244f$export$9c6b53e35bc51b5c, (v) => $f260af419b27244f$export$9c6b53e35bc51b5c = v);\nvar $f260af419b27244f$export$88fb0cfd153261a7;\nvar $f260af419b27244f$export$9c6b53e35bc51b5c;\n'use strict';\n// This is free and unencumbered software released into the public domain.\n// See LICENSE.md for more information.\n//\n// Utilities\n//\n/**\n * @param {number} a The number to test.\n * @param {number} min The minimum value in the range, inclusive.\n * @param {number} max The maximum value in the range, inclusive.\n * @return {boolean} True if a >= min and a <= max.\n */ function $f260af419b27244f$var$inRange(a, min, max) {\n return min <= a && a <= max;\n}\n/**\n * @param {*} o\n * @return {Object}\n */ function $f260af419b27244f$var$ToDictionary(o) {\n if (o === undefined) return {};\n if (o === Object(o)) return o;\n throw TypeError('Could not convert argument to dictionary');\n}\n/**\n * @param {string} string Input string of UTF-16 code units.\n * @return {!Array.} Code points.\n */ function $f260af419b27244f$var$stringToCodePoints(string) {\n // https://heycam.github.io/webidl/#dfn-obtain-unicode\n // 1. Let S be the DOMString value.\n var s = String(string);\n // 2. Let n be the length of S.\n var n = s.length;\n // 3. Initialize i to 0.\n var i = 0;\n // 4. Initialize U to be an empty sequence of Unicode characters.\n var u = [];\n // 5. While i < n:\n while(i < n){\n // 1. Let c be the code unit in S at index i.\n var c = s.charCodeAt(i);\n // 2. Depending on the value of c:\n // c < 0xD800 or c > 0xDFFF\n if (c < 0xD800 || c > 0xDFFF) // Append to U the Unicode character with code point c.\n u.push(c);\n else if (0xDC00 <= c && c <= 0xDFFF) // Append to U a U+FFFD REPLACEMENT CHARACTER.\n u.push(0xFFFD);\n else if (0xD800 <= c && c <= 0xDBFF) {\n // 1. If i = n−1, then append to U a U+FFFD REPLACEMENT\n // CHARACTER.\n if (i === n - 1) u.push(0xFFFD);\n else {\n // 1. Let d be the code unit in S at index i+1.\n var d = string.charCodeAt(i + 1);\n // 2. If 0xDC00 ≤ d ≤ 0xDFFF, then:\n if (0xDC00 <= d && d <= 0xDFFF) {\n // 1. Let a be c & 0x3FF.\n var a = c & 0x3FF;\n // 2. Let b be d & 0x3FF.\n var b = d & 0x3FF;\n // 3. Append to U the Unicode character with code point\n // 2^16+2^10*a+b.\n u.push(0x10000 + (a << 10) + b);\n // 4. Set i to i+1.\n i += 1;\n } else u.push(0xFFFD);\n }\n }\n // 3. Set i to i+1.\n i += 1;\n }\n // 6. Return U.\n return u;\n}\n/**\n * @param {!Array.} code_points Array of code points.\n * @return {string} string String of UTF-16 code units.\n */ function $f260af419b27244f$var$codePointsToString(code_points) {\n var s = '';\n for(var i = 0; i < code_points.length; ++i){\n var cp = code_points[i];\n if (cp <= 0xFFFF) s += String.fromCharCode(cp);\n else {\n cp -= 0x10000;\n s += String.fromCharCode((cp >> 10) + 0xD800, (cp & 0x3FF) + 0xDC00);\n }\n }\n return s;\n}\n//\n// Implementation of Encoding specification\n// https://encoding.spec.whatwg.org/\n//\n//\n// 3. Terminology\n//\n/**\n * End-of-stream is a special token that signifies no more tokens\n * are in the stream.\n * @const\n */ var $f260af419b27244f$var$end_of_stream = -1;\n/**\n * A stream represents an ordered sequence of tokens.\n *\n * @constructor\n * @param {!(Array.|Uint8Array)} tokens Array of tokens that provide the\n * stream.\n */ function $f260af419b27244f$var$Stream(tokens) {\n /** @type {!Array.} */ this.tokens = [].slice.call(tokens);\n}\n$f260af419b27244f$var$Stream.prototype = {\n /**\n * @return {boolean} True if end-of-stream has been hit.\n */ endOfStream: function() {\n return !this.tokens.length;\n },\n /**\n * When a token is read from a stream, the first token in the\n * stream must be returned and subsequently removed, and\n * end-of-stream must be returned otherwise.\n *\n * @return {number} Get the next token from the stream, or\n * end_of_stream.\n */ read: function() {\n if (!this.tokens.length) return $f260af419b27244f$var$end_of_stream;\n return this.tokens.shift();\n },\n /**\n * When one or more tokens are prepended to a stream, those tokens\n * must be inserted, in given order, before the first token in the\n * stream.\n *\n * @param {(number|!Array.)} token The token(s) to prepend to the stream.\n */ prepend: function(token) {\n if (Array.isArray(token)) {\n var tokens = /**@type {!Array.}*/ token;\n while(tokens.length)this.tokens.unshift(tokens.pop());\n } else this.tokens.unshift(token);\n },\n /**\n * When one or more tokens are pushed to a stream, those tokens\n * must be inserted, in given order, after the last token in the\n * stream.\n *\n * @param {(number|!Array.)} token The tokens(s) to prepend to the stream.\n */ push: function(token) {\n if (Array.isArray(token)) {\n var tokens = /**@type {!Array.}*/ token;\n while(tokens.length)this.tokens.push(tokens.shift());\n } else this.tokens.push(token);\n }\n};\n//\n// 4. Encodings\n//\n// 4.1 Encoders and decoders\n/** @const */ var $f260af419b27244f$var$finished = -1;\n/**\n * @param {boolean} fatal If true, decoding errors raise an exception.\n * @param {number=} opt_code_point Override the standard fallback code point.\n * @return {number} The code point to insert on a decoding error.\n */ function $f260af419b27244f$var$decoderError(fatal, opt_code_point) {\n if (fatal) throw TypeError('Decoder error');\n return opt_code_point || 0xFFFD;\n}\n//\n// 7. API\n//\n/** @const */ var $f260af419b27244f$var$DEFAULT_ENCODING = 'utf-8';\n// 7.1 Interface TextDecoder\n/**\n * @constructor\n * @param {string=} encoding The label of the encoding;\n * defaults to 'utf-8'.\n * @param {Object=} options\n */ function $f260af419b27244f$var$TextDecoder(encoding, options) {\n if (!(this instanceof $f260af419b27244f$var$TextDecoder)) return new $f260af419b27244f$var$TextDecoder(encoding, options);\n encoding = encoding !== undefined ? String(encoding).toLowerCase() : $f260af419b27244f$var$DEFAULT_ENCODING;\n if (encoding !== $f260af419b27244f$var$DEFAULT_ENCODING) throw new Error('Encoding not supported. Only utf-8 is supported');\n options = $f260af419b27244f$var$ToDictionary(options);\n /** @private @type {boolean} */ this._streaming = false;\n /** @private @type {boolean} */ this._BOMseen = false;\n /** @private @type {?Decoder} */ this._decoder = null;\n /** @private @type {boolean} */ this._fatal = Boolean(options['fatal']);\n /** @private @type {boolean} */ this._ignoreBOM = Boolean(options['ignoreBOM']);\n Object.defineProperty(this, 'encoding', {\n value: 'utf-8'\n });\n Object.defineProperty(this, 'fatal', {\n value: this._fatal\n });\n Object.defineProperty(this, 'ignoreBOM', {\n value: this._ignoreBOM\n });\n}\n$f260af419b27244f$var$TextDecoder.prototype = {\n /**\n * @param {ArrayBufferView=} input The buffer of bytes to decode.\n * @param {Object=} options\n * @return {string} The decoded string.\n */ decode: function decode(input, options) {\n var bytes;\n if (typeof input === 'object' && input instanceof ArrayBuffer) bytes = new Uint8Array(input);\n else if (typeof input === 'object' && 'buffer' in input && input.buffer instanceof ArrayBuffer) bytes = new Uint8Array(input.buffer, input.byteOffset, input.byteLength);\n else bytes = new Uint8Array(0);\n options = $f260af419b27244f$var$ToDictionary(options);\n if (!this._streaming) {\n this._decoder = new $f260af419b27244f$var$UTF8Decoder({\n fatal: this._fatal\n });\n this._BOMseen = false;\n }\n this._streaming = Boolean(options['stream']);\n var input_stream = new $f260af419b27244f$var$Stream(bytes);\n var code_points = [];\n /** @type {?(number|!Array.)} */ var result;\n while(!input_stream.endOfStream()){\n result = this._decoder.handler(input_stream, input_stream.read());\n if (result === $f260af419b27244f$var$finished) break;\n if (result === null) continue;\n if (Array.isArray(result)) code_points.push.apply(code_points, /**@type {!Array.}*/ result);\n else code_points.push(result);\n }\n if (!this._streaming) {\n do {\n result = this._decoder.handler(input_stream, input_stream.read());\n if (result === $f260af419b27244f$var$finished) break;\n if (result === null) continue;\n if (Array.isArray(result)) code_points.push.apply(code_points, /**@type {!Array.}*/ result);\n else code_points.push(result);\n }while (!input_stream.endOfStream());\n this._decoder = null;\n }\n if (code_points.length) // If encoding is one of utf-8, utf-16be, and utf-16le, and\n // ignore BOM flag and BOM seen flag are unset, run these\n // subsubsteps:\n {\n if ([\n 'utf-8'\n ].indexOf(this.encoding) !== -1 && !this._ignoreBOM && !this._BOMseen) {\n // If token is U+FEFF, set BOM seen flag.\n if (code_points[0] === 0xFEFF) {\n this._BOMseen = true;\n code_points.shift();\n } else // Otherwise, if token is not end-of-stream, set BOM seen\n // flag and append token to output.\n this._BOMseen = true;\n }\n }\n return $f260af419b27244f$var$codePointsToString(code_points);\n }\n};\n// 7.2 Interface TextEncoder\n/**\n * @constructor\n * @param {string=} encoding The label of the encoding;\n * defaults to 'utf-8'.\n * @param {Object=} options\n */ function $f260af419b27244f$var$TextEncoder(encoding, options) {\n if (!(this instanceof $f260af419b27244f$var$TextEncoder)) return new $f260af419b27244f$var$TextEncoder(encoding, options);\n encoding = encoding !== undefined ? String(encoding).toLowerCase() : $f260af419b27244f$var$DEFAULT_ENCODING;\n if (encoding !== $f260af419b27244f$var$DEFAULT_ENCODING) throw new Error('Encoding not supported. Only utf-8 is supported');\n options = $f260af419b27244f$var$ToDictionary(options);\n /** @private @type {boolean} */ this._streaming = false;\n /** @private @type {?Encoder} */ this._encoder = null;\n /** @private @type {{fatal: boolean}} */ this._options = {\n fatal: Boolean(options['fatal'])\n };\n Object.defineProperty(this, 'encoding', {\n value: 'utf-8'\n });\n}\n$f260af419b27244f$var$TextEncoder.prototype = {\n /**\n * @param {string=} opt_string The string to encode.\n * @param {Object=} options\n * @return {Uint8Array} Encoded bytes, as a Uint8Array.\n */ encode: function encode(opt_string, options) {\n opt_string = opt_string ? String(opt_string) : '';\n options = $f260af419b27244f$var$ToDictionary(options);\n // NOTE: This option is nonstandard. None of the encodings\n // permitted for encoding (i.e. UTF-8, UTF-16) are stateful,\n // so streaming is not necessary.\n if (!this._streaming) this._encoder = new $f260af419b27244f$var$UTF8Encoder(this._options);\n this._streaming = Boolean(options['stream']);\n var bytes = [];\n var input_stream = new $f260af419b27244f$var$Stream($f260af419b27244f$var$stringToCodePoints(opt_string));\n /** @type {?(number|!Array.)} */ var result;\n while(!input_stream.endOfStream()){\n result = this._encoder.handler(input_stream, input_stream.read());\n if (result === $f260af419b27244f$var$finished) break;\n if (Array.isArray(result)) bytes.push.apply(bytes, /**@type {!Array.}*/ result);\n else bytes.push(result);\n }\n if (!this._streaming) {\n while(true){\n result = this._encoder.handler(input_stream, input_stream.read());\n if (result === $f260af419b27244f$var$finished) break;\n if (Array.isArray(result)) bytes.push.apply(bytes, /**@type {!Array.}*/ result);\n else bytes.push(result);\n }\n this._encoder = null;\n }\n return new Uint8Array(bytes);\n }\n};\n//\n// 8. The encoding\n//\n// 8.1 utf-8\n/**\n * @constructor\n * @implements {Decoder}\n * @param {{fatal: boolean}} options\n */ function $f260af419b27244f$var$UTF8Decoder(options) {\n var fatal = options.fatal;\n // utf-8's decoder's has an associated utf-8 code point, utf-8\n // bytes seen, and utf-8 bytes needed (all initially 0), a utf-8\n // lower boundary (initially 0x80), and a utf-8 upper boundary\n // (initially 0xBF).\n var /** @type {number} */ utf8_code_point = 0, /** @type {number} */ utf8_bytes_seen = 0, /** @type {number} */ utf8_bytes_needed = 0, /** @type {number} */ utf8_lower_boundary = 0x80, /** @type {number} */ utf8_upper_boundary = 0xBF;\n /**\n * @param {Stream} stream The stream of bytes being decoded.\n * @param {number} bite The next byte read from the stream.\n * @return {?(number|!Array.)} The next code point(s)\n * decoded, or null if not enough data exists in the input\n * stream to decode a complete code point.\n */ this.handler = function(stream, bite) {\n // 1. If byte is end-of-stream and utf-8 bytes needed is not 0,\n // set utf-8 bytes needed to 0 and return error.\n if (bite === $f260af419b27244f$var$end_of_stream && utf8_bytes_needed !== 0) {\n utf8_bytes_needed = 0;\n return $f260af419b27244f$var$decoderError(fatal);\n }\n // 2. If byte is end-of-stream, return finished.\n if (bite === $f260af419b27244f$var$end_of_stream) return $f260af419b27244f$var$finished;\n // 3. If utf-8 bytes needed is 0, based on byte:\n if (utf8_bytes_needed === 0) {\n // 0x00 to 0x7F\n if ($f260af419b27244f$var$inRange(bite, 0x00, 0x7F)) // Return a code point whose value is byte.\n return bite;\n // 0xC2 to 0xDF\n if ($f260af419b27244f$var$inRange(bite, 0xC2, 0xDF)) {\n // Set utf-8 bytes needed to 1 and utf-8 code point to byte\n // − 0xC0.\n utf8_bytes_needed = 1;\n utf8_code_point = bite - 0xC0;\n } else if ($f260af419b27244f$var$inRange(bite, 0xE0, 0xEF)) {\n // 1. If byte is 0xE0, set utf-8 lower boundary to 0xA0.\n if (bite === 0xE0) utf8_lower_boundary = 0xA0;\n // 2. If byte is 0xED, set utf-8 upper boundary to 0x9F.\n if (bite === 0xED) utf8_upper_boundary = 0x9F;\n // 3. Set utf-8 bytes needed to 2 and utf-8 code point to\n // byte − 0xE0.\n utf8_bytes_needed = 2;\n utf8_code_point = bite - 0xE0;\n } else if ($f260af419b27244f$var$inRange(bite, 0xF0, 0xF4)) {\n // 1. If byte is 0xF0, set utf-8 lower boundary to 0x90.\n if (bite === 0xF0) utf8_lower_boundary = 0x90;\n // 2. If byte is 0xF4, set utf-8 upper boundary to 0x8F.\n if (bite === 0xF4) utf8_upper_boundary = 0x8F;\n // 3. Set utf-8 bytes needed to 3 and utf-8 code point to\n // byte − 0xF0.\n utf8_bytes_needed = 3;\n utf8_code_point = bite - 0xF0;\n } else // Return error.\n return $f260af419b27244f$var$decoderError(fatal);\n // Then (byte is in the range 0xC2 to 0xF4) set utf-8 code\n // point to utf-8 code point << (6 × utf-8 bytes needed) and\n // return continue.\n utf8_code_point = utf8_code_point << 6 * utf8_bytes_needed;\n return null;\n }\n // 4. If byte is not in the range utf-8 lower boundary to utf-8\n // upper boundary, run these substeps:\n if (!$f260af419b27244f$var$inRange(bite, utf8_lower_boundary, utf8_upper_boundary)) {\n // 1. Set utf-8 code point, utf-8 bytes needed, and utf-8\n // bytes seen to 0, set utf-8 lower boundary to 0x80, and set\n // utf-8 upper boundary to 0xBF.\n utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;\n utf8_lower_boundary = 0x80;\n utf8_upper_boundary = 0xBF;\n // 2. Prepend byte to stream.\n stream.prepend(bite);\n // 3. Return error.\n return $f260af419b27244f$var$decoderError(fatal);\n }\n // 5. Set utf-8 lower boundary to 0x80 and utf-8 upper boundary\n // to 0xBF.\n utf8_lower_boundary = 0x80;\n utf8_upper_boundary = 0xBF;\n // 6. Increase utf-8 bytes seen by one and set utf-8 code point\n // to utf-8 code point + (byte − 0x80) << (6 × (utf-8 bytes\n // needed − utf-8 bytes seen)).\n utf8_bytes_seen += 1;\n utf8_code_point += bite - 0x80 << 6 * (utf8_bytes_needed - utf8_bytes_seen);\n // 7. If utf-8 bytes seen is not equal to utf-8 bytes needed,\n // continue.\n if (utf8_bytes_seen !== utf8_bytes_needed) return null;\n // 8. Let code point be utf-8 code point.\n var code_point = utf8_code_point;\n // 9. Set utf-8 code point, utf-8 bytes needed, and utf-8 bytes\n // seen to 0.\n utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;\n // 10. Return a code point whose value is code point.\n return code_point;\n };\n}\n/**\n * @constructor\n * @implements {Encoder}\n * @param {{fatal: boolean}} options\n */ function $f260af419b27244f$var$UTF8Encoder(options) {\n var fatal = options.fatal;\n /**\n * @param {Stream} stream Input stream.\n * @param {number} code_point Next code point read from the stream.\n * @return {(number|!Array.)} Byte(s) to emit.\n */ this.handler = function(stream, code_point) {\n // 1. If code point is end-of-stream, return finished.\n if (code_point === $f260af419b27244f$var$end_of_stream) return $f260af419b27244f$var$finished;\n // 2. If code point is in the range U+0000 to U+007F, return a\n // byte whose value is code point.\n if ($f260af419b27244f$var$inRange(code_point, 0x0000, 0x007f)) return code_point;\n // 3. Set count and offset based on the range code point is in:\n var count, offset;\n // U+0080 to U+07FF: 1 and 0xC0\n if ($f260af419b27244f$var$inRange(code_point, 0x0080, 0x07FF)) {\n count = 1;\n offset = 0xC0;\n } else if ($f260af419b27244f$var$inRange(code_point, 0x0800, 0xFFFF)) {\n count = 2;\n offset = 0xE0;\n } else if ($f260af419b27244f$var$inRange(code_point, 0x10000, 0x10FFFF)) {\n count = 3;\n offset = 0xF0;\n }\n // 4.Let bytes be a byte sequence whose first byte is (code\n // point >> (6 × count)) + offset.\n var bytes = [\n (code_point >> 6 * count) + offset\n ];\n // 5. Run these substeps while count is greater than 0:\n while(count > 0){\n // 1. Set temp to code point >> (6 × (count − 1)).\n var temp = code_point >> 6 * (count - 1);\n // 2. Append to bytes 0x80 | (temp & 0x3F).\n bytes.push(0x80 | temp & 0x3F);\n // 3. Decrease count by one.\n count -= 1;\n }\n // 6. Return bytes bytes, in order.\n return bytes;\n };\n}\n$f260af419b27244f$export$88fb0cfd153261a7 = $f260af419b27244f$var$TextEncoder;\n$f260af419b27244f$export$9c6b53e35bc51b5c = $f260af419b27244f$var$TextDecoder;\n\n});\n\n\nparcelRegister(\"Q02IV\", function(module, exports) {\n/* The MIT License (MIT)\n *\n * Copyright 2015-2018 Peter A. Bigot\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */ /**\n * Support for translating between Uint8Array instances and JavaScript\n * native types.\n *\n * {@link module:Layout~Layout|Layout} is the basis of a class\n * hierarchy that associates property names with sequences of encoded\n * bytes.\n *\n * Layouts are supported for these scalar (numeric) types:\n * * {@link module:Layout~UInt|Unsigned integers in little-endian\n * format} with {@link module:Layout.u8|8-bit}, {@link\n * module:Layout.u16|16-bit}, {@link module:Layout.u24|24-bit},\n * {@link module:Layout.u32|32-bit}, {@link\n * module:Layout.u40|40-bit}, and {@link module:Layout.u48|48-bit}\n * representation ranges;\n * * {@link module:Layout~UIntBE|Unsigned integers in big-endian\n * format} with {@link module:Layout.u16be|16-bit}, {@link\n * module:Layout.u24be|24-bit}, {@link module:Layout.u32be|32-bit},\n * {@link module:Layout.u40be|40-bit}, and {@link\n * module:Layout.u48be|48-bit} representation ranges;\n * * {@link module:Layout~Int|Signed integers in little-endian\n * format} with {@link module:Layout.s8|8-bit}, {@link\n * module:Layout.s16|16-bit}, {@link module:Layout.s24|24-bit},\n * {@link module:Layout.s32|32-bit}, {@link\n * module:Layout.s40|40-bit}, and {@link module:Layout.s48|48-bit}\n * representation ranges;\n * * {@link module:Layout~IntBE|Signed integers in big-endian format}\n * with {@link module:Layout.s16be|16-bit}, {@link\n * module:Layout.s24be|24-bit}, {@link module:Layout.s32be|32-bit},\n * {@link module:Layout.s40be|40-bit}, and {@link\n * module:Layout.s48be|48-bit} representation ranges;\n * * 64-bit integral values that decode to an exact (if magnitude is\n * less than 2^53) or nearby integral Number in {@link\n * module:Layout.nu64|unsigned little-endian}, {@link\n * module:Layout.nu64be|unsigned big-endian}, {@link\n * module:Layout.ns64|signed little-endian}, and {@link\n * module:Layout.ns64be|unsigned big-endian} encodings;\n * * 32-bit floating point values with {@link\n * module:Layout.f32|little-endian} and {@link\n * module:Layout.f32be|big-endian} representations;\n * * 64-bit floating point values with {@link\n * module:Layout.f64|little-endian} and {@link\n * module:Layout.f64be|big-endian} representations;\n * * {@link module:Layout.const|Constants} that take no space in the\n * encoded expression.\n *\n * and for these aggregate types:\n * * {@link module:Layout.seq|Sequence}s of instances of a {@link\n * module:Layout~Layout|Layout}, with JavaScript representation as\n * an Array and constant or data-dependent {@link\n * module:Layout~Sequence#count|length};\n * * {@link module:Layout.struct|Structure}s that aggregate a\n * heterogeneous sequence of {@link module:Layout~Layout|Layout}\n * instances, with JavaScript representation as an Object;\n * * {@link module:Layout.union|Union}s that support multiple {@link\n * module:Layout~VariantLayout|variant layouts} over a fixed\n * (padded) or variable (not padded) span of bytes, using an\n * unsigned integer at the start of the data or a separate {@link\n * module:Layout.unionLayoutDiscriminator|layout element} to\n * determine which layout to use when interpreting the buffer\n * contents;\n * * {@link module:Layout.bits|BitStructure}s that contain a sequence\n * of individual {@link\n * module:Layout~BitStructure#addField|BitField}s packed into an 8,\n * 16, 24, or 32-bit unsigned integer starting at the least- or\n * most-significant bit;\n * * {@link module:Layout.cstr|C strings} of varying length;\n * * {@link module:Layout.blob|Blobs} of fixed- or variable-{@link\n * module:Layout~Blob#length|length} raw data.\n *\n * All {@link module:Layout~Layout|Layout} instances are immutable\n * after construction, to prevent internal state from becoming\n * inconsistent.\n *\n * @local Layout\n * @local ExternalLayout\n * @local GreedyCount\n * @local OffsetLayout\n * @local UInt\n * @local UIntBE\n * @local Int\n * @local IntBE\n * @local NearUInt64\n * @local NearUInt64BE\n * @local NearInt64\n * @local NearInt64BE\n * @local Float\n * @local FloatBE\n * @local Double\n * @local DoubleBE\n * @local Sequence\n * @local Structure\n * @local UnionDiscriminator\n * @local UnionLayoutDiscriminator\n * @local Union\n * @local VariantLayout\n * @local BitStructure\n * @local BitField\n * @local Boolean\n * @local Blob\n * @local CString\n * @local Constant\n * @local bindConstructorLayout\n * @module Layout\n * @license MIT\n * @author Peter A. Bigot\n * @see {@link https://github.com/pabigot/buffer-layout|buffer-layout on GitHub}\n */ 'use strict';\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.s16 = module.exports.s8 = module.exports.nu64be = module.exports.u48be = module.exports.u40be = module.exports.u32be = module.exports.u24be = module.exports.u16be = module.exports.nu64 = module.exports.u48 = module.exports.u40 = module.exports.u32 = module.exports.u24 = module.exports.u16 = module.exports.u8 = module.exports.offset = module.exports.greedy = module.exports.Constant = module.exports.UTF8 = module.exports.CString = module.exports.Blob = module.exports.Boolean = module.exports.BitField = module.exports.BitStructure = module.exports.VariantLayout = module.exports.Union = module.exports.UnionLayoutDiscriminator = module.exports.UnionDiscriminator = module.exports.Structure = module.exports.Sequence = module.exports.DoubleBE = module.exports.Double = module.exports.FloatBE = module.exports.Float = module.exports.NearInt64BE = module.exports.NearInt64 = module.exports.NearUInt64BE = module.exports.NearUInt64 = module.exports.IntBE = module.exports.Int = module.exports.UIntBE = module.exports.UInt = module.exports.OffsetLayout = module.exports.GreedyCount = module.exports.ExternalLayout = module.exports.bindConstructorLayout = module.exports.nameWithProperty = module.exports.Layout = module.exports.uint8ArrayToBuffer = module.exports.checkUint8Array = void 0;\nmodule.exports.constant = module.exports.utf8 = module.exports.cstr = module.exports.blob = module.exports.unionLayoutDiscriminator = module.exports.union = module.exports.seq = module.exports.bits = module.exports.struct = module.exports.f64be = module.exports.f64 = module.exports.f32be = module.exports.f32 = module.exports.ns64be = module.exports.s48be = module.exports.s40be = module.exports.s32be = module.exports.s24be = module.exports.s16be = module.exports.ns64 = module.exports.s48 = module.exports.s40 = module.exports.s32 = module.exports.s24 = void 0;\n\nvar $6ZWSX = parcelRequire(\"6ZWSX\");\n/* Check if a value is a Uint8Array.\n *\n * @ignore */ function $09c4e3f7de797447$var$checkUint8Array(b) {\n if (!(b instanceof Uint8Array)) throw new TypeError('b must be a Uint8Array');\n}\nmodule.exports.checkUint8Array = $09c4e3f7de797447$var$checkUint8Array;\n/* Create a Buffer instance from a Uint8Array.\n *\n * @ignore */ function $09c4e3f7de797447$var$uint8ArrayToBuffer(b) {\n $09c4e3f7de797447$var$checkUint8Array(b);\n return $6ZWSX.Buffer.from(b.buffer, b.byteOffset, b.length);\n}\nmodule.exports.uint8ArrayToBuffer = $09c4e3f7de797447$var$uint8ArrayToBuffer;\n/**\n * Base class for layout objects.\n *\n * **NOTE** This is an abstract base class; you can create instances\n * if it amuses you, but they won't support the {@link\n * Layout#encode|encode} or {@link Layout#decode|decode} functions.\n *\n * @param {Number} span - Initializer for {@link Layout#span|span}. The\n * parameter must be an integer; a negative value signifies that the\n * span is {@link Layout#getSpan|value-specific}.\n *\n * @param {string} [property] - Initializer for {@link\n * Layout#property|property}.\n *\n * @abstract\n */ class $09c4e3f7de797447$var$Layout {\n constructor(span, property){\n if (!Number.isInteger(span)) throw new TypeError('span must be an integer');\n /** The span of the layout in bytes.\n *\n * Positive values are generally expected.\n *\n * Zero will only appear in {@link Constant}s and in {@link\n * Sequence}s where the {@link Sequence#count|count} is zero.\n *\n * A negative value indicates that the span is value-specific, and\n * must be obtained using {@link Layout#getSpan|getSpan}. */ this.span = span;\n /** The property name used when this layout is represented in an\n * Object.\n *\n * Used only for layouts that {@link Layout#decode|decode} to Object\n * instances. If left undefined the span of the unnamed layout will\n * be treated as padding: it will not be mutated by {@link\n * Layout#encode|encode} nor represented as a property in the\n * decoded Object. */ this.property = property;\n }\n /** Function to create an Object into which decoded properties will\n * be written.\n *\n * Used only for layouts that {@link Layout#decode|decode} to Object\n * instances, which means:\n * * {@link Structure}\n * * {@link Union}\n * * {@link VariantLayout}\n * * {@link BitStructure}\n *\n * If left undefined the JavaScript representation of these layouts\n * will be Object instances.\n *\n * See {@link bindConstructorLayout}.\n */ makeDestinationObject() {\n return {};\n }\n /**\n * Calculate the span of a specific instance of a layout.\n *\n * @param {Uint8Array} b - the buffer that contains an encoded instance.\n *\n * @param {Number} [offset] - the offset at which the encoded instance\n * starts. If absent a zero offset is inferred.\n *\n * @return {Number} - the number of bytes covered by the layout\n * instance. If this method is not overridden in a subclass the\n * definition-time constant {@link Layout#span|span} will be\n * returned.\n *\n * @throws {RangeError} - if the length of the value cannot be\n * determined.\n */ getSpan(b, offset) {\n if (0 > this.span) throw new RangeError('indeterminate span');\n return this.span;\n }\n /**\n * Replicate the layout using a new property.\n *\n * This function must be used to get a structurally-equivalent layout\n * with a different name since all {@link Layout} instances are\n * immutable.\n *\n * **NOTE** This is a shallow copy. All fields except {@link\n * Layout#property|property} are strictly equal to the origin layout.\n *\n * @param {String} property - the value for {@link\n * Layout#property|property} in the replica.\n *\n * @returns {Layout} - the copy with {@link Layout#property|property}\n * set to `property`.\n */ replicate(property) {\n const rv = Object.create(this.constructor.prototype);\n Object.assign(rv, this);\n rv.property = property;\n return rv;\n }\n /**\n * Create an object from layout properties and an array of values.\n *\n * **NOTE** This function returns `undefined` if invoked on a layout\n * that does not return its value as an Object. Objects are\n * returned for things that are a {@link Structure}, which includes\n * {@link VariantLayout|variant layouts} if they are structures, and\n * excludes {@link Union}s. If you want this feature for a union\n * you must use {@link Union.getVariant|getVariant} to select the\n * desired layout.\n *\n * @param {Array} values - an array of values that correspond to the\n * default order for properties. As with {@link Layout#decode|decode}\n * layout elements that have no property name are skipped when\n * iterating over the array values. Only the top-level properties are\n * assigned; arguments are not assigned to properties of contained\n * layouts. Any unused values are ignored.\n *\n * @return {(Object|undefined)}\n */ fromArray(values) {\n return undefined;\n }\n}\nmodule.exports.Layout = $09c4e3f7de797447$var$Layout;\n/* Provide text that carries a name (such as for a function that will\n * be throwing an error) annotated with the property of a given layout\n * (such as one for which the value was unacceptable).\n *\n * @ignore */ function $09c4e3f7de797447$var$nameWithProperty(name, lo) {\n if (lo.property) return name + '[' + lo.property + ']';\n return name;\n}\nmodule.exports.nameWithProperty = $09c4e3f7de797447$var$nameWithProperty;\n/**\n * Augment a class so that instances can be encoded/decoded using a\n * given layout.\n *\n * Calling this function couples `Class` with `layout` in several ways:\n *\n * * `Class.layout_` becomes a static member property equal to `layout`;\n * * `layout.boundConstructor_` becomes a static member property equal\n * to `Class`;\n * * The {@link Layout#makeDestinationObject|makeDestinationObject()}\n * property of `layout` is set to a function that returns a `new\n * Class()`;\n * * `Class.decode(b, offset)` becomes a static member function that\n * delegates to {@link Layout#decode|layout.decode}. The\n * synthesized function may be captured and extended.\n * * `Class.prototype.encode(b, offset)` provides an instance member\n * function that delegates to {@link Layout#encode|layout.encode}\n * with `src` set to `this`. The synthesized function may be\n * captured and extended, but when the extension is invoked `this`\n * must be explicitly bound to the instance.\n *\n * @param {class} Class - a JavaScript class with a nullary\n * constructor.\n *\n * @param {Layout} layout - the {@link Layout} instance used to encode\n * instances of `Class`.\n */ // `Class` must be a constructor Function, but the assignment of a `layout_` property to it makes it difficult to type\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nfunction $09c4e3f7de797447$var$bindConstructorLayout(Class, layout) {\n if ('function' !== typeof Class) throw new TypeError('Class must be constructor');\n if (Object.prototype.hasOwnProperty.call(Class, 'layout_')) throw new Error('Class is already bound to a layout');\n if (!(layout && layout instanceof $09c4e3f7de797447$var$Layout)) throw new TypeError('layout must be a Layout');\n if (Object.prototype.hasOwnProperty.call(layout, 'boundConstructor_')) throw new Error('layout is already bound to a constructor');\n Class.layout_ = layout;\n layout.boundConstructor_ = Class;\n layout.makeDestinationObject = ()=>new Class();\n Object.defineProperty(Class.prototype, 'encode', {\n value (b, offset) {\n return layout.encode(this, b, offset);\n },\n writable: true\n });\n Object.defineProperty(Class, 'decode', {\n value (b, offset) {\n return layout.decode(b, offset);\n },\n writable: true\n });\n}\nmodule.exports.bindConstructorLayout = $09c4e3f7de797447$var$bindConstructorLayout;\n/**\n * An object that behaves like a layout but does not consume space\n * within its containing layout.\n *\n * This is primarily used to obtain metadata about a member, such as a\n * {@link OffsetLayout} that can provide data about a {@link\n * Layout#getSpan|value-specific span}.\n *\n * **NOTE** This is an abstract base class; you can create instances\n * if it amuses you, but they won't support {@link\n * ExternalLayout#isCount|isCount} or other {@link Layout} functions.\n *\n * @param {Number} span - initializer for {@link Layout#span|span}.\n * The parameter can range from 1 through 6.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @abstract\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$ExternalLayout extends $09c4e3f7de797447$var$Layout {\n /**\n * Return `true` iff the external layout decodes to an unsigned\n * integer layout.\n *\n * In that case it can be used as the source of {@link\n * Sequence#count|Sequence counts}, {@link Blob#length|Blob lengths},\n * or as {@link UnionLayoutDiscriminator#layout|external union\n * discriminators}.\n *\n * @abstract\n */ isCount() {\n throw new Error('ExternalLayout is abstract');\n }\n}\nmodule.exports.ExternalLayout = $09c4e3f7de797447$var$ExternalLayout;\n/**\n * An {@link ExternalLayout} that determines its {@link\n * Layout#decode|value} based on offset into and length of the buffer\n * on which it is invoked.\n *\n * *Factory*: {@link module:Layout.greedy|greedy}\n *\n * @param {Number} [elementSpan] - initializer for {@link\n * GreedyCount#elementSpan|elementSpan}.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {ExternalLayout}\n */ class $09c4e3f7de797447$var$GreedyCount extends $09c4e3f7de797447$var$ExternalLayout {\n constructor(elementSpan = 1, property){\n if (!Number.isInteger(elementSpan) || 0 >= elementSpan) throw new TypeError('elementSpan must be a (positive) integer');\n super(-1, property);\n /** The layout for individual elements of the sequence. The value\n * must be a positive integer. If not provided, the value will be\n * 1. */ this.elementSpan = elementSpan;\n }\n /** @override */ isCount() {\n return true;\n }\n /** @override */ decode(b, offset = 0) {\n $09c4e3f7de797447$var$checkUint8Array(b);\n const rem = b.length - offset;\n return Math.floor(rem / this.elementSpan);\n }\n /** @override */ encode(src, b, offset) {\n return 0;\n }\n}\nmodule.exports.GreedyCount = $09c4e3f7de797447$var$GreedyCount;\n/**\n * An {@link ExternalLayout} that supports accessing a {@link Layout}\n * at a fixed offset from the start of another Layout. The offset may\n * be before, within, or after the base layout.\n *\n * *Factory*: {@link module:Layout.offset|offset}\n *\n * @param {Layout} layout - initializer for {@link\n * OffsetLayout#layout|layout}, modulo `property`.\n *\n * @param {Number} [offset] - Initializes {@link\n * OffsetLayout#offset|offset}. Defaults to zero.\n *\n * @param {string} [property] - Optional new property name for a\n * {@link Layout#replicate| replica} of `layout` to be used as {@link\n * OffsetLayout#layout|layout}. If not provided the `layout` is used\n * unchanged.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$OffsetLayout extends $09c4e3f7de797447$var$ExternalLayout {\n constructor(layout, offset = 0, property){\n if (!(layout instanceof $09c4e3f7de797447$var$Layout)) throw new TypeError('layout must be a Layout');\n if (!Number.isInteger(offset)) throw new TypeError('offset must be integer or undefined');\n super(layout.span, property || layout.property);\n /** The subordinated layout. */ this.layout = layout;\n /** The location of {@link OffsetLayout#layout} relative to the\n * start of another layout.\n *\n * The value may be positive or negative, but an error will thrown\n * if at the point of use it goes outside the span of the Uint8Array\n * being accessed. */ this.offset = offset;\n }\n /** @override */ isCount() {\n return this.layout instanceof $09c4e3f7de797447$var$UInt || this.layout instanceof $09c4e3f7de797447$var$UIntBE;\n }\n /** @override */ decode(b, offset = 0) {\n return this.layout.decode(b, offset + this.offset);\n }\n /** @override */ encode(src, b, offset = 0) {\n return this.layout.encode(src, b, offset + this.offset);\n }\n}\nmodule.exports.OffsetLayout = $09c4e3f7de797447$var$OffsetLayout;\n/**\n * Represent an unsigned integer in little-endian format.\n *\n * *Factory*: {@link module:Layout.u8|u8}, {@link\n * module:Layout.u16|u16}, {@link module:Layout.u24|u24}, {@link\n * module:Layout.u32|u32}, {@link module:Layout.u40|u40}, {@link\n * module:Layout.u48|u48}\n *\n * @param {Number} span - initializer for {@link Layout#span|span}.\n * The parameter can range from 1 through 6.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$UInt extends $09c4e3f7de797447$var$Layout {\n constructor(span, property){\n super(span, property);\n if (6 < this.span) throw new RangeError('span must not exceed 6 bytes');\n }\n /** @override */ decode(b, offset = 0) {\n return $09c4e3f7de797447$var$uint8ArrayToBuffer(b).readUIntLE(offset, this.span);\n }\n /** @override */ encode(src, b, offset = 0) {\n $09c4e3f7de797447$var$uint8ArrayToBuffer(b).writeUIntLE(src, offset, this.span);\n return this.span;\n }\n}\nmodule.exports.UInt = $09c4e3f7de797447$var$UInt;\n/**\n * Represent an unsigned integer in big-endian format.\n *\n * *Factory*: {@link module:Layout.u8be|u8be}, {@link\n * module:Layout.u16be|u16be}, {@link module:Layout.u24be|u24be},\n * {@link module:Layout.u32be|u32be}, {@link\n * module:Layout.u40be|u40be}, {@link module:Layout.u48be|u48be}\n *\n * @param {Number} span - initializer for {@link Layout#span|span}.\n * The parameter can range from 1 through 6.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$UIntBE extends $09c4e3f7de797447$var$Layout {\n constructor(span, property){\n super(span, property);\n if (6 < this.span) throw new RangeError('span must not exceed 6 bytes');\n }\n /** @override */ decode(b, offset = 0) {\n return $09c4e3f7de797447$var$uint8ArrayToBuffer(b).readUIntBE(offset, this.span);\n }\n /** @override */ encode(src, b, offset = 0) {\n $09c4e3f7de797447$var$uint8ArrayToBuffer(b).writeUIntBE(src, offset, this.span);\n return this.span;\n }\n}\nmodule.exports.UIntBE = $09c4e3f7de797447$var$UIntBE;\n/**\n * Represent a signed integer in little-endian format.\n *\n * *Factory*: {@link module:Layout.s8|s8}, {@link\n * module:Layout.s16|s16}, {@link module:Layout.s24|s24}, {@link\n * module:Layout.s32|s32}, {@link module:Layout.s40|s40}, {@link\n * module:Layout.s48|s48}\n *\n * @param {Number} span - initializer for {@link Layout#span|span}.\n * The parameter can range from 1 through 6.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$Int extends $09c4e3f7de797447$var$Layout {\n constructor(span, property){\n super(span, property);\n if (6 < this.span) throw new RangeError('span must not exceed 6 bytes');\n }\n /** @override */ decode(b, offset = 0) {\n return $09c4e3f7de797447$var$uint8ArrayToBuffer(b).readIntLE(offset, this.span);\n }\n /** @override */ encode(src, b, offset = 0) {\n $09c4e3f7de797447$var$uint8ArrayToBuffer(b).writeIntLE(src, offset, this.span);\n return this.span;\n }\n}\nmodule.exports.Int = $09c4e3f7de797447$var$Int;\n/**\n * Represent a signed integer in big-endian format.\n *\n * *Factory*: {@link module:Layout.s8be|s8be}, {@link\n * module:Layout.s16be|s16be}, {@link module:Layout.s24be|s24be},\n * {@link module:Layout.s32be|s32be}, {@link\n * module:Layout.s40be|s40be}, {@link module:Layout.s48be|s48be}\n *\n * @param {Number} span - initializer for {@link Layout#span|span}.\n * The parameter can range from 1 through 6.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$IntBE extends $09c4e3f7de797447$var$Layout {\n constructor(span, property){\n super(span, property);\n if (6 < this.span) throw new RangeError('span must not exceed 6 bytes');\n }\n /** @override */ decode(b, offset = 0) {\n return $09c4e3f7de797447$var$uint8ArrayToBuffer(b).readIntBE(offset, this.span);\n }\n /** @override */ encode(src, b, offset = 0) {\n $09c4e3f7de797447$var$uint8ArrayToBuffer(b).writeIntBE(src, offset, this.span);\n return this.span;\n }\n}\nmodule.exports.IntBE = $09c4e3f7de797447$var$IntBE;\nconst $09c4e3f7de797447$var$V2E32 = Math.pow(2, 32);\n/* True modulus high and low 32-bit words, where low word is always\n * non-negative. */ function $09c4e3f7de797447$var$divmodInt64(src) {\n const hi32 = Math.floor(src / $09c4e3f7de797447$var$V2E32);\n const lo32 = src - hi32 * $09c4e3f7de797447$var$V2E32;\n return {\n hi32: hi32,\n lo32: lo32\n };\n}\n/* Reconstruct Number from quotient and non-negative remainder */ function $09c4e3f7de797447$var$roundedInt64(hi32, lo32) {\n return hi32 * $09c4e3f7de797447$var$V2E32 + lo32;\n}\n/**\n * Represent an unsigned 64-bit integer in little-endian format when\n * encoded and as a near integral JavaScript Number when decoded.\n *\n * *Factory*: {@link module:Layout.nu64|nu64}\n *\n * **NOTE** Values with magnitude greater than 2^52 may not decode to\n * the exact value of the encoded representation.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$NearUInt64 extends $09c4e3f7de797447$var$Layout {\n constructor(property){\n super(8, property);\n }\n /** @override */ decode(b, offset = 0) {\n const buffer = $09c4e3f7de797447$var$uint8ArrayToBuffer(b);\n const lo32 = buffer.readUInt32LE(offset);\n const hi32 = buffer.readUInt32LE(offset + 4);\n return $09c4e3f7de797447$var$roundedInt64(hi32, lo32);\n }\n /** @override */ encode(src, b, offset = 0) {\n const split = $09c4e3f7de797447$var$divmodInt64(src);\n const buffer = $09c4e3f7de797447$var$uint8ArrayToBuffer(b);\n buffer.writeUInt32LE(split.lo32, offset);\n buffer.writeUInt32LE(split.hi32, offset + 4);\n return 8;\n }\n}\nmodule.exports.NearUInt64 = $09c4e3f7de797447$var$NearUInt64;\n/**\n * Represent an unsigned 64-bit integer in big-endian format when\n * encoded and as a near integral JavaScript Number when decoded.\n *\n * *Factory*: {@link module:Layout.nu64be|nu64be}\n *\n * **NOTE** Values with magnitude greater than 2^52 may not decode to\n * the exact value of the encoded representation.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$NearUInt64BE extends $09c4e3f7de797447$var$Layout {\n constructor(property){\n super(8, property);\n }\n /** @override */ decode(b, offset = 0) {\n const buffer = $09c4e3f7de797447$var$uint8ArrayToBuffer(b);\n const hi32 = buffer.readUInt32BE(offset);\n const lo32 = buffer.readUInt32BE(offset + 4);\n return $09c4e3f7de797447$var$roundedInt64(hi32, lo32);\n }\n /** @override */ encode(src, b, offset = 0) {\n const split = $09c4e3f7de797447$var$divmodInt64(src);\n const buffer = $09c4e3f7de797447$var$uint8ArrayToBuffer(b);\n buffer.writeUInt32BE(split.hi32, offset);\n buffer.writeUInt32BE(split.lo32, offset + 4);\n return 8;\n }\n}\nmodule.exports.NearUInt64BE = $09c4e3f7de797447$var$NearUInt64BE;\n/**\n * Represent a signed 64-bit integer in little-endian format when\n * encoded and as a near integral JavaScript Number when decoded.\n *\n * *Factory*: {@link module:Layout.ns64|ns64}\n *\n * **NOTE** Values with magnitude greater than 2^52 may not decode to\n * the exact value of the encoded representation.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$NearInt64 extends $09c4e3f7de797447$var$Layout {\n constructor(property){\n super(8, property);\n }\n /** @override */ decode(b, offset = 0) {\n const buffer = $09c4e3f7de797447$var$uint8ArrayToBuffer(b);\n const lo32 = buffer.readUInt32LE(offset);\n const hi32 = buffer.readInt32LE(offset + 4);\n return $09c4e3f7de797447$var$roundedInt64(hi32, lo32);\n }\n /** @override */ encode(src, b, offset = 0) {\n const split = $09c4e3f7de797447$var$divmodInt64(src);\n const buffer = $09c4e3f7de797447$var$uint8ArrayToBuffer(b);\n buffer.writeUInt32LE(split.lo32, offset);\n buffer.writeInt32LE(split.hi32, offset + 4);\n return 8;\n }\n}\nmodule.exports.NearInt64 = $09c4e3f7de797447$var$NearInt64;\n/**\n * Represent a signed 64-bit integer in big-endian format when\n * encoded and as a near integral JavaScript Number when decoded.\n *\n * *Factory*: {@link module:Layout.ns64be|ns64be}\n *\n * **NOTE** Values with magnitude greater than 2^52 may not decode to\n * the exact value of the encoded representation.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$NearInt64BE extends $09c4e3f7de797447$var$Layout {\n constructor(property){\n super(8, property);\n }\n /** @override */ decode(b, offset = 0) {\n const buffer = $09c4e3f7de797447$var$uint8ArrayToBuffer(b);\n const hi32 = buffer.readInt32BE(offset);\n const lo32 = buffer.readUInt32BE(offset + 4);\n return $09c4e3f7de797447$var$roundedInt64(hi32, lo32);\n }\n /** @override */ encode(src, b, offset = 0) {\n const split = $09c4e3f7de797447$var$divmodInt64(src);\n const buffer = $09c4e3f7de797447$var$uint8ArrayToBuffer(b);\n buffer.writeInt32BE(split.hi32, offset);\n buffer.writeUInt32BE(split.lo32, offset + 4);\n return 8;\n }\n}\nmodule.exports.NearInt64BE = $09c4e3f7de797447$var$NearInt64BE;\n/**\n * Represent a 32-bit floating point number in little-endian format.\n *\n * *Factory*: {@link module:Layout.f32|f32}\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$Float extends $09c4e3f7de797447$var$Layout {\n constructor(property){\n super(4, property);\n }\n /** @override */ decode(b, offset = 0) {\n return $09c4e3f7de797447$var$uint8ArrayToBuffer(b).readFloatLE(offset);\n }\n /** @override */ encode(src, b, offset = 0) {\n $09c4e3f7de797447$var$uint8ArrayToBuffer(b).writeFloatLE(src, offset);\n return 4;\n }\n}\nmodule.exports.Float = $09c4e3f7de797447$var$Float;\n/**\n * Represent a 32-bit floating point number in big-endian format.\n *\n * *Factory*: {@link module:Layout.f32be|f32be}\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$FloatBE extends $09c4e3f7de797447$var$Layout {\n constructor(property){\n super(4, property);\n }\n /** @override */ decode(b, offset = 0) {\n return $09c4e3f7de797447$var$uint8ArrayToBuffer(b).readFloatBE(offset);\n }\n /** @override */ encode(src, b, offset = 0) {\n $09c4e3f7de797447$var$uint8ArrayToBuffer(b).writeFloatBE(src, offset);\n return 4;\n }\n}\nmodule.exports.FloatBE = $09c4e3f7de797447$var$FloatBE;\n/**\n * Represent a 64-bit floating point number in little-endian format.\n *\n * *Factory*: {@link module:Layout.f64|f64}\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$Double extends $09c4e3f7de797447$var$Layout {\n constructor(property){\n super(8, property);\n }\n /** @override */ decode(b, offset = 0) {\n return $09c4e3f7de797447$var$uint8ArrayToBuffer(b).readDoubleLE(offset);\n }\n /** @override */ encode(src, b, offset = 0) {\n $09c4e3f7de797447$var$uint8ArrayToBuffer(b).writeDoubleLE(src, offset);\n return 8;\n }\n}\nmodule.exports.Double = $09c4e3f7de797447$var$Double;\n/**\n * Represent a 64-bit floating point number in big-endian format.\n *\n * *Factory*: {@link module:Layout.f64be|f64be}\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$DoubleBE extends $09c4e3f7de797447$var$Layout {\n constructor(property){\n super(8, property);\n }\n /** @override */ decode(b, offset = 0) {\n return $09c4e3f7de797447$var$uint8ArrayToBuffer(b).readDoubleBE(offset);\n }\n /** @override */ encode(src, b, offset = 0) {\n $09c4e3f7de797447$var$uint8ArrayToBuffer(b).writeDoubleBE(src, offset);\n return 8;\n }\n}\nmodule.exports.DoubleBE = $09c4e3f7de797447$var$DoubleBE;\n/**\n * Represent a contiguous sequence of a specific layout as an Array.\n *\n * *Factory*: {@link module:Layout.seq|seq}\n *\n * @param {Layout} elementLayout - initializer for {@link\n * Sequence#elementLayout|elementLayout}.\n *\n * @param {(Number|ExternalLayout)} count - initializer for {@link\n * Sequence#count|count}. The parameter must be either a positive\n * integer or an instance of {@link ExternalLayout}.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$Sequence extends $09c4e3f7de797447$var$Layout {\n constructor(elementLayout, count, property){\n if (!(elementLayout instanceof $09c4e3f7de797447$var$Layout)) throw new TypeError('elementLayout must be a Layout');\n if (!(count instanceof $09c4e3f7de797447$var$ExternalLayout && count.isCount() || Number.isInteger(count) && 0 <= count)) throw new TypeError(\"count must be non-negative integer or an unsigned integer ExternalLayout\");\n let span = -1;\n if (!(count instanceof $09c4e3f7de797447$var$ExternalLayout) && 0 < elementLayout.span) span = count * elementLayout.span;\n super(span, property);\n /** The layout for individual elements of the sequence. */ this.elementLayout = elementLayout;\n /** The number of elements in the sequence.\n *\n * This will be either a non-negative integer or an instance of\n * {@link ExternalLayout} for which {@link\n * ExternalLayout#isCount|isCount()} is `true`. */ this.count = count;\n }\n /** @override */ getSpan(b, offset = 0) {\n if (0 <= this.span) return this.span;\n let span = 0;\n let count = this.count;\n if (count instanceof $09c4e3f7de797447$var$ExternalLayout) count = count.decode(b, offset);\n if (0 < this.elementLayout.span) span = count * this.elementLayout.span;\n else {\n let idx = 0;\n while(idx < count){\n span += this.elementLayout.getSpan(b, offset + span);\n ++idx;\n }\n }\n return span;\n }\n /** @override */ decode(b, offset = 0) {\n const rv = [];\n let i = 0;\n let count = this.count;\n if (count instanceof $09c4e3f7de797447$var$ExternalLayout) count = count.decode(b, offset);\n while(i < count){\n rv.push(this.elementLayout.decode(b, offset));\n offset += this.elementLayout.getSpan(b, offset);\n i += 1;\n }\n return rv;\n }\n /** Implement {@link Layout#encode|encode} for {@link Sequence}.\n *\n * **NOTE** If `src` is shorter than {@link Sequence#count|count} then\n * the unused space in the buffer is left unchanged. If `src` is\n * longer than {@link Sequence#count|count} the unneeded elements are\n * ignored.\n *\n * **NOTE** If {@link Layout#count|count} is an instance of {@link\n * ExternalLayout} then the length of `src` will be encoded as the\n * count after `src` is encoded. */ encode(src, b, offset = 0) {\n const elo = this.elementLayout;\n const span = src.reduce((span, v)=>{\n return span + elo.encode(v, b, offset + span);\n }, 0);\n if (this.count instanceof $09c4e3f7de797447$var$ExternalLayout) this.count.encode(src.length, b, offset);\n return span;\n }\n}\nmodule.exports.Sequence = $09c4e3f7de797447$var$Sequence;\n/**\n * Represent a contiguous sequence of arbitrary layout elements as an\n * Object.\n *\n * *Factory*: {@link module:Layout.struct|struct}\n *\n * **NOTE** The {@link Layout#span|span} of the structure is variable\n * if any layout in {@link Structure#fields|fields} has a variable\n * span. When {@link Layout#encode|encoding} we must have a value for\n * all variable-length fields, or we wouldn't be able to figure out\n * how much space to use for storage. We can only identify the value\n * for a field when it has a {@link Layout#property|property}. As\n * such, although a structure may contain both unnamed fields and\n * variable-length fields, it cannot contain an unnamed\n * variable-length field.\n *\n * @param {Layout[]} fields - initializer for {@link\n * Structure#fields|fields}. An error is raised if this contains a\n * variable-length field for which a {@link Layout#property|property}\n * is not defined.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @param {Boolean} [decodePrefixes] - initializer for {@link\n * Structure#decodePrefixes|property}.\n *\n * @throws {Error} - if `fields` contains an unnamed variable-length\n * layout.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$Structure extends $09c4e3f7de797447$var$Layout {\n constructor(fields, property, decodePrefixes){\n if (!(Array.isArray(fields) && fields.reduce((acc, v)=>acc && v instanceof $09c4e3f7de797447$var$Layout, true))) throw new TypeError('fields must be array of Layout instances');\n if ('boolean' === typeof property && undefined === decodePrefixes) {\n decodePrefixes = property;\n property = undefined;\n }\n /* Verify absence of unnamed variable-length fields. */ for (const fd of fields){\n if (0 > fd.span && undefined === fd.property) throw new Error('fields cannot contain unnamed variable-length layout');\n }\n let span = -1;\n try {\n span = fields.reduce((span, fd)=>span + fd.getSpan(), 0);\n } catch (e) {\n // ignore error\n }\n super(span, property);\n /** The sequence of {@link Layout} values that comprise the\n * structure.\n *\n * The individual elements need not be the same type, and may be\n * either scalar or aggregate layouts. If a member layout leaves\n * its {@link Layout#property|property} undefined the\n * corresponding region of the buffer associated with the element\n * will not be mutated.\n *\n * @type {Layout[]} */ this.fields = fields;\n /** Control behavior of {@link Layout#decode|decode()} given short\n * buffers.\n *\n * In some situations a structure many be extended with additional\n * fields over time, with older installations providing only a\n * prefix of the full structure. If this property is `true`\n * decoding will accept those buffers and leave subsequent fields\n * undefined, as long as the buffer ends at a field boundary.\n * Defaults to `false`. */ this.decodePrefixes = !!decodePrefixes;\n }\n /** @override */ getSpan(b, offset = 0) {\n if (0 <= this.span) return this.span;\n let span = 0;\n try {\n span = this.fields.reduce((span, fd)=>{\n const fsp = fd.getSpan(b, offset);\n offset += fsp;\n return span + fsp;\n }, 0);\n } catch (e) {\n throw new RangeError('indeterminate span');\n }\n return span;\n }\n /** @override */ decode(b, offset = 0) {\n $09c4e3f7de797447$var$checkUint8Array(b);\n const dest = this.makeDestinationObject();\n for (const fd of this.fields){\n if (undefined !== fd.property) dest[fd.property] = fd.decode(b, offset);\n offset += fd.getSpan(b, offset);\n if (this.decodePrefixes && b.length === offset) break;\n }\n return dest;\n }\n /** Implement {@link Layout#encode|encode} for {@link Structure}.\n *\n * If `src` is missing a property for a member with a defined {@link\n * Layout#property|property} the corresponding region of the buffer is\n * left unmodified. */ encode(src, b, offset = 0) {\n const firstOffset = offset;\n let lastOffset = 0;\n let lastWrote = 0;\n for (const fd of this.fields){\n let span = fd.span;\n lastWrote = 0 < span ? span : 0;\n if (undefined !== fd.property) {\n const fv = src[fd.property];\n if (undefined !== fv) {\n lastWrote = fd.encode(fv, b, offset);\n if (0 > span) /* Read the as-encoded span, which is not necessarily the\n * same as what we wrote. */ span = fd.getSpan(b, offset);\n }\n }\n lastOffset = offset;\n offset += span;\n }\n /* Use (lastOffset + lastWrote) instead of offset because the last\n * item may have had a dynamic length and we don't want to include\n * the padding between it and the end of the space reserved for\n * it. */ return lastOffset + lastWrote - firstOffset;\n }\n /** @override */ fromArray(values) {\n const dest = this.makeDestinationObject();\n for (const fd of this.fields)if (undefined !== fd.property && 0 < values.length) dest[fd.property] = values.shift();\n return dest;\n }\n /**\n * Get access to the layout of a given property.\n *\n * @param {String} property - the structure member of interest.\n *\n * @return {Layout} - the layout associated with `property`, or\n * undefined if there is no such property.\n */ layoutFor(property) {\n if ('string' !== typeof property) throw new TypeError('property must be string');\n for (const fd of this.fields){\n if (fd.property === property) return fd;\n }\n return undefined;\n }\n /**\n * Get the offset of a structure member.\n *\n * @param {String} property - the structure member of interest.\n *\n * @return {Number} - the offset in bytes to the start of `property`\n * within the structure, or undefined if `property` is not a field\n * within the structure. If the property is a member but follows a\n * variable-length structure member a negative number will be\n * returned.\n */ offsetOf(property) {\n if ('string' !== typeof property) throw new TypeError('property must be string');\n let offset = 0;\n for (const fd of this.fields){\n if (fd.property === property) return offset;\n if (0 > fd.span) offset = -1;\n else if (0 <= offset) offset += fd.span;\n }\n return undefined;\n }\n}\nmodule.exports.Structure = $09c4e3f7de797447$var$Structure;\n/**\n * An object that can provide a {@link\n * Union#discriminator|discriminator} API for {@link Union}.\n *\n * **NOTE** This is an abstract base class; you can create instances\n * if it amuses you, but they won't support the {@link\n * UnionDiscriminator#encode|encode} or {@link\n * UnionDiscriminator#decode|decode} functions.\n *\n * @param {string} [property] - Default for {@link\n * UnionDiscriminator#property|property}.\n *\n * @abstract\n */ class $09c4e3f7de797447$var$UnionDiscriminator {\n constructor(property){\n /** The {@link Layout#property|property} to be used when the\n * discriminator is referenced in isolation (generally when {@link\n * Union#decode|Union decode} cannot delegate to a specific\n * variant). */ this.property = property;\n }\n /** Analog to {@link Layout#decode|Layout decode} for union discriminators.\n *\n * The implementation of this method need not reference the buffer if\n * variant information is available through other means. */ decode(b, offset) {\n throw new Error('UnionDiscriminator is abstract');\n }\n /** Analog to {@link Layout#decode|Layout encode} for union discriminators.\n *\n * The implementation of this method need not store the value if\n * variant information is maintained through other means. */ encode(src, b, offset) {\n throw new Error('UnionDiscriminator is abstract');\n }\n}\nmodule.exports.UnionDiscriminator = $09c4e3f7de797447$var$UnionDiscriminator;\n/**\n * An object that can provide a {@link\n * UnionDiscriminator|discriminator API} for {@link Union} using an\n * unsigned integral {@link Layout} instance located either inside or\n * outside the union.\n *\n * @param {ExternalLayout} layout - initializes {@link\n * UnionLayoutDiscriminator#layout|layout}. Must satisfy {@link\n * ExternalLayout#isCount|isCount()}.\n *\n * @param {string} [property] - Default for {@link\n * UnionDiscriminator#property|property}, superseding the property\n * from `layout`, but defaulting to `variant` if neither `property`\n * nor layout provide a property name.\n *\n * @augments {UnionDiscriminator}\n */ class $09c4e3f7de797447$var$UnionLayoutDiscriminator extends $09c4e3f7de797447$var$UnionDiscriminator {\n constructor(layout, property){\n if (!(layout instanceof $09c4e3f7de797447$var$ExternalLayout && layout.isCount())) throw new TypeError('layout must be an unsigned integer ExternalLayout');\n super(property || layout.property || 'variant');\n /** The {@link ExternalLayout} used to access the discriminator\n * value. */ this.layout = layout;\n }\n /** Delegate decoding to {@link UnionLayoutDiscriminator#layout|layout}. */ decode(b, offset) {\n return this.layout.decode(b, offset);\n }\n /** Delegate encoding to {@link UnionLayoutDiscriminator#layout|layout}. */ encode(src, b, offset) {\n return this.layout.encode(src, b, offset);\n }\n}\nmodule.exports.UnionLayoutDiscriminator = $09c4e3f7de797447$var$UnionLayoutDiscriminator;\n/**\n * Represent any number of span-compatible layouts.\n *\n * *Factory*: {@link module:Layout.union|union}\n *\n * If the union has a {@link Union#defaultLayout|default layout} that\n * layout must have a non-negative {@link Layout#span|span}. The span\n * of a fixed-span union includes its {@link\n * Union#discriminator|discriminator} if the variant is a {@link\n * Union#usesPrefixDiscriminator|prefix of the union}, plus the span\n * of its {@link Union#defaultLayout|default layout}.\n *\n * If the union does not have a default layout then the encoded span\n * of the union depends on the encoded span of its variant (which may\n * be fixed or variable).\n *\n * {@link VariantLayout#layout|Variant layout}s are added through\n * {@link Union#addVariant|addVariant}. If the union has a default\n * layout, the span of the {@link VariantLayout#layout|layout\n * contained by the variant} must not exceed the span of the {@link\n * Union#defaultLayout|default layout} (minus the span of a {@link\n * Union#usesPrefixDiscriminator|prefix disriminator}, if used). The\n * span of the variant will equal the span of the union itself.\n *\n * The variant for a buffer can only be identified from the {@link\n * Union#discriminator|discriminator} {@link\n * UnionDiscriminator#property|property} (in the case of the {@link\n * Union#defaultLayout|default layout}), or by using {@link\n * Union#getVariant|getVariant} and examining the resulting {@link\n * VariantLayout} instance.\n *\n * A variant compatible with a JavaScript object can be identified\n * using {@link Union#getSourceVariant|getSourceVariant}.\n *\n * @param {(UnionDiscriminator|ExternalLayout|Layout)} discr - How to\n * identify the layout used to interpret the union contents. The\n * parameter must be an instance of {@link UnionDiscriminator}, an\n * {@link ExternalLayout} that satisfies {@link\n * ExternalLayout#isCount|isCount()}, or {@link UInt} (or {@link\n * UIntBE}). When a non-external layout element is passed the layout\n * appears at the start of the union. In all cases the (synthesized)\n * {@link UnionDiscriminator} instance is recorded as {@link\n * Union#discriminator|discriminator}.\n *\n * @param {(Layout|null)} defaultLayout - initializer for {@link\n * Union#defaultLayout|defaultLayout}. If absent defaults to `null`.\n * If `null` there is no default layout: the union has data-dependent\n * length and attempts to decode or encode unrecognized variants will\n * throw an exception. A {@link Layout} instance must have a\n * non-negative {@link Layout#span|span}, and if it lacks a {@link\n * Layout#property|property} the {@link\n * Union#defaultLayout|defaultLayout} will be a {@link\n * Layout#replicate|replica} with property `content`.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$Union extends $09c4e3f7de797447$var$Layout {\n constructor(discr, defaultLayout, property){\n let discriminator;\n if (discr instanceof $09c4e3f7de797447$var$UInt || discr instanceof $09c4e3f7de797447$var$UIntBE) discriminator = new $09c4e3f7de797447$var$UnionLayoutDiscriminator(new $09c4e3f7de797447$var$OffsetLayout(discr));\n else if (discr instanceof $09c4e3f7de797447$var$ExternalLayout && discr.isCount()) discriminator = new $09c4e3f7de797447$var$UnionLayoutDiscriminator(discr);\n else if (!(discr instanceof $09c4e3f7de797447$var$UnionDiscriminator)) throw new TypeError(\"discr must be a UnionDiscriminator or an unsigned integer layout\");\n else discriminator = discr;\n if (undefined === defaultLayout) defaultLayout = null;\n if (!(null === defaultLayout || defaultLayout instanceof $09c4e3f7de797447$var$Layout)) throw new TypeError('defaultLayout must be null or a Layout');\n if (null !== defaultLayout) {\n if (0 > defaultLayout.span) throw new Error('defaultLayout must have constant span');\n if (undefined === defaultLayout.property) defaultLayout = defaultLayout.replicate('content');\n }\n /* The union span can be estimated only if there's a default\n * layout. The union spans its default layout, plus any prefix\n * variant layout. By construction both layouts, if present, have\n * non-negative span. */ let span = -1;\n if (defaultLayout) {\n span = defaultLayout.span;\n if (0 <= span && (discr instanceof $09c4e3f7de797447$var$UInt || discr instanceof $09c4e3f7de797447$var$UIntBE)) span += discriminator.layout.span;\n }\n super(span, property);\n /** The interface for the discriminator value in isolation.\n *\n * This a {@link UnionDiscriminator} either passed to the\n * constructor or synthesized from the `discr` constructor\n * argument. {@link\n * Union#usesPrefixDiscriminator|usesPrefixDiscriminator} will be\n * `true` iff the `discr` parameter was a non-offset {@link\n * Layout} instance. */ this.discriminator = discriminator;\n /** `true` if the {@link Union#discriminator|discriminator} is the\n * first field in the union.\n *\n * If `false` the discriminator is obtained from somewhere\n * else. */ this.usesPrefixDiscriminator = discr instanceof $09c4e3f7de797447$var$UInt || discr instanceof $09c4e3f7de797447$var$UIntBE;\n /** The layout for non-discriminator content when the value of the\n * discriminator is not recognized.\n *\n * This is the value passed to the constructor. It is\n * structurally equivalent to the second component of {@link\n * Union#layout|layout} but may have a different property\n * name. */ this.defaultLayout = defaultLayout;\n /** A registry of allowed variants.\n *\n * The keys are unsigned integers which should be compatible with\n * {@link Union.discriminator|discriminator}. The property value\n * is the corresponding {@link VariantLayout} instances assigned\n * to this union by {@link Union#addVariant|addVariant}.\n *\n * **NOTE** The registry remains mutable so that variants can be\n * {@link Union#addVariant|added} at any time. Users should not\n * manipulate the content of this property. */ this.registry = {};\n /* Private variable used when invoking getSourceVariant */ let boundGetSourceVariant = this.defaultGetSourceVariant.bind(this);\n /** Function to infer the variant selected by a source object.\n *\n * Defaults to {@link\n * Union#defaultGetSourceVariant|defaultGetSourceVariant} but may\n * be overridden using {@link\n * Union#configGetSourceVariant|configGetSourceVariant}.\n *\n * @param {Object} src - as with {@link\n * Union#defaultGetSourceVariant|defaultGetSourceVariant}.\n *\n * @returns {(undefined|VariantLayout)} The default variant\n * (`undefined`) or first registered variant that uses a property\n * available in `src`. */ this.getSourceVariant = function(src) {\n return boundGetSourceVariant(src);\n };\n /** Function to override the implementation of {@link\n * Union#getSourceVariant|getSourceVariant}.\n *\n * Use this if the desired variant cannot be identified using the\n * algorithm of {@link\n * Union#defaultGetSourceVariant|defaultGetSourceVariant}.\n *\n * **NOTE** The provided function will be invoked bound to this\n * Union instance, providing local access to {@link\n * Union#registry|registry}.\n *\n * @param {Function} gsv - a function that follows the API of\n * {@link Union#defaultGetSourceVariant|defaultGetSourceVariant}. */ this.configGetSourceVariant = function(gsv) {\n boundGetSourceVariant = gsv.bind(this);\n };\n }\n /** @override */ getSpan(b, offset = 0) {\n if (0 <= this.span) return this.span;\n /* Default layouts always have non-negative span, so we don't have\n * one and we have to recognize the variant which will in turn\n * determine the span. */ const vlo = this.getVariant(b, offset);\n if (!vlo) throw new Error('unable to determine span for unrecognized variant');\n return vlo.getSpan(b, offset);\n }\n /**\n * Method to infer a registered Union variant compatible with `src`.\n *\n * The first satisfied rule in the following sequence defines the\n * return value:\n * * If `src` has properties matching the Union discriminator and\n * the default layout, `undefined` is returned regardless of the\n * value of the discriminator property (this ensures the default\n * layout will be used);\n * * If `src` has a property matching the Union discriminator, the\n * value of the discriminator identifies a registered variant, and\n * either (a) the variant has no layout, or (b) `src` has the\n * variant's property, then the variant is returned (because the\n * source satisfies the constraints of the variant it identifies);\n * * If `src` does not have a property matching the Union\n * discriminator, but does have a property matching a registered\n * variant, then the variant is returned (because the source\n * matches a variant without an explicit conflict);\n * * An error is thrown (because we either can't identify a variant,\n * or we were explicitly told the variant but can't satisfy it).\n *\n * @param {Object} src - an object presumed to be compatible with\n * the content of the Union.\n *\n * @return {(undefined|VariantLayout)} - as described above.\n *\n * @throws {Error} - if `src` cannot be associated with a default or\n * registered variant.\n */ defaultGetSourceVariant(src) {\n if (Object.prototype.hasOwnProperty.call(src, this.discriminator.property)) {\n if (this.defaultLayout && this.defaultLayout.property && Object.prototype.hasOwnProperty.call(src, this.defaultLayout.property)) return undefined;\n const vlo = this.registry[src[this.discriminator.property]];\n if (vlo && (!vlo.layout || vlo.property && Object.prototype.hasOwnProperty.call(src, vlo.property))) return vlo;\n } else for(const tag in this.registry){\n const vlo = this.registry[tag];\n if (vlo.property && Object.prototype.hasOwnProperty.call(src, vlo.property)) return vlo;\n }\n throw new Error('unable to infer src variant');\n }\n /** Implement {@link Layout#decode|decode} for {@link Union}.\n *\n * If the variant is {@link Union#addVariant|registered} the return\n * value is an instance of that variant, with no explicit\n * discriminator. Otherwise the {@link Union#defaultLayout|default\n * layout} is used to decode the content. */ decode(b, offset = 0) {\n let dest;\n const dlo = this.discriminator;\n const discr = dlo.decode(b, offset);\n const clo = this.registry[discr];\n if (undefined === clo) {\n const defaultLayout = this.defaultLayout;\n let contentOffset = 0;\n if (this.usesPrefixDiscriminator) contentOffset = dlo.layout.span;\n dest = this.makeDestinationObject();\n dest[dlo.property] = discr;\n // defaultLayout.property can be undefined, but this is allowed by buffer-layout\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n dest[defaultLayout.property] = defaultLayout.decode(b, offset + contentOffset);\n } else dest = clo.decode(b, offset);\n return dest;\n }\n /** Implement {@link Layout#encode|encode} for {@link Union}.\n *\n * This API assumes the `src` object is consistent with the union's\n * {@link Union#defaultLayout|default layout}. To encode variants\n * use the appropriate variant-specific {@link VariantLayout#encode}\n * method. */ encode(src, b, offset = 0) {\n const vlo = this.getSourceVariant(src);\n if (undefined === vlo) {\n const dlo = this.discriminator;\n // this.defaultLayout is not undefined when vlo is undefined\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const clo = this.defaultLayout;\n let contentOffset = 0;\n if (this.usesPrefixDiscriminator) contentOffset = dlo.layout.span;\n dlo.encode(src[dlo.property], b, offset);\n // clo.property is not undefined when vlo is undefined\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return contentOffset + clo.encode(src[clo.property], b, offset + contentOffset);\n }\n return vlo.encode(src, b, offset);\n }\n /** Register a new variant structure within a union. The newly\n * created variant is returned.\n *\n * @param {Number} variant - initializer for {@link\n * VariantLayout#variant|variant}.\n *\n * @param {Layout} layout - initializer for {@link\n * VariantLayout#layout|layout}.\n *\n * @param {String} property - initializer for {@link\n * Layout#property|property}.\n *\n * @return {VariantLayout} */ addVariant(variant, layout, property) {\n const rv = new $09c4e3f7de797447$var$VariantLayout(this, variant, layout, property);\n this.registry[variant] = rv;\n return rv;\n }\n /**\n * Get the layout associated with a registered variant.\n *\n * If `vb` does not produce a registered variant the function returns\n * `undefined`.\n *\n * @param {(Number|Uint8Array)} vb - either the variant number, or a\n * buffer from which the discriminator is to be read.\n *\n * @param {Number} offset - offset into `vb` for the start of the\n * union. Used only when `vb` is an instance of {Uint8Array}.\n *\n * @return {({VariantLayout}|undefined)}\n */ getVariant(vb, offset = 0) {\n let variant;\n if (vb instanceof Uint8Array) variant = this.discriminator.decode(vb, offset);\n else variant = vb;\n return this.registry[variant];\n }\n}\nmodule.exports.Union = $09c4e3f7de797447$var$Union;\n/**\n * Represent a specific variant within a containing union.\n *\n * **NOTE** The {@link Layout#span|span} of the variant may include\n * the span of the {@link Union#discriminator|discriminator} used to\n * identify it, but values read and written using the variant strictly\n * conform to the content of {@link VariantLayout#layout|layout}.\n *\n * **NOTE** User code should not invoke this constructor directly. Use\n * the union {@link Union#addVariant|addVariant} helper method.\n *\n * @param {Union} union - initializer for {@link\n * VariantLayout#union|union}.\n *\n * @param {Number} variant - initializer for {@link\n * VariantLayout#variant|variant}.\n *\n * @param {Layout} [layout] - initializer for {@link\n * VariantLayout#layout|layout}. If absent the variant carries no\n * data.\n *\n * @param {String} [property] - initializer for {@link\n * Layout#property|property}. Unlike many other layouts, variant\n * layouts normally include a property name so they can be identified\n * within their containing {@link Union}. The property identifier may\n * be absent only if `layout` is is absent.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$VariantLayout extends $09c4e3f7de797447$var$Layout {\n constructor(union, variant, layout, property){\n if (!(union instanceof $09c4e3f7de797447$var$Union)) throw new TypeError('union must be a Union');\n if (!Number.isInteger(variant) || 0 > variant) throw new TypeError('variant must be a (non-negative) integer');\n if ('string' === typeof layout && undefined === property) {\n property = layout;\n layout = null;\n }\n if (layout) {\n if (!(layout instanceof $09c4e3f7de797447$var$Layout)) throw new TypeError('layout must be a Layout');\n if (null !== union.defaultLayout && 0 <= layout.span && layout.span > union.defaultLayout.span) throw new Error('variant span exceeds span of containing union');\n if ('string' !== typeof property) throw new TypeError('variant must have a String property');\n }\n let span = union.span;\n if (0 > union.span) {\n span = layout ? layout.span : 0;\n if (0 <= span && union.usesPrefixDiscriminator) span += union.discriminator.layout.span;\n }\n super(span, property);\n /** The {@link Union} to which this variant belongs. */ this.union = union;\n /** The unsigned integral value identifying this variant within\n * the {@link Union#discriminator|discriminator} of the containing\n * union. */ this.variant = variant;\n /** The {@link Layout} to be used when reading/writing the\n * non-discriminator part of the {@link\n * VariantLayout#union|union}. If `null` the variant carries no\n * data. */ this.layout = layout || null;\n }\n /** @override */ getSpan(b, offset = 0) {\n if (0 <= this.span) /* Will be equal to the containing union span if that is not\n * variable. */ return this.span;\n let contentOffset = 0;\n if (this.union.usesPrefixDiscriminator) contentOffset = this.union.discriminator.layout.span;\n /* Span is defined solely by the variant (and prefix discriminator) */ let span = 0;\n if (this.layout) span = this.layout.getSpan(b, offset + contentOffset);\n return contentOffset + span;\n }\n /** @override */ decode(b, offset = 0) {\n const dest = this.makeDestinationObject();\n if (this !== this.union.getVariant(b, offset)) throw new Error('variant mismatch');\n let contentOffset = 0;\n if (this.union.usesPrefixDiscriminator) contentOffset = this.union.discriminator.layout.span;\n if (this.layout) dest[this.property] = this.layout.decode(b, offset + contentOffset);\n else if (this.property) dest[this.property] = true;\n else if (this.union.usesPrefixDiscriminator) dest[this.union.discriminator.property] = this.variant;\n return dest;\n }\n /** @override */ encode(src, b, offset = 0) {\n let contentOffset = 0;\n if (this.union.usesPrefixDiscriminator) contentOffset = this.union.discriminator.layout.span;\n if (this.layout && !Object.prototype.hasOwnProperty.call(src, this.property)) throw new TypeError('variant lacks property ' + this.property);\n this.union.discriminator.encode(this.variant, b, offset);\n let span = contentOffset;\n if (this.layout) {\n this.layout.encode(src[this.property], b, offset + contentOffset);\n span += this.layout.getSpan(b, offset + contentOffset);\n if (0 <= this.union.span && span > this.union.span) throw new Error('encoded variant overruns containing union');\n }\n return span;\n }\n /** Delegate {@link Layout#fromArray|fromArray} to {@link\n * VariantLayout#layout|layout}. */ fromArray(values) {\n if (this.layout) return this.layout.fromArray(values);\n return undefined;\n }\n}\nmodule.exports.VariantLayout = $09c4e3f7de797447$var$VariantLayout;\n/** JavaScript chose to define bitwise operations as operating on\n * signed 32-bit values in 2's complement form, meaning any integer\n * with bit 31 set is going to look negative. For right shifts that's\n * not a problem, because `>>>` is a logical shift, but for every\n * other bitwise operator we have to compensate for possible negative\n * results. */ function $09c4e3f7de797447$var$fixBitwiseResult(v) {\n if (0 > v) v += 0x100000000;\n return v;\n}\n/**\n * Contain a sequence of bit fields as an unsigned integer.\n *\n * *Factory*: {@link module:Layout.bits|bits}\n *\n * This is a container element; within it there are {@link BitField}\n * instances that provide the extracted properties. The container\n * simply defines the aggregate representation and its bit ordering.\n * The representation is an object containing properties with numeric\n * or {@link Boolean} values.\n *\n * {@link BitField}s are added with the {@link\n * BitStructure#addField|addField} and {@link\n * BitStructure#addBoolean|addBoolean} methods.\n\n * @param {Layout} word - initializer for {@link\n * BitStructure#word|word}. The parameter must be an instance of\n * {@link UInt} (or {@link UIntBE}) that is no more than 4 bytes wide.\n *\n * @param {bool} [msb] - `true` if the bit numbering starts at the\n * most significant bit of the containing word; `false` (default) if\n * it starts at the least significant bit of the containing word. If\n * the parameter at this position is a string and `property` is\n * `undefined` the value of this argument will instead be used as the\n * value of `property`.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$BitStructure extends $09c4e3f7de797447$var$Layout {\n constructor(word, msb, property){\n if (!(word instanceof $09c4e3f7de797447$var$UInt || word instanceof $09c4e3f7de797447$var$UIntBE)) throw new TypeError('word must be a UInt or UIntBE layout');\n if ('string' === typeof msb && undefined === property) {\n property = msb;\n msb = false;\n }\n if (4 < word.span) throw new RangeError('word cannot exceed 32 bits');\n super(word.span, property);\n /** The layout used for the packed value. {@link BitField}\n * instances are packed sequentially depending on {@link\n * BitStructure#msb|msb}. */ this.word = word;\n /** Whether the bit sequences are packed starting at the most\n * significant bit growing down (`true`), or the least significant\n * bit growing up (`false`).\n *\n * **NOTE** Regardless of this value, the least significant bit of\n * any {@link BitField} value is the least significant bit of the\n * corresponding section of the packed value. */ this.msb = !!msb;\n /** The sequence of {@link BitField} layouts that comprise the\n * packed structure.\n *\n * **NOTE** The array remains mutable to allow fields to be {@link\n * BitStructure#addField|added} after construction. Users should\n * not manipulate the content of this property.*/ this.fields = [];\n /* Storage for the value. Capture a variable instead of using an\n * instance property because we don't want anything to change the\n * value without going through the mutator. */ let value = 0;\n this._packedSetValue = function(v) {\n value = $09c4e3f7de797447$var$fixBitwiseResult(v);\n return this;\n };\n this._packedGetValue = function() {\n return value;\n };\n }\n /** @override */ decode(b, offset = 0) {\n const dest = this.makeDestinationObject();\n const value = this.word.decode(b, offset);\n this._packedSetValue(value);\n for (const fd of this.fields)if (undefined !== fd.property) dest[fd.property] = fd.decode(b);\n return dest;\n }\n /** Implement {@link Layout#encode|encode} for {@link BitStructure}.\n *\n * If `src` is missing a property for a member with a defined {@link\n * Layout#property|property} the corresponding region of the packed\n * value is left unmodified. Unused bits are also left unmodified. */ encode(src, b, offset = 0) {\n const value = this.word.decode(b, offset);\n this._packedSetValue(value);\n for (const fd of this.fields)if (undefined !== fd.property) {\n const fv = src[fd.property];\n if (undefined !== fv) fd.encode(fv);\n }\n return this.word.encode(this._packedGetValue(), b, offset);\n }\n /** Register a new bitfield with a containing bit structure. The\n * resulting bitfield is returned.\n *\n * @param {Number} bits - initializer for {@link BitField#bits|bits}.\n *\n * @param {string} property - initializer for {@link\n * Layout#property|property}.\n *\n * @return {BitField} */ addField(bits, property) {\n const bf = new $09c4e3f7de797447$var$BitField(this, bits, property);\n this.fields.push(bf);\n return bf;\n }\n /** As with {@link BitStructure#addField|addField} for single-bit\n * fields with `boolean` value representation.\n *\n * @param {string} property - initializer for {@link\n * Layout#property|property}.\n *\n * @return {Boolean} */ // `Boolean` conflicts with the native primitive type\n // eslint-disable-next-line @typescript-eslint/ban-types\n addBoolean(property) {\n // This is my Boolean, not the Javascript one.\n const bf = new $09c4e3f7de797447$var$Boolean(this, property);\n this.fields.push(bf);\n return bf;\n }\n /**\n * Get access to the bit field for a given property.\n *\n * @param {String} property - the bit field of interest.\n *\n * @return {BitField} - the field associated with `property`, or\n * undefined if there is no such property.\n */ fieldFor(property) {\n if ('string' !== typeof property) throw new TypeError('property must be string');\n for (const fd of this.fields){\n if (fd.property === property) return fd;\n }\n return undefined;\n }\n}\nmodule.exports.BitStructure = $09c4e3f7de797447$var$BitStructure;\n/**\n * Represent a sequence of bits within a {@link BitStructure}.\n *\n * All bit field values are represented as unsigned integers.\n *\n * **NOTE** User code should not invoke this constructor directly.\n * Use the container {@link BitStructure#addField|addField} helper\n * method.\n *\n * **NOTE** BitField instances are not instances of {@link Layout}\n * since {@link Layout#span|span} measures 8-bit units.\n *\n * @param {BitStructure} container - initializer for {@link\n * BitField#container|container}.\n *\n * @param {Number} bits - initializer for {@link BitField#bits|bits}.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n */ class $09c4e3f7de797447$var$BitField {\n constructor(container, bits, property){\n if (!(container instanceof $09c4e3f7de797447$var$BitStructure)) throw new TypeError('container must be a BitStructure');\n if (!Number.isInteger(bits) || 0 >= bits) throw new TypeError('bits must be positive integer');\n const totalBits = 8 * container.span;\n const usedBits = container.fields.reduce((sum, fd)=>sum + fd.bits, 0);\n if (bits + usedBits > totalBits) throw new Error('bits too long for span remainder (' + (totalBits - usedBits) + ' of ' + totalBits + ' remain)');\n /** The {@link BitStructure} instance to which this bit field\n * belongs. */ this.container = container;\n /** The span of this value in bits. */ this.bits = bits;\n /** A mask of {@link BitField#bits|bits} bits isolating value bits\n * that fit within the field.\n *\n * That is, it masks a value that has not yet been shifted into\n * position within its containing packed integer. */ this.valueMask = (1 << bits) - 1;\n if (32 === bits) this.valueMask = 0xFFFFFFFF;\n /** The offset of the value within the containing packed unsigned\n * integer. The least significant bit of the packed value is at\n * offset zero, regardless of bit ordering used. */ this.start = usedBits;\n if (this.container.msb) this.start = totalBits - usedBits - bits;\n /** A mask of {@link BitField#bits|bits} isolating the field value\n * within the containing packed unsigned integer. */ this.wordMask = $09c4e3f7de797447$var$fixBitwiseResult(this.valueMask << this.start);\n /** The property name used when this bitfield is represented in an\n * Object.\n *\n * Intended to be functionally equivalent to {@link\n * Layout#property}.\n *\n * If left undefined the corresponding span of bits will be\n * treated as padding: it will not be mutated by {@link\n * Layout#encode|encode} nor represented as a property in the\n * decoded Object. */ this.property = property;\n }\n /** Store a value into the corresponding subsequence of the containing\n * bit field. */ decode(b, offset) {\n const word = this.container._packedGetValue();\n const wordValue = $09c4e3f7de797447$var$fixBitwiseResult(word & this.wordMask);\n const value = wordValue >>> this.start;\n return value;\n }\n /** Store a value into the corresponding subsequence of the containing\n * bit field.\n *\n * **NOTE** This is not a specialization of {@link\n * Layout#encode|Layout.encode} and there is no return value. */ encode(value) {\n if ('number' !== typeof value || !Number.isInteger(value) || value !== $09c4e3f7de797447$var$fixBitwiseResult(value & this.valueMask)) throw new TypeError($09c4e3f7de797447$var$nameWithProperty('BitField.encode', this) + ' value must be integer not exceeding ' + this.valueMask);\n const word = this.container._packedGetValue();\n const wordValue = $09c4e3f7de797447$var$fixBitwiseResult(value << this.start);\n this.container._packedSetValue($09c4e3f7de797447$var$fixBitwiseResult(word & ~this.wordMask) | wordValue);\n }\n}\nmodule.exports.BitField = $09c4e3f7de797447$var$BitField;\n/**\n * Represent a single bit within a {@link BitStructure} as a\n * JavaScript boolean.\n *\n * **NOTE** User code should not invoke this constructor directly.\n * Use the container {@link BitStructure#addBoolean|addBoolean} helper\n * method.\n *\n * @param {BitStructure} container - initializer for {@link\n * BitField#container|container}.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {BitField}\n */ /* eslint-disable no-extend-native */ class $09c4e3f7de797447$var$Boolean extends $09c4e3f7de797447$var$BitField {\n constructor(container, property){\n super(container, 1, property);\n }\n /** Override {@link BitField#decode|decode} for {@link Boolean|Boolean}.\n *\n * @returns {boolean} */ decode(b, offset) {\n return !!super.decode(b, offset);\n }\n /** @override */ encode(value) {\n if ('boolean' === typeof value) // BitField requires integer values\n value = +value;\n super.encode(value);\n }\n}\nmodule.exports.Boolean = $09c4e3f7de797447$var$Boolean;\n/* eslint-enable no-extend-native */ /**\n * Contain a fixed-length block of arbitrary data, represented as a\n * Uint8Array.\n *\n * *Factory*: {@link module:Layout.blob|blob}\n *\n * @param {(Number|ExternalLayout)} length - initializes {@link\n * Blob#length|length}.\n *\n * @param {String} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$Blob extends $09c4e3f7de797447$var$Layout {\n constructor(length, property){\n if (!(length instanceof $09c4e3f7de797447$var$ExternalLayout && length.isCount() || Number.isInteger(length) && 0 <= length)) throw new TypeError(\"length must be positive integer or an unsigned integer ExternalLayout\");\n let span = -1;\n if (!(length instanceof $09c4e3f7de797447$var$ExternalLayout)) span = length;\n super(span, property);\n /** The number of bytes in the blob.\n *\n * This may be a non-negative integer, or an instance of {@link\n * ExternalLayout} that satisfies {@link\n * ExternalLayout#isCount|isCount()}. */ this.length = length;\n }\n /** @override */ getSpan(b, offset) {\n let span = this.span;\n if (0 > span) span = this.length.decode(b, offset);\n return span;\n }\n /** @override */ decode(b, offset = 0) {\n let span = this.span;\n if (0 > span) span = this.length.decode(b, offset);\n return $09c4e3f7de797447$var$uint8ArrayToBuffer(b).slice(offset, offset + span);\n }\n /** Implement {@link Layout#encode|encode} for {@link Blob}.\n *\n * **NOTE** If {@link Layout#count|count} is an instance of {@link\n * ExternalLayout} then the length of `src` will be encoded as the\n * count after `src` is encoded. */ encode(src, b, offset) {\n let span = this.length;\n if (this.length instanceof $09c4e3f7de797447$var$ExternalLayout) span = src.length;\n if (!(src instanceof Uint8Array && span === src.length)) throw new TypeError($09c4e3f7de797447$var$nameWithProperty('Blob.encode', this) + ' requires (length ' + span + ') Uint8Array as src');\n if (offset + span > b.length) throw new RangeError('encoding overruns Uint8Array');\n const srcBuffer = $09c4e3f7de797447$var$uint8ArrayToBuffer(src);\n $09c4e3f7de797447$var$uint8ArrayToBuffer(b).write(srcBuffer.toString('hex'), offset, span, 'hex');\n if (this.length instanceof $09c4e3f7de797447$var$ExternalLayout) this.length.encode(span, b, offset);\n return span;\n }\n}\nmodule.exports.Blob = $09c4e3f7de797447$var$Blob;\n/**\n * Contain a `NUL`-terminated UTF8 string.\n *\n * *Factory*: {@link module:Layout.cstr|cstr}\n *\n * **NOTE** Any UTF8 string that incorporates a zero-valued byte will\n * not be correctly decoded by this layout.\n *\n * @param {String} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$CString extends $09c4e3f7de797447$var$Layout {\n constructor(property){\n super(-1, property);\n }\n /** @override */ getSpan(b, offset = 0) {\n $09c4e3f7de797447$var$checkUint8Array(b);\n let idx = offset;\n while(idx < b.length && 0 !== b[idx])idx += 1;\n return 1 + idx - offset;\n }\n /** @override */ decode(b, offset = 0) {\n const span = this.getSpan(b, offset);\n return $09c4e3f7de797447$var$uint8ArrayToBuffer(b).slice(offset, offset + span - 1).toString('utf-8');\n }\n /** @override */ encode(src, b, offset = 0) {\n /* Must force this to a string, lest it be a number and the\n * \"utf8-encoding\" below actually allocate a buffer of length\n * src */ if ('string' !== typeof src) src = String(src);\n const srcb = $6ZWSX.Buffer.from(src, 'utf8');\n const span = srcb.length;\n if (offset + span > b.length) throw new RangeError('encoding overruns Buffer');\n const buffer = $09c4e3f7de797447$var$uint8ArrayToBuffer(b);\n srcb.copy(buffer, offset);\n buffer[offset + span] = 0;\n return span + 1;\n }\n}\nmodule.exports.CString = $09c4e3f7de797447$var$CString;\n/**\n * Contain a UTF8 string with implicit length.\n *\n * *Factory*: {@link module:Layout.utf8|utf8}\n *\n * **NOTE** Because the length is implicit in the size of the buffer\n * this layout should be used only in isolation, or in a situation\n * where the length can be expressed by operating on a slice of the\n * containing buffer.\n *\n * @param {Number} [maxSpan] - the maximum length allowed for encoded\n * string content. If not provided there is no bound on the allowed\n * content.\n *\n * @param {String} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$UTF8 extends $09c4e3f7de797447$var$Layout {\n constructor(maxSpan, property){\n if ('string' === typeof maxSpan && undefined === property) {\n property = maxSpan;\n maxSpan = undefined;\n }\n if (undefined === maxSpan) maxSpan = -1;\n else if (!Number.isInteger(maxSpan)) throw new TypeError('maxSpan must be an integer');\n super(-1, property);\n /** The maximum span of the layout in bytes.\n *\n * Positive values are generally expected. Zero is abnormal.\n * Attempts to encode or decode a value that exceeds this length\n * will throw a `RangeError`.\n *\n * A negative value indicates that there is no bound on the length\n * of the content. */ this.maxSpan = maxSpan;\n }\n /** @override */ getSpan(b, offset = 0) {\n $09c4e3f7de797447$var$checkUint8Array(b);\n return b.length - offset;\n }\n /** @override */ decode(b, offset = 0) {\n const span = this.getSpan(b, offset);\n if (0 <= this.maxSpan && this.maxSpan < span) throw new RangeError('text length exceeds maxSpan');\n return $09c4e3f7de797447$var$uint8ArrayToBuffer(b).slice(offset, offset + span).toString('utf-8');\n }\n /** @override */ encode(src, b, offset = 0) {\n /* Must force this to a string, lest it be a number and the\n * \"utf8-encoding\" below actually allocate a buffer of length\n * src */ if ('string' !== typeof src) src = String(src);\n const srcb = $6ZWSX.Buffer.from(src, 'utf8');\n const span = srcb.length;\n if (0 <= this.maxSpan && this.maxSpan < span) throw new RangeError('text length exceeds maxSpan');\n if (offset + span > b.length) throw new RangeError('encoding overruns Buffer');\n srcb.copy($09c4e3f7de797447$var$uint8ArrayToBuffer(b), offset);\n return span;\n }\n}\nmodule.exports.UTF8 = $09c4e3f7de797447$var$UTF8;\n/**\n * Contain a constant value.\n *\n * This layout may be used in cases where a JavaScript value can be\n * inferred without an expression in the binary encoding. An example\n * would be a {@link VariantLayout|variant layout} where the content\n * is implied by the union {@link Union#discriminator|discriminator}.\n *\n * @param {Object|Number|String} value - initializer for {@link\n * Constant#value|value}. If the value is an object (or array) and\n * the application intends the object to remain unchanged regardless\n * of what is done to values decoded by this layout, the value should\n * be frozen prior passing it to this constructor.\n *\n * @param {String} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */ class $09c4e3f7de797447$var$Constant extends $09c4e3f7de797447$var$Layout {\n constructor(value, property){\n super(0, property);\n /** The value produced by this constant when the layout is {@link\n * Constant#decode|decoded}.\n *\n * Any JavaScript value including `null` and `undefined` is\n * permitted.\n *\n * **WARNING** If `value` passed in the constructor was not\n * frozen, it is possible for users of decoded values to change\n * the content of the value. */ this.value = value;\n }\n /** @override */ decode(b, offset) {\n return this.value;\n }\n /** @override */ encode(src, b, offset) {\n /* Constants take no space */ return 0;\n }\n}\nmodule.exports.Constant = $09c4e3f7de797447$var$Constant;\n/** Factory for {@link GreedyCount}. */ module.exports.greedy = (elementSpan, property)=>new $09c4e3f7de797447$var$GreedyCount(elementSpan, property);\n/** Factory for {@link OffsetLayout}. */ module.exports.offset = (layout, offset, property)=>new $09c4e3f7de797447$var$OffsetLayout(layout, offset, property);\n/** Factory for {@link UInt|unsigned int layouts} spanning one\n * byte. */ module.exports.u8 = (property)=>new $09c4e3f7de797447$var$UInt(1, property);\n/** Factory for {@link UInt|little-endian unsigned int layouts}\n * spanning two bytes. */ module.exports.u16 = (property)=>new $09c4e3f7de797447$var$UInt(2, property);\n/** Factory for {@link UInt|little-endian unsigned int layouts}\n * spanning three bytes. */ module.exports.u24 = (property)=>new $09c4e3f7de797447$var$UInt(3, property);\n/** Factory for {@link UInt|little-endian unsigned int layouts}\n * spanning four bytes. */ module.exports.u32 = (property)=>new $09c4e3f7de797447$var$UInt(4, property);\n/** Factory for {@link UInt|little-endian unsigned int layouts}\n * spanning five bytes. */ module.exports.u40 = (property)=>new $09c4e3f7de797447$var$UInt(5, property);\n/** Factory for {@link UInt|little-endian unsigned int layouts}\n * spanning six bytes. */ module.exports.u48 = (property)=>new $09c4e3f7de797447$var$UInt(6, property);\n/** Factory for {@link NearUInt64|little-endian unsigned int\n * layouts} interpreted as Numbers. */ module.exports.nu64 = (property)=>new $09c4e3f7de797447$var$NearUInt64(property);\n/** Factory for {@link UInt|big-endian unsigned int layouts}\n * spanning two bytes. */ module.exports.u16be = (property)=>new $09c4e3f7de797447$var$UIntBE(2, property);\n/** Factory for {@link UInt|big-endian unsigned int layouts}\n * spanning three bytes. */ module.exports.u24be = (property)=>new $09c4e3f7de797447$var$UIntBE(3, property);\n/** Factory for {@link UInt|big-endian unsigned int layouts}\n * spanning four bytes. */ module.exports.u32be = (property)=>new $09c4e3f7de797447$var$UIntBE(4, property);\n/** Factory for {@link UInt|big-endian unsigned int layouts}\n * spanning five bytes. */ module.exports.u40be = (property)=>new $09c4e3f7de797447$var$UIntBE(5, property);\n/** Factory for {@link UInt|big-endian unsigned int layouts}\n * spanning six bytes. */ module.exports.u48be = (property)=>new $09c4e3f7de797447$var$UIntBE(6, property);\n/** Factory for {@link NearUInt64BE|big-endian unsigned int\n * layouts} interpreted as Numbers. */ module.exports.nu64be = (property)=>new $09c4e3f7de797447$var$NearUInt64BE(property);\n/** Factory for {@link Int|signed int layouts} spanning one\n * byte. */ module.exports.s8 = (property)=>new $09c4e3f7de797447$var$Int(1, property);\n/** Factory for {@link Int|little-endian signed int layouts}\n * spanning two bytes. */ module.exports.s16 = (property)=>new $09c4e3f7de797447$var$Int(2, property);\n/** Factory for {@link Int|little-endian signed int layouts}\n * spanning three bytes. */ module.exports.s24 = (property)=>new $09c4e3f7de797447$var$Int(3, property);\n/** Factory for {@link Int|little-endian signed int layouts}\n * spanning four bytes. */ module.exports.s32 = (property)=>new $09c4e3f7de797447$var$Int(4, property);\n/** Factory for {@link Int|little-endian signed int layouts}\n * spanning five bytes. */ module.exports.s40 = (property)=>new $09c4e3f7de797447$var$Int(5, property);\n/** Factory for {@link Int|little-endian signed int layouts}\n * spanning six bytes. */ module.exports.s48 = (property)=>new $09c4e3f7de797447$var$Int(6, property);\n/** Factory for {@link NearInt64|little-endian signed int layouts}\n * interpreted as Numbers. */ module.exports.ns64 = (property)=>new $09c4e3f7de797447$var$NearInt64(property);\n/** Factory for {@link Int|big-endian signed int layouts}\n * spanning two bytes. */ module.exports.s16be = (property)=>new $09c4e3f7de797447$var$IntBE(2, property);\n/** Factory for {@link Int|big-endian signed int layouts}\n * spanning three bytes. */ module.exports.s24be = (property)=>new $09c4e3f7de797447$var$IntBE(3, property);\n/** Factory for {@link Int|big-endian signed int layouts}\n * spanning four bytes. */ module.exports.s32be = (property)=>new $09c4e3f7de797447$var$IntBE(4, property);\n/** Factory for {@link Int|big-endian signed int layouts}\n * spanning five bytes. */ module.exports.s40be = (property)=>new $09c4e3f7de797447$var$IntBE(5, property);\n/** Factory for {@link Int|big-endian signed int layouts}\n * spanning six bytes. */ module.exports.s48be = (property)=>new $09c4e3f7de797447$var$IntBE(6, property);\n/** Factory for {@link NearInt64BE|big-endian signed int layouts}\n * interpreted as Numbers. */ module.exports.ns64be = (property)=>new $09c4e3f7de797447$var$NearInt64BE(property);\n/** Factory for {@link Float|little-endian 32-bit floating point} values. */ module.exports.f32 = (property)=>new $09c4e3f7de797447$var$Float(property);\n/** Factory for {@link FloatBE|big-endian 32-bit floating point} values. */ module.exports.f32be = (property)=>new $09c4e3f7de797447$var$FloatBE(property);\n/** Factory for {@link Double|little-endian 64-bit floating point} values. */ module.exports.f64 = (property)=>new $09c4e3f7de797447$var$Double(property);\n/** Factory for {@link DoubleBE|big-endian 64-bit floating point} values. */ module.exports.f64be = (property)=>new $09c4e3f7de797447$var$DoubleBE(property);\n/** Factory for {@link Structure} values. */ module.exports.struct = (fields, property, decodePrefixes)=>new $09c4e3f7de797447$var$Structure(fields, property, decodePrefixes);\n/** Factory for {@link BitStructure} values. */ module.exports.bits = (word, msb, property)=>new $09c4e3f7de797447$var$BitStructure(word, msb, property);\n/** Factory for {@link Sequence} values. */ module.exports.seq = (elementLayout, count, property)=>new $09c4e3f7de797447$var$Sequence(elementLayout, count, property);\n/** Factory for {@link Union} values. */ module.exports.union = (discr, defaultLayout, property)=>new $09c4e3f7de797447$var$Union(discr, defaultLayout, property);\n/** Factory for {@link UnionLayoutDiscriminator} values. */ module.exports.unionLayoutDiscriminator = (layout, property)=>new $09c4e3f7de797447$var$UnionLayoutDiscriminator(layout, property);\n/** Factory for {@link Blob} values. */ module.exports.blob = (length, property)=>new $09c4e3f7de797447$var$Blob(length, property);\n/** Factory for {@link CString} values. */ module.exports.cstr = (property)=>new $09c4e3f7de797447$var$CString(property);\n/** Factory for {@link UTF8} values. */ module.exports.utf8 = (maxSpan, property)=>new $09c4e3f7de797447$var$UTF8(maxSpan, property);\n/** Factory for {@link Constant} values. */ module.exports.constant = (value, property)=>new $09c4e3f7de797447$var$Constant(value, property);\n\n});\n\nparcelRegister(\"gyRuj\", function(module, exports) {\n\nvar $6ZWSX = parcelRequire(\"6ZWSX\");\nvar $c0e94fe1a84d811b$require$Buffer = $6ZWSX.Buffer;\n'use strict';\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nlet $c0e94fe1a84d811b$var$converter;\n/**\n * Convert a little-endian buffer into a BigInt.\n * @param buf The little-endian buffer to convert\n * @returns A BigInt with the little-endian representation of buf.\n */ function $c0e94fe1a84d811b$var$toBigIntLE(buf) {\n {\n const reversed = $c0e94fe1a84d811b$require$Buffer.from(buf);\n reversed.reverse();\n const hex = reversed.toString('hex');\n if (hex.length === 0) return BigInt(0);\n return BigInt(`0x${hex}`);\n }\n return $c0e94fe1a84d811b$var$converter.toBigInt(buf, false);\n}\nmodule.exports.toBigIntLE = $c0e94fe1a84d811b$var$toBigIntLE;\n/**\n * Convert a big-endian buffer into a BigInt\n * @param buf The big-endian buffer to convert.\n * @returns A BigInt with the big-endian representation of buf.\n */ function $c0e94fe1a84d811b$var$toBigIntBE(buf) {\n {\n const hex = buf.toString('hex');\n if (hex.length === 0) return BigInt(0);\n return BigInt(`0x${hex}`);\n }\n return $c0e94fe1a84d811b$var$converter.toBigInt(buf, true);\n}\nmodule.exports.toBigIntBE = $c0e94fe1a84d811b$var$toBigIntBE;\n/**\n * Convert a BigInt to a little-endian buffer.\n * @param num The BigInt to convert.\n * @param width The number of bytes that the resulting buffer should be.\n * @returns A little-endian buffer representation of num.\n */ function $c0e94fe1a84d811b$var$toBufferLE(num, width) {\n {\n const hex = num.toString(16);\n const buffer = $c0e94fe1a84d811b$require$Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');\n buffer.reverse();\n return buffer;\n }\n // Allocation is done here, since it is slower using napi in C\n return $c0e94fe1a84d811b$var$converter.fromBigInt(num, $c0e94fe1a84d811b$require$Buffer.allocUnsafe(width), false);\n}\nmodule.exports.toBufferLE = $c0e94fe1a84d811b$var$toBufferLE;\n/**\n * Convert a BigInt to a big-endian buffer.\n * @param num The BigInt to convert.\n * @param width The number of bytes that the resulting buffer should be.\n * @returns A big-endian buffer representation of num.\n */ function $c0e94fe1a84d811b$var$toBufferBE(num, width) {\n {\n const hex = num.toString(16);\n return $c0e94fe1a84d811b$require$Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');\n }\n return $c0e94fe1a84d811b$var$converter.fromBigInt(num, $c0e94fe1a84d811b$require$Buffer.allocUnsafe(width), true);\n}\nmodule.exports.toBufferBE = $c0e94fe1a84d811b$var$toBufferBE;\n\n});\n\nparcelRegister(\"5DqgT\", function(module, exports) {\n\n$parcel$export(module.exports, \"assert\", () => $d36cd0d29f3bcaa8$export$a7a9523472993e97);\n$parcel$export(module.exports, \"create\", () => $d36cd0d29f3bcaa8$export$185802fd694ee1f5);\n$parcel$export(module.exports, \"type\", () => $d36cd0d29f3bcaa8$export$bf9fb029d174d554);\n$parcel$export(module.exports, \"optional\", () => $d36cd0d29f3bcaa8$export$516e28dec6a4b6d4);\n$parcel$export(module.exports, \"any\", () => $d36cd0d29f3bcaa8$export$4154a199d7d90455);\n$parcel$export(module.exports, \"array\", () => $d36cd0d29f3bcaa8$export$2f23118c22fb2630);\n$parcel$export(module.exports, \"boolean\", () => $d36cd0d29f3bcaa8$export$4a21f16c33752377);\n$parcel$export(module.exports, \"instance\", () => $d36cd0d29f3bcaa8$export$9544d5bb712b01ea);\n$parcel$export(module.exports, \"literal\", () => $d36cd0d29f3bcaa8$export$c8ec6e1ec9fefcb0);\n$parcel$export(module.exports, \"nullable\", () => $d36cd0d29f3bcaa8$export$133fc36489ac9add);\n$parcel$export(module.exports, \"number\", () => $d36cd0d29f3bcaa8$export$98e628dec113755e);\n$parcel$export(module.exports, \"record\", () => $d36cd0d29f3bcaa8$export$e5185e241753e543);\n$parcel$export(module.exports, \"string\", () => $d36cd0d29f3bcaa8$export$22b082955e083ec3);\n$parcel$export(module.exports, \"tuple\", () => $d36cd0d29f3bcaa8$export$65e3907585753458);\n$parcel$export(module.exports, \"union\", () => $d36cd0d29f3bcaa8$export$971dd5b0dfd021b6);\n$parcel$export(module.exports, \"unknown\", () => $d36cd0d29f3bcaa8$export$19282c40b967aec6);\n$parcel$export(module.exports, \"coerce\", () => $d36cd0d29f3bcaa8$export$8c14e57e778d3873);\n/**\n * A `StructFailure` represents a single specific failure in validation.\n */ /**\n * `StructError` objects are thrown (or returned) when validation fails.\n *\n * Validation logic is design to exit early for maximum performance. The error\n * represents the first error encountered during validation. For more detail,\n * the `error.failures` property is a generator function that can be run to\n * continue validation and receive all the failures in the data.\n */ class $d36cd0d29f3bcaa8$export$58cc9131e3e8861b extends TypeError {\n constructor(failure, failures){\n let cached;\n const { message: message, explanation: explanation, ...rest } = failure;\n const { path: path } = failure;\n const msg = path.length === 0 ? message : `At path: ${path.join('.')} -- ${message}`;\n super(explanation ?? msg);\n if (explanation != null) this.cause = msg;\n Object.assign(this, rest);\n this.name = this.constructor.name;\n this.failures = ()=>{\n return cached ?? (cached = [\n failure,\n ...failures()\n ]);\n };\n }\n}\n/**\n * Check if a value is an iterator.\n */ function $d36cd0d29f3bcaa8$var$isIterable(x) {\n return $d36cd0d29f3bcaa8$var$isObject(x) && typeof x[Symbol.iterator] === 'function';\n}\n/**\n * Check if a value is a plain object.\n */ function $d36cd0d29f3bcaa8$var$isObject(x) {\n return typeof x === 'object' && x != null;\n}\n/**\n * Check if a value is a non-array object.\n */ function $d36cd0d29f3bcaa8$var$isNonArrayObject(x) {\n return $d36cd0d29f3bcaa8$var$isObject(x) && !Array.isArray(x);\n}\n/**\n * Check if a value is a plain object.\n */ function $d36cd0d29f3bcaa8$var$isPlainObject(x) {\n if (Object.prototype.toString.call(x) !== '[object Object]') return false;\n const prototype = Object.getPrototypeOf(x);\n return prototype === null || prototype === Object.prototype;\n}\n/**\n * Return a value as a printable string.\n */ function $d36cd0d29f3bcaa8$var$print(value) {\n if (typeof value === 'symbol') return value.toString();\n return typeof value === 'string' ? JSON.stringify(value) : `${value}`;\n}\n/**\n * Shifts (removes and returns) the first value from the `input` iterator.\n * Like `Array.prototype.shift()` but for an `Iterator`.\n */ function $d36cd0d29f3bcaa8$var$shiftIterator(input) {\n const { done: done, value: value } = input.next();\n return done ? undefined : value;\n}\n/**\n * Convert a single validation result to a failure.\n */ function $d36cd0d29f3bcaa8$var$toFailure(result, context, struct, value) {\n if (result === true) return;\n else if (result === false) result = {};\n else if (typeof result === 'string') result = {\n message: result\n };\n const { path: path, branch: branch } = context;\n const { type: type } = struct;\n const { refinement: refinement, message: message = `Expected a value of type \\`${type}\\`${refinement ? ` with refinement \\`${refinement}\\`` : ''}, but received: \\`${$d36cd0d29f3bcaa8$var$print(value)}\\`` } = result;\n return {\n value: value,\n type: type,\n refinement: refinement,\n key: path[path.length - 1],\n path: path,\n branch: branch,\n ...result,\n message: message\n };\n}\n/**\n * Convert a validation result to an iterable of failures.\n */ function* $d36cd0d29f3bcaa8$var$toFailures(result, context, struct, value) {\n if (!$d36cd0d29f3bcaa8$var$isIterable(result)) result = [\n result\n ];\n for (const r of result){\n const failure = $d36cd0d29f3bcaa8$var$toFailure(r, context, struct, value);\n if (failure) yield failure;\n }\n}\n/**\n * Check a value against a struct, traversing deeply into nested values, and\n * returning an iterator of failures or success.\n */ function* $d36cd0d29f3bcaa8$var$run(value, struct, options = {}) {\n const { path: path = [], branch: branch = [\n value\n ], coerce: coerce = false, mask: mask = false } = options;\n const ctx = {\n path: path,\n branch: branch,\n mask: mask\n };\n if (coerce) value = struct.coercer(value, ctx);\n let status = 'valid';\n for (const failure of struct.validator(value, ctx)){\n failure.explanation = options.message;\n status = 'not_valid';\n yield [\n failure,\n undefined\n ];\n }\n for (let [k, v, s] of struct.entries(value, ctx)){\n const ts = $d36cd0d29f3bcaa8$var$run(v, s, {\n path: k === undefined ? path : [\n ...path,\n k\n ],\n branch: k === undefined ? branch : [\n ...branch,\n v\n ],\n coerce: coerce,\n mask: mask,\n message: options.message\n });\n for (const t of ts){\n if (t[0]) {\n status = t[0].refinement != null ? 'not_refined' : 'not_valid';\n yield [\n t[0],\n undefined\n ];\n } else if (coerce) {\n v = t[1];\n if (k === undefined) value = v;\n else if (value instanceof Map) value.set(k, v);\n else if (value instanceof Set) value.add(v);\n else if ($d36cd0d29f3bcaa8$var$isObject(value)) {\n if (v !== undefined || k in value) value[k] = v;\n }\n }\n }\n }\n if (status !== 'not_valid') for (const failure of struct.refiner(value, ctx)){\n failure.explanation = options.message;\n status = 'not_refined';\n yield [\n failure,\n undefined\n ];\n }\n if (status === 'valid') yield [\n undefined,\n value\n ];\n}\n/**\n * `Struct` objects encapsulate the validation logic for a specific type of\n * values. Once constructed, you use the `assert`, `is` or `validate` helpers to\n * validate unknown input data against the struct.\n */ class $d36cd0d29f3bcaa8$export$eabc71f011df675a {\n constructor(props){\n const { type: type, schema: schema, validator: validator, refiner: refiner, coercer: coercer = (value)=>value, entries: entries = function*() {} } = props;\n this.type = type;\n this.schema = schema;\n this.entries = entries;\n this.coercer = coercer;\n if (validator) this.validator = (value, context)=>{\n const result = validator(value, context);\n return $d36cd0d29f3bcaa8$var$toFailures(result, context, this, value);\n };\n else this.validator = ()=>[];\n if (refiner) this.refiner = (value, context)=>{\n const result = refiner(value, context);\n return $d36cd0d29f3bcaa8$var$toFailures(result, context, this, value);\n };\n else this.refiner = ()=>[];\n }\n /**\n * Assert that a value passes the struct's validation, throwing if it doesn't.\n */ assert(value, message) {\n return $d36cd0d29f3bcaa8$export$a7a9523472993e97(value, this, message);\n }\n /**\n * Create a value with the struct's coercion logic, then validate it.\n */ create(value, message) {\n return $d36cd0d29f3bcaa8$export$185802fd694ee1f5(value, this, message);\n }\n /**\n * Check if a value passes the struct's validation.\n */ is(value) {\n return $d36cd0d29f3bcaa8$export$226b3eccf92c9ed9(value, this);\n }\n /**\n * Mask a value, coercing and validating it, but returning only the subset of\n * properties defined by the struct's schema. Masking applies recursively to\n * props of `object` structs only.\n */ mask(value, message) {\n return $d36cd0d29f3bcaa8$export$d99f0801a68bbcf1(value, this, message);\n }\n /**\n * Validate a value with the struct's validation logic, returning a tuple\n * representing the result.\n *\n * You may optionally pass `true` for the `coerce` argument to coerce\n * the value before attempting to validate it. If you do, the result will\n * contain the coerced result when successful. Also, `mask` will turn on\n * masking of the unknown `object` props recursively if passed.\n */ validate(value, options = {}) {\n return $d36cd0d29f3bcaa8$export$a22775fa5e2eebd9(value, this, options);\n }\n}\n/**\n * Assert that a value passes a struct, throwing if it doesn't.\n */ function $d36cd0d29f3bcaa8$export$a7a9523472993e97(value, struct, message) {\n const result = $d36cd0d29f3bcaa8$export$a22775fa5e2eebd9(value, struct, {\n message: message\n });\n if (result[0]) throw result[0];\n}\n/**\n * Create a value with the coercion logic of struct and validate it.\n */ function $d36cd0d29f3bcaa8$export$185802fd694ee1f5(value, struct, message) {\n const result = $d36cd0d29f3bcaa8$export$a22775fa5e2eebd9(value, struct, {\n coerce: true,\n message: message\n });\n if (result[0]) throw result[0];\n else return result[1];\n}\n/**\n * Mask a value, returning only the subset of properties defined by a struct.\n */ function $d36cd0d29f3bcaa8$export$d99f0801a68bbcf1(value, struct, message) {\n const result = $d36cd0d29f3bcaa8$export$a22775fa5e2eebd9(value, struct, {\n coerce: true,\n mask: true,\n message: message\n });\n if (result[0]) throw result[0];\n else return result[1];\n}\n/**\n * Check if a value passes a struct.\n */ function $d36cd0d29f3bcaa8$export$226b3eccf92c9ed9(value, struct) {\n const result = $d36cd0d29f3bcaa8$export$a22775fa5e2eebd9(value, struct);\n return !result[0];\n}\n/**\n * Validate a value against a struct, returning an error if invalid, or the\n * value (with potential coercion) if valid.\n */ function $d36cd0d29f3bcaa8$export$a22775fa5e2eebd9(value, struct, options = {}) {\n const tuples = $d36cd0d29f3bcaa8$var$run(value, struct, options);\n const tuple = $d36cd0d29f3bcaa8$var$shiftIterator(tuples);\n if (tuple[0]) {\n const error = new $d36cd0d29f3bcaa8$export$58cc9131e3e8861b(tuple[0], function*() {\n for (const t of tuples)if (t[0]) yield t[0];\n });\n return [\n error,\n undefined\n ];\n } else {\n const v = tuple[1];\n return [\n undefined,\n v\n ];\n }\n}\nfunction $d36cd0d29f3bcaa8$export$e6e34fd1f2686227(...Structs) {\n const isType = Structs[0].type === 'type';\n const schemas = Structs.map((s)=>s.schema);\n const schema = Object.assign({}, ...schemas);\n return isType ? $d36cd0d29f3bcaa8$export$bf9fb029d174d554(schema) : $d36cd0d29f3bcaa8$export$be5493f9613cbbe(schema);\n}\n/**\n * Define a new struct type with a custom validation function.\n */ function $d36cd0d29f3bcaa8$export$f36d6a7a5c09a23e(name, validator) {\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n type: name,\n schema: null,\n validator: validator\n });\n}\n/**\n * Create a new struct based on an existing struct, but the value is allowed to\n * be `undefined`. `log` will be called if the value is not `undefined`.\n */ function $d36cd0d29f3bcaa8$export$cdd73fc4100a6ef4(struct, log) {\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n ...struct,\n refiner: (value, ctx)=>value === undefined || struct.refiner(value, ctx),\n validator (value, ctx) {\n if (value === undefined) return true;\n else {\n log(value, ctx);\n return struct.validator(value, ctx);\n }\n }\n });\n}\n/**\n * Create a struct with dynamic validation logic.\n *\n * The callback will receive the value currently being validated, and must\n * return a struct object to validate it with. This can be useful to model\n * validation logic that changes based on its input.\n */ function $d36cd0d29f3bcaa8$export$7077912c31975674(fn) {\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n type: 'dynamic',\n schema: null,\n *entries (value, ctx) {\n const struct = fn(value, ctx);\n yield* struct.entries(value, ctx);\n },\n validator (value, ctx) {\n const struct = fn(value, ctx);\n return struct.validator(value, ctx);\n },\n coercer (value, ctx) {\n const struct = fn(value, ctx);\n return struct.coercer(value, ctx);\n },\n refiner (value, ctx) {\n const struct = fn(value, ctx);\n return struct.refiner(value, ctx);\n }\n });\n}\n/**\n * Create a struct with lazily evaluated validation logic.\n *\n * The first time validation is run with the struct, the callback will be called\n * and must return a struct object to use. This is useful for cases where you\n * want to have self-referential structs for nested data structures to avoid a\n * circular definition problem.\n */ function $d36cd0d29f3bcaa8$export$488013bae63b21da(fn) {\n let struct;\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n type: 'lazy',\n schema: null,\n *entries (value, ctx) {\n struct ?? (struct = fn());\n yield* struct.entries(value, ctx);\n },\n validator (value, ctx) {\n struct ?? (struct = fn());\n return struct.validator(value, ctx);\n },\n coercer (value, ctx) {\n struct ?? (struct = fn());\n return struct.coercer(value, ctx);\n },\n refiner (value, ctx) {\n struct ?? (struct = fn());\n return struct.refiner(value, ctx);\n }\n });\n}\n/**\n * Create a new struct based on an existing object struct, but excluding\n * specific properties.\n *\n * Like TypeScript's `Omit` utility.\n */ function $d36cd0d29f3bcaa8$export$30a06c8d3562193f(struct, keys) {\n const { schema: schema } = struct;\n const subschema = {\n ...schema\n };\n for (const key of keys)delete subschema[key];\n switch(struct.type){\n case 'type':\n return $d36cd0d29f3bcaa8$export$bf9fb029d174d554(subschema);\n default:\n return $d36cd0d29f3bcaa8$export$be5493f9613cbbe(subschema);\n }\n}\n/**\n * Create a new struct based on an existing object struct, but with all of its\n * properties allowed to be `undefined`.\n *\n * Like TypeScript's `Partial` utility.\n */ function $d36cd0d29f3bcaa8$export$e45945969df8035a(struct) {\n const isStruct = struct instanceof $d36cd0d29f3bcaa8$export$eabc71f011df675a;\n const schema = isStruct ? {\n ...struct.schema\n } : {\n ...struct\n };\n for(const key in schema)schema[key] = $d36cd0d29f3bcaa8$export$516e28dec6a4b6d4(schema[key]);\n if (isStruct && struct.type === 'type') return $d36cd0d29f3bcaa8$export$bf9fb029d174d554(schema);\n return $d36cd0d29f3bcaa8$export$be5493f9613cbbe(schema);\n}\n/**\n * Create a new struct based on an existing object struct, but only including\n * specific properties.\n *\n * Like TypeScript's `Pick` utility.\n */ function $d36cd0d29f3bcaa8$export$357523c63a2253b9(struct, keys) {\n const { schema: schema } = struct;\n const subschema = {};\n for (const key of keys)subschema[key] = schema[key];\n switch(struct.type){\n case 'type':\n return $d36cd0d29f3bcaa8$export$bf9fb029d174d554(subschema);\n default:\n return $d36cd0d29f3bcaa8$export$be5493f9613cbbe(subschema);\n }\n}\n/**\n * Define a new struct type with a custom validation function.\n *\n * @deprecated This function has been renamed to `define`.\n */ function $d36cd0d29f3bcaa8$export$8cf3da7c1c9174ea(name, validator) {\n console.warn('superstruct@0.11 - The `struct` helper has been renamed to `define`.');\n return $d36cd0d29f3bcaa8$export$f36d6a7a5c09a23e(name, validator);\n}\n/**\n * Ensure that any value passes validation.\n */ function $d36cd0d29f3bcaa8$export$4154a199d7d90455() {\n return $d36cd0d29f3bcaa8$export$f36d6a7a5c09a23e('any', ()=>true);\n}\nfunction $d36cd0d29f3bcaa8$export$2f23118c22fb2630(Element) {\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n type: 'array',\n schema: Element,\n *entries (value) {\n if (Element && Array.isArray(value)) for (const [i, v] of value.entries())yield [\n i,\n v,\n Element\n ];\n },\n coercer (value) {\n return Array.isArray(value) ? value.slice() : value;\n },\n validator (value) {\n return Array.isArray(value) || `Expected an array value, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`;\n }\n });\n}\n/**\n * Ensure that a value is a bigint.\n */ function $d36cd0d29f3bcaa8$export$a0f65b52274bcc00() {\n return $d36cd0d29f3bcaa8$export$f36d6a7a5c09a23e('bigint', (value)=>{\n return typeof value === 'bigint';\n });\n}\n/**\n * Ensure that a value is a boolean.\n */ function $d36cd0d29f3bcaa8$export$4a21f16c33752377() {\n return $d36cd0d29f3bcaa8$export$f36d6a7a5c09a23e('boolean', (value)=>{\n return typeof value === 'boolean';\n });\n}\n/**\n * Ensure that a value is a valid `Date`.\n *\n * Note: this also ensures that the value is *not* an invalid `Date` object,\n * which can occur when parsing a date fails but still returns a `Date`.\n */ function $d36cd0d29f3bcaa8$export$324d90190a8b822a() {\n return $d36cd0d29f3bcaa8$export$f36d6a7a5c09a23e('date', (value)=>{\n return value instanceof Date && !isNaN(value.getTime()) || `Expected a valid \\`Date\\` object, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`;\n });\n}\nfunction $d36cd0d29f3bcaa8$export$9b16c434df8cc259(values) {\n const schema = {};\n const description = values.map((v)=>$d36cd0d29f3bcaa8$var$print(v)).join();\n for (const key of values)schema[key] = key;\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n type: 'enums',\n schema: schema,\n validator (value) {\n return values.includes(value) || `Expected one of \\`${description}\\`, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`;\n }\n });\n}\n/**\n * Ensure that a value is a function.\n */ function $d36cd0d29f3bcaa8$export$86951950244e2001() {\n return $d36cd0d29f3bcaa8$export$f36d6a7a5c09a23e('func', (value)=>{\n return typeof value === 'function' || `Expected a function, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`;\n });\n}\n/**\n * Ensure that a value is an instance of a specific class.\n */ function $d36cd0d29f3bcaa8$export$9544d5bb712b01ea(Class) {\n return $d36cd0d29f3bcaa8$export$f36d6a7a5c09a23e('instance', (value)=>{\n return value instanceof Class || `Expected a \\`${Class.name}\\` instance, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`;\n });\n}\n/**\n * Ensure that a value is an integer.\n */ function $d36cd0d29f3bcaa8$export$32744b5b3bba4764() {\n return $d36cd0d29f3bcaa8$export$f36d6a7a5c09a23e('integer', (value)=>{\n return typeof value === 'number' && !isNaN(value) && Number.isInteger(value) || `Expected an integer, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`;\n });\n}\n/**\n * Ensure that a value matches all of a set of types.\n */ function $d36cd0d29f3bcaa8$export$bc86dfbf7795668c(Structs) {\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n type: 'intersection',\n schema: null,\n *entries (value, ctx) {\n for (const S of Structs)yield* S.entries(value, ctx);\n },\n *validator (value, ctx) {\n for (const S of Structs)yield* S.validator(value, ctx);\n },\n *refiner (value, ctx) {\n for (const S of Structs)yield* S.refiner(value, ctx);\n }\n });\n}\nfunction $d36cd0d29f3bcaa8$export$c8ec6e1ec9fefcb0(constant) {\n const description = $d36cd0d29f3bcaa8$var$print(constant);\n const t = typeof constant;\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n type: 'literal',\n schema: t === 'string' || t === 'number' || t === 'boolean' ? constant : null,\n validator (value) {\n return value === constant || `Expected the literal \\`${description}\\`, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`;\n }\n });\n}\nfunction $d36cd0d29f3bcaa8$export$871de8747c9eaa88(Key, Value) {\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n type: 'map',\n schema: null,\n *entries (value) {\n if (Key && Value && value instanceof Map) for (const [k, v] of value.entries()){\n yield [\n k,\n k,\n Key\n ];\n yield [\n k,\n v,\n Value\n ];\n }\n },\n coercer (value) {\n return value instanceof Map ? new Map(value) : value;\n },\n validator (value) {\n return value instanceof Map || `Expected a \\`Map\\` object, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`;\n }\n });\n}\n/**\n * Ensure that no value ever passes validation.\n */ function $d36cd0d29f3bcaa8$export$b3e22bcfd64c1022() {\n return $d36cd0d29f3bcaa8$export$f36d6a7a5c09a23e('never', ()=>false);\n}\n/**\n * Augment an existing struct to allow `null` values.\n */ function $d36cd0d29f3bcaa8$export$133fc36489ac9add(struct) {\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n ...struct,\n validator: (value, ctx)=>value === null || struct.validator(value, ctx),\n refiner: (value, ctx)=>value === null || struct.refiner(value, ctx)\n });\n}\n/**\n * Ensure that a value is a number.\n */ function $d36cd0d29f3bcaa8$export$98e628dec113755e() {\n return $d36cd0d29f3bcaa8$export$f36d6a7a5c09a23e('number', (value)=>{\n return typeof value === 'number' && !isNaN(value) || `Expected a number, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`;\n });\n}\nfunction $d36cd0d29f3bcaa8$export$be5493f9613cbbe(schema) {\n const knowns = schema ? Object.keys(schema) : [];\n const Never = $d36cd0d29f3bcaa8$export$b3e22bcfd64c1022();\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n type: 'object',\n schema: schema ? schema : null,\n *entries (value) {\n if (schema && $d36cd0d29f3bcaa8$var$isObject(value)) {\n const unknowns = new Set(Object.keys(value));\n for (const key of knowns){\n unknowns.delete(key);\n yield [\n key,\n value[key],\n schema[key]\n ];\n }\n for (const key of unknowns)yield [\n key,\n value[key],\n Never\n ];\n }\n },\n validator (value) {\n return $d36cd0d29f3bcaa8$var$isNonArrayObject(value) || `Expected an object, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`;\n },\n coercer (value, ctx) {\n if (!$d36cd0d29f3bcaa8$var$isNonArrayObject(value)) return value;\n const coerced = {\n ...value\n };\n // The `object` struct has special behaviour enabled by the mask flag.\n // When masking, properties that are not in the schema are deleted from\n // the coerced object instead of eventually failing validaiton.\n if (ctx.mask && schema) {\n for(const key in coerced)if (schema[key] === undefined) delete coerced[key];\n }\n return coerced;\n }\n });\n}\n/**\n * Augment a struct to allow `undefined` values.\n */ function $d36cd0d29f3bcaa8$export$516e28dec6a4b6d4(struct) {\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n ...struct,\n validator: (value, ctx)=>value === undefined || struct.validator(value, ctx),\n refiner: (value, ctx)=>value === undefined || struct.refiner(value, ctx)\n });\n}\n/**\n * Ensure that a value is an object with keys and values of specific types, but\n * without ensuring any specific shape of properties.\n *\n * Like TypeScript's `Record` utility.\n */ function $d36cd0d29f3bcaa8$export$e5185e241753e543(Key, Value) {\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n type: 'record',\n schema: null,\n *entries (value) {\n if ($d36cd0d29f3bcaa8$var$isObject(value)) for(const k in value){\n const v = value[k];\n yield [\n k,\n k,\n Key\n ];\n yield [\n k,\n v,\n Value\n ];\n }\n },\n validator (value) {\n return $d36cd0d29f3bcaa8$var$isNonArrayObject(value) || `Expected an object, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`;\n },\n coercer (value) {\n return $d36cd0d29f3bcaa8$var$isNonArrayObject(value) ? {\n ...value\n } : value;\n }\n });\n}\n/**\n * Ensure that a value is a `RegExp`.\n *\n * Note: this does not test the value against the regular expression! For that\n * you need to use the `pattern()` refinement.\n */ function $d36cd0d29f3bcaa8$export$efdc1e5bdb609bb() {\n return $d36cd0d29f3bcaa8$export$f36d6a7a5c09a23e('regexp', (value)=>{\n return value instanceof RegExp;\n });\n}\nfunction $d36cd0d29f3bcaa8$export$adaa4cf7ef1b65be(Element) {\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n type: 'set',\n schema: null,\n *entries (value) {\n if (Element && value instanceof Set) for (const v of value)yield [\n v,\n v,\n Element\n ];\n },\n coercer (value) {\n return value instanceof Set ? new Set(value) : value;\n },\n validator (value) {\n return value instanceof Set || `Expected a \\`Set\\` object, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`;\n }\n });\n}\n/**\n * Ensure that a value is a string.\n */ function $d36cd0d29f3bcaa8$export$22b082955e083ec3() {\n return $d36cd0d29f3bcaa8$export$f36d6a7a5c09a23e('string', (value)=>{\n return typeof value === 'string' || `Expected a string, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`;\n });\n}\n/**\n * Ensure that a value is a tuple of a specific length, and that each of its\n * elements is of a specific type.\n */ function $d36cd0d29f3bcaa8$export$65e3907585753458(Structs) {\n const Never = $d36cd0d29f3bcaa8$export$b3e22bcfd64c1022();\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n type: 'tuple',\n schema: null,\n *entries (value) {\n if (Array.isArray(value)) {\n const length = Math.max(Structs.length, value.length);\n for(let i = 0; i < length; i++)yield [\n i,\n value[i],\n Structs[i] || Never\n ];\n }\n },\n validator (value) {\n return Array.isArray(value) || `Expected an array, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`;\n },\n coercer (value) {\n return Array.isArray(value) ? value.slice() : value;\n }\n });\n}\n/**\n * Ensure that a value has a set of known properties of specific types.\n *\n * Note: Unrecognized properties are allowed and untouched. This is similar to\n * how TypeScript's structural typing works.\n */ function $d36cd0d29f3bcaa8$export$bf9fb029d174d554(schema) {\n const keys = Object.keys(schema);\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n type: 'type',\n schema: schema,\n *entries (value) {\n if ($d36cd0d29f3bcaa8$var$isObject(value)) for (const k of keys)yield [\n k,\n value[k],\n schema[k]\n ];\n },\n validator (value) {\n return $d36cd0d29f3bcaa8$var$isNonArrayObject(value) || `Expected an object, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`;\n },\n coercer (value) {\n return $d36cd0d29f3bcaa8$var$isNonArrayObject(value) ? {\n ...value\n } : value;\n }\n });\n}\n/**\n * Ensure that a value matches one of a set of types.\n */ function $d36cd0d29f3bcaa8$export$971dd5b0dfd021b6(Structs) {\n const description = Structs.map((s)=>s.type).join(' | ');\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n type: 'union',\n schema: null,\n coercer (value, ctx) {\n for (const S of Structs){\n const [error, coerced] = S.validate(value, {\n coerce: true,\n mask: ctx.mask\n });\n if (!error) return coerced;\n }\n return value;\n },\n validator (value, ctx) {\n const failures = [];\n for (const S of Structs){\n const [...tuples] = $d36cd0d29f3bcaa8$var$run(value, S, ctx);\n const [first] = tuples;\n if (!first[0]) return [];\n else {\n for (const [failure] of tuples)if (failure) failures.push(failure);\n }\n }\n return [\n `Expected the value to satisfy a union of \\`${description}\\`, but received: ${$d36cd0d29f3bcaa8$var$print(value)}`,\n ...failures\n ];\n }\n });\n}\n/**\n * Ensure that any value passes validation, without widening its type to `any`.\n */ function $d36cd0d29f3bcaa8$export$19282c40b967aec6() {\n return $d36cd0d29f3bcaa8$export$f36d6a7a5c09a23e('unknown', ()=>true);\n}\n/**\n * Augment a `Struct` to add an additional coercion step to its input.\n *\n * This allows you to transform input data before validating it, to increase the\n * likelihood that it passes validation—for example for default values, parsing\n * different formats, etc.\n *\n * Note: You must use `create(value, Struct)` on the value to have the coercion\n * take effect! Using simply `assert()` or `is()` will not use coercion.\n */ function $d36cd0d29f3bcaa8$export$8c14e57e778d3873(struct, condition, coercer) {\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n ...struct,\n coercer: (value, ctx)=>{\n return $d36cd0d29f3bcaa8$export$226b3eccf92c9ed9(value, condition) ? struct.coercer(coercer(value, ctx), ctx) : struct.coercer(value, ctx);\n }\n });\n}\n/**\n * Augment a struct to replace `undefined` values with a default.\n *\n * Note: You must use `create(value, Struct)` on the value to have the coercion\n * take effect! Using simply `assert()` or `is()` will not use coercion.\n */ function $d36cd0d29f3bcaa8$export$83c510c4356017ae(struct, fallback, options = {}) {\n return $d36cd0d29f3bcaa8$export$8c14e57e778d3873(struct, $d36cd0d29f3bcaa8$export$19282c40b967aec6(), (x)=>{\n const f = typeof fallback === 'function' ? fallback() : fallback;\n if (x === undefined) return f;\n if (!options.strict && $d36cd0d29f3bcaa8$var$isPlainObject(x) && $d36cd0d29f3bcaa8$var$isPlainObject(f)) {\n const ret = {\n ...x\n };\n let changed = false;\n for(const key in f)if (ret[key] === undefined) {\n ret[key] = f[key];\n changed = true;\n }\n if (changed) return ret;\n }\n return x;\n });\n}\n/**\n * Augment a struct to trim string inputs.\n *\n * Note: You must use `create(value, Struct)` on the value to have the coercion\n * take effect! Using simply `assert()` or `is()` will not use coercion.\n */ function $d36cd0d29f3bcaa8$export$41f369984ed28930(struct) {\n return $d36cd0d29f3bcaa8$export$8c14e57e778d3873(struct, $d36cd0d29f3bcaa8$export$22b082955e083ec3(), (x)=>x.trim());\n}\n/**\n * Ensure that a string, array, map, or set is empty.\n */ function $d36cd0d29f3bcaa8$export$6e22c362a0406a2c(struct) {\n return $d36cd0d29f3bcaa8$export$edc9d475108b3212(struct, 'empty', (value)=>{\n const size = $d36cd0d29f3bcaa8$var$getSize(value);\n return size === 0 || `Expected an empty ${struct.type} but received one with a size of \\`${size}\\``;\n });\n}\nfunction $d36cd0d29f3bcaa8$var$getSize(value) {\n if (value instanceof Map || value instanceof Set) return value.size;\n else return value.length;\n}\n/**\n * Ensure that a number or date is below a threshold.\n */ function $d36cd0d29f3bcaa8$export$8960430cfd85939f(struct, threshold, options = {}) {\n const { exclusive: exclusive } = options;\n return $d36cd0d29f3bcaa8$export$edc9d475108b3212(struct, 'max', (value)=>{\n return exclusive ? value < threshold : value <= threshold || `Expected a ${struct.type} less than ${exclusive ? '' : 'or equal to '}${threshold} but received \\`${value}\\``;\n });\n}\n/**\n * Ensure that a number or date is above a threshold.\n */ function $d36cd0d29f3bcaa8$export$96ec731ed4dcb222(struct, threshold, options = {}) {\n const { exclusive: exclusive } = options;\n return $d36cd0d29f3bcaa8$export$edc9d475108b3212(struct, 'min', (value)=>{\n return exclusive ? value > threshold : value >= threshold || `Expected a ${struct.type} greater than ${exclusive ? '' : 'or equal to '}${threshold} but received \\`${value}\\``;\n });\n}\n/**\n * Ensure that a string, array, map or set is not empty.\n */ function $d36cd0d29f3bcaa8$export$6ce6c9218151d511(struct) {\n return $d36cd0d29f3bcaa8$export$edc9d475108b3212(struct, 'nonempty', (value)=>{\n const size = $d36cd0d29f3bcaa8$var$getSize(value);\n return size > 0 || `Expected a nonempty ${struct.type} but received an empty one`;\n });\n}\n/**\n * Ensure that a string matches a regular expression.\n */ function $d36cd0d29f3bcaa8$export$24f82734ea047e6f(struct, regexp) {\n return $d36cd0d29f3bcaa8$export$edc9d475108b3212(struct, 'pattern', (value)=>{\n return regexp.test(value) || `Expected a ${struct.type} matching \\`/${regexp.source}/\\` but received \"${value}\"`;\n });\n}\n/**\n * Ensure that a string, array, number, date, map, or set has a size (or length, or time) between `min` and `max`.\n */ function $d36cd0d29f3bcaa8$export$346677f925de839c(struct, min, max = min) {\n const expected = `Expected a ${struct.type}`;\n const of = min === max ? `of \\`${min}\\`` : `between \\`${min}\\` and \\`${max}\\``;\n return $d36cd0d29f3bcaa8$export$edc9d475108b3212(struct, 'size', (value)=>{\n if (typeof value === 'number' || value instanceof Date) return min <= value && value <= max || `${expected} ${of} but received \\`${value}\\``;\n else if (value instanceof Map || value instanceof Set) {\n const { size: size } = value;\n return min <= size && size <= max || `${expected} with a size ${of} but received one with a size of \\`${size}\\``;\n } else {\n const { length: length } = value;\n return min <= length && length <= max || `${expected} with a length ${of} but received one with a length of \\`${length}\\``;\n }\n });\n}\n/**\n * Augment a `Struct` to add an additional refinement to the validation.\n *\n * The refiner function is guaranteed to receive a value of the struct's type,\n * because the struct's existing validation will already have passed. This\n * allows you to layer additional validation on top of existing structs.\n */ function $d36cd0d29f3bcaa8$export$edc9d475108b3212(struct, name, refiner) {\n return new $d36cd0d29f3bcaa8$export$eabc71f011df675a({\n ...struct,\n *refiner (value, ctx) {\n yield* struct.refiner(value, ctx);\n const result = refiner(value, ctx);\n const failures = $d36cd0d29f3bcaa8$var$toFailures(result, ctx, struct, value);\n for (const failure of failures)yield {\n ...failure,\n refinement: name\n };\n }\n });\n}\n\n});\n\nparcelRegister(\"7pfXJ\", function(module, exports) {\n'use strict';\n\nvar $7XmlK = parcelRequire(\"7XmlK\");\nvar $5647400503806718$require$uuid = $7XmlK.default;\n\nvar $4kTUs = parcelRequire(\"4kTUs\");\n/**\n * Constructor for a Jayson Browser Client that does not depend any node.js core libraries\n * @class ClientBrowser\n * @param {Function} callServer Method that calls the server, receives the stringified request and a regular node-style callback\n * @param {Object} [options]\n * @param {Function} [options.reviver] Reviver function for JSON\n * @param {Function} [options.replacer] Replacer function for JSON\n * @param {Number} [options.version=2] JSON-RPC version to use (1|2)\n * @param {Function} [options.generator] Function to use for generating request IDs\n * @param {Boolean} [options.notificationIdNull=false] When true, version 2 requests will set id to null instead of omitting it\n * @return {ClientBrowser}\n */ const $5647400503806718$var$ClientBrowser = function(callServer, options) {\n if (!(this instanceof $5647400503806718$var$ClientBrowser)) return new $5647400503806718$var$ClientBrowser(callServer, options);\n if (!options) options = {};\n this.options = {\n reviver: typeof options.reviver !== 'undefined' ? options.reviver : null,\n replacer: typeof options.replacer !== 'undefined' ? options.replacer : null,\n generator: typeof options.generator !== 'undefined' ? options.generator : function() {\n return $5647400503806718$require$uuid();\n },\n version: typeof options.version !== 'undefined' ? options.version : 2,\n notificationIdNull: typeof options.notificationIdNull === 'boolean' ? options.notificationIdNull : false\n };\n this.callServer = callServer;\n};\nmodule.exports = $5647400503806718$var$ClientBrowser;\n/**\n * Creates a request and dispatches it if given a callback.\n * @param {String|Array} method A batch request if passed an Array, or a method name if passed a String\n * @param {Array|Object} [params] Parameters for the method\n * @param {String|Number} [id] Optional id. If undefined an id will be generated. If null it creates a notification request\n * @param {Function} [callback] Request callback. If specified, executes the request rather than only returning it.\n * @throws {TypeError} Invalid parameters\n * @return {Object} JSON-RPC 1.0 or 2.0 compatible request\n */ $5647400503806718$var$ClientBrowser.prototype.request = function(method, params, id, callback) {\n const self = this;\n let request = null;\n // is this a batch request?\n const isBatch = Array.isArray(method) && typeof params === 'function';\n if (this.options.version === 1 && isBatch) throw new TypeError('JSON-RPC 1.0 does not support batching');\n // is this a raw request?\n const isRaw = !isBatch && method && typeof method === 'object' && typeof params === 'function';\n if (isBatch || isRaw) {\n callback = params;\n request = method;\n } else {\n if (typeof id === 'function') {\n callback = id;\n // specifically undefined because \"null\" is a notification request\n id = undefined;\n }\n const hasCallback = typeof callback === 'function';\n try {\n request = $4kTUs(method, params, id, {\n generator: this.options.generator,\n version: this.options.version,\n notificationIdNull: this.options.notificationIdNull\n });\n } catch (err) {\n if (hasCallback) return callback(err);\n throw err;\n }\n // no callback means we should just return a raw request\n if (!hasCallback) return request;\n }\n let message;\n try {\n message = JSON.stringify(request, this.options.replacer);\n } catch (err) {\n return callback(err);\n }\n this.callServer(message, function(err, response) {\n self._parseResponse(err, response, callback);\n });\n // always return the raw request\n return request;\n};\n/**\n * Parses a response from a server\n * @param {Object} err Error to pass on that is unrelated to the actual response\n * @param {String} responseText JSON-RPC 1.0 or 2.0 response\n * @param {Function} callback Callback that will receive different arguments depending on the amount of parameters\n * @private\n */ $5647400503806718$var$ClientBrowser.prototype._parseResponse = function(err, responseText, callback) {\n if (err) {\n callback(err);\n return;\n }\n if (!responseText) // empty response text, assume that is correct because it could be a\n // notification which jayson does not give any body for\n return callback();\n let response;\n try {\n response = JSON.parse(responseText, this.options.reviver);\n } catch (err) {\n return callback(err);\n }\n if (callback.length === 3) {\n // if callback length is 3, we split callback arguments on error and response\n // is batch response?\n if (Array.isArray(response)) {\n // neccesary to split strictly on validity according to spec here\n const isError = function(res) {\n return typeof res.error !== 'undefined';\n };\n const isNotError = function(res) {\n return !isError(res);\n };\n return callback(null, response.filter(isError), response.filter(isNotError));\n } else // split regardless of validity\n return callback(null, response.error, response.result);\n }\n callback(null, response);\n};\n\n});\nparcelRegister(\"7XmlK\", function(module, exports) {\n\n$parcel$export(module.exports, \"default\", () => $5caf614dfdadbbf1$export$2e2bcd8739ae039);\n\nvar $8vELy = parcelRequire(\"8vELy\");\n\nvar $pdSq5 = parcelRequire(\"pdSq5\");\nfunction $5caf614dfdadbbf1$var$v4(options, buf, offset) {\n options = options || {};\n var rnds = options.random || (options.rng || (0, $8vELy.default))(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n if (buf) {\n offset = offset || 0;\n for(var i = 0; i < 16; ++i)buf[offset + i] = rnds[i];\n return buf;\n }\n return (0, $pdSq5.default)(rnds);\n}\nvar $5caf614dfdadbbf1$export$2e2bcd8739ae039 = $5caf614dfdadbbf1$var$v4;\n\n});\nparcelRegister(\"8vELy\", function(module, exports) {\n\n$parcel$export(module.exports, \"default\", () => $6320d7442e1ae600$export$2e2bcd8739ae039);\n// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nvar $6320d7442e1ae600$var$getRandomValues;\nvar $6320d7442e1ae600$var$rnds8 = new Uint8Array(16);\nfunction $6320d7442e1ae600$export$2e2bcd8739ae039() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!$6320d7442e1ae600$var$getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation. Also,\n // find the complete implementation of crypto (msCrypto) on IE11.\n $6320d7442e1ae600$var$getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);\n if (!$6320d7442e1ae600$var$getRandomValues) throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n return $6320d7442e1ae600$var$getRandomValues($6320d7442e1ae600$var$rnds8);\n}\n\n});\n\nparcelRegister(\"pdSq5\", function(module, exports) {\n\n$parcel$export(module.exports, \"default\", () => $04bd198b9afd43e8$export$2e2bcd8739ae039);\n\nvar $e7Drt = parcelRequire(\"e7Drt\");\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */ var $04bd198b9afd43e8$var$byteToHex = [];\nfor(var $04bd198b9afd43e8$var$i = 0; $04bd198b9afd43e8$var$i < 256; ++$04bd198b9afd43e8$var$i)$04bd198b9afd43e8$var$byteToHex.push(($04bd198b9afd43e8$var$i + 0x100).toString(16).substr(1));\nfunction $04bd198b9afd43e8$var$stringify(arr) {\n var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n var uuid = ($04bd198b9afd43e8$var$byteToHex[arr[offset + 0]] + $04bd198b9afd43e8$var$byteToHex[arr[offset + 1]] + $04bd198b9afd43e8$var$byteToHex[arr[offset + 2]] + $04bd198b9afd43e8$var$byteToHex[arr[offset + 3]] + '-' + $04bd198b9afd43e8$var$byteToHex[arr[offset + 4]] + $04bd198b9afd43e8$var$byteToHex[arr[offset + 5]] + '-' + $04bd198b9afd43e8$var$byteToHex[arr[offset + 6]] + $04bd198b9afd43e8$var$byteToHex[arr[offset + 7]] + '-' + $04bd198b9afd43e8$var$byteToHex[arr[offset + 8]] + $04bd198b9afd43e8$var$byteToHex[arr[offset + 9]] + '-' + $04bd198b9afd43e8$var$byteToHex[arr[offset + 10]] + $04bd198b9afd43e8$var$byteToHex[arr[offset + 11]] + $04bd198b9afd43e8$var$byteToHex[arr[offset + 12]] + $04bd198b9afd43e8$var$byteToHex[arr[offset + 13]] + $04bd198b9afd43e8$var$byteToHex[arr[offset + 14]] + $04bd198b9afd43e8$var$byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n if (!(0, $e7Drt.default)(uuid)) throw TypeError('Stringified UUID is invalid');\n return uuid;\n}\nvar $04bd198b9afd43e8$export$2e2bcd8739ae039 = $04bd198b9afd43e8$var$stringify;\n\n});\nparcelRegister(\"e7Drt\", function(module, exports) {\n\n$parcel$export(module.exports, \"default\", () => $a480508add5e3ec9$export$2e2bcd8739ae039);\n\nvar $gnfHI = parcelRequire(\"gnfHI\");\nfunction $a480508add5e3ec9$var$validate(uuid) {\n return typeof uuid === 'string' && (0, $gnfHI.default).test(uuid);\n}\nvar $a480508add5e3ec9$export$2e2bcd8739ae039 = $a480508add5e3ec9$var$validate;\n\n});\nparcelRegister(\"gnfHI\", function(module, exports) {\n\n$parcel$export(module.exports, \"default\", () => $bebaf9d4e743910c$export$2e2bcd8739ae039);\nvar $bebaf9d4e743910c$export$2e2bcd8739ae039 = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;\n\n});\n\n\n\n\nparcelRegister(\"4kTUs\", function(module, exports) {\n'use strict';\n\nvar $7XmlK = parcelRequire(\"7XmlK\");\nvar $3284662ae09c2cc1$require$uuid = $7XmlK.default;\n/**\n * Generates a JSON-RPC 1.0 or 2.0 request\n * @param {String} method Name of method to call\n * @param {Array|Object} params Array of parameters passed to the method as specified, or an object of parameter names and corresponding value\n * @param {String|Number|null} [id] Request ID can be a string, number, null for explicit notification or left out for automatic generation\n * @param {Object} [options]\n * @param {Number} [options.version=2] JSON-RPC version to use (1 or 2)\n * @param {Boolean} [options.notificationIdNull=false] When true, version 2 requests will set id to null instead of omitting it\n * @param {Function} [options.generator] Passed the request, and the options object and is expected to return a request ID\n * @throws {TypeError} If any of the parameters are invalid\n * @return {Object} A JSON-RPC 1.0 or 2.0 request\n * @memberOf Utils\n */ const $3284662ae09c2cc1$var$generateRequest = function(method, params, id, options) {\n if (typeof method !== 'string') throw new TypeError(method + ' must be a string');\n options = options || {};\n // check valid version provided\n const version = typeof options.version === 'number' ? options.version : 2;\n if (version !== 1 && version !== 2) throw new TypeError(version + ' must be 1 or 2');\n const request = {\n method: method\n };\n if (version === 2) request.jsonrpc = '2.0';\n if (params) {\n // params given, but invalid?\n if (typeof params !== 'object' && !Array.isArray(params)) throw new TypeError(params + ' must be an object, array or omitted');\n request.params = params;\n }\n // if id was left out, generate one (null means explicit notification)\n if (typeof id === 'undefined') {\n const generator = typeof options.generator === 'function' ? options.generator : function() {\n return $3284662ae09c2cc1$require$uuid();\n };\n request.id = generator(request, options);\n } else if (version === 2 && id === null) // we have a version 2 notification\n {\n if (options.notificationIdNull) request.id = null; // id will not be set at all unless option provided\n } else request.id = id;\n return request;\n};\nmodule.exports = $3284662ae09c2cc1$var$generateRequest;\n\n});\n\n\nparcelRegister(\"ga6mf\", function(module, exports) {\n\n$parcel$export(module.exports, \"WebSocket\", () => $c01611184c7492cd$export$3909fb301d3dc8c9);\n$parcel$export(module.exports, \"CommonClient\", () => $c01611184c7492cd$export$b43a6d9568fa5272);\n\nvar $6ZWSX = parcelRequire(\"6ZWSX\");\n\nvar $3hOXp = parcelRequire(\"3hOXp\");\n// node_modules/esbuild-plugin-polyfill-node/polyfills/buffer.js\nvar $c01611184c7492cd$var$WebSocketBrowserImpl = class extends (0, $3hOXp.EventEmitter) {\n socket;\n /** Instantiate a WebSocket class\n * @constructor\n * @param {String} address - url to a websocket server\n * @param {(Object)} options - websocket options\n * @param {(String|Array)} protocols - a list of protocols\n * @return {WebSocketBrowserImpl} - returns a WebSocket instance\n */ constructor(address, options, protocols){\n super();\n this.socket = new window.WebSocket(address, protocols);\n this.socket.onopen = ()=>this.emit(\"open\");\n this.socket.onmessage = (event)=>this.emit(\"message\", event.data);\n this.socket.onerror = (error)=>this.emit(\"error\", error);\n this.socket.onclose = (event)=>{\n this.emit(\"close\", event.code, event.reason);\n };\n }\n /**\n * Sends data through a websocket connection\n * @method\n * @param {(String|Object)} data - data to be sent via websocket\n * @param {Object} optionsOrCallback - ws options\n * @param {Function} callback - a callback called once the data is sent\n * @return {Undefined}\n */ send(data, optionsOrCallback, callback) {\n const cb = callback || optionsOrCallback;\n try {\n this.socket.send(data);\n cb();\n } catch (error) {\n cb(error);\n }\n }\n /**\n * Closes an underlying socket\n * @method\n * @param {Number} code - status code explaining why the connection is being closed\n * @param {String} reason - a description why the connection is closing\n * @return {Undefined}\n * @throws {Error}\n */ close(code, reason) {\n this.socket.close(code, reason);\n }\n addEventListener(type, listener, options) {\n this.socket.addEventListener(type, listener, options);\n }\n};\nfunction $c01611184c7492cd$export$3909fb301d3dc8c9(address, options) {\n return new $c01611184c7492cd$var$WebSocketBrowserImpl(address, options);\n}\n// src/lib/utils.ts\nvar $c01611184c7492cd$export$9fd32f4b4353d82d = class {\n encode(value) {\n return JSON.stringify(value);\n }\n decode(value) {\n return JSON.parse(value);\n }\n};\n// src/lib/client.ts\nvar $c01611184c7492cd$export$b43a6d9568fa5272 = class extends (0, $3hOXp.EventEmitter) {\n address;\n rpc_id;\n queue;\n options;\n autoconnect;\n ready;\n reconnect;\n reconnect_timer_id;\n reconnect_interval;\n max_reconnects;\n rest_options;\n current_reconnects;\n generate_request_id;\n socket;\n webSocketFactory;\n dataPack;\n /**\n * Instantiate a Client class.\n * @constructor\n * @param {webSocketFactory} webSocketFactory - factory method for WebSocket\n * @param {String} address - url to a websocket server\n * @param {Object} options - ws options object with reconnect parameters\n * @param {Function} generate_request_id - custom generation request Id\n * @param {DataPack} dataPack - data pack contains encoder and decoder\n * @return {CommonClient}\n */ constructor(webSocketFactory, address = \"ws://localhost:8080\", { autoconnect: autoconnect = true, reconnect: reconnect = true, reconnect_interval: reconnect_interval = 1e3, max_reconnects: max_reconnects = 5, ...rest_options } = {}, generate_request_id, dataPack){\n super();\n this.webSocketFactory = webSocketFactory;\n this.queue = {};\n this.rpc_id = 0;\n this.address = address;\n this.autoconnect = autoconnect;\n this.ready = false;\n this.reconnect = reconnect;\n this.reconnect_timer_id = void 0;\n this.reconnect_interval = reconnect_interval;\n this.max_reconnects = max_reconnects;\n this.rest_options = rest_options;\n this.current_reconnects = 0;\n this.generate_request_id = generate_request_id || (()=>++this.rpc_id);\n if (!dataPack) this.dataPack = new $c01611184c7492cd$export$9fd32f4b4353d82d();\n else this.dataPack = dataPack;\n if (this.autoconnect) this._connect(this.address, {\n autoconnect: this.autoconnect,\n reconnect: this.reconnect,\n reconnect_interval: this.reconnect_interval,\n max_reconnects: this.max_reconnects,\n ...this.rest_options\n });\n }\n /**\n * Connects to a defined server if not connected already.\n * @method\n * @return {Undefined}\n */ connect() {\n if (this.socket) return;\n this._connect(this.address, {\n autoconnect: this.autoconnect,\n reconnect: this.reconnect,\n reconnect_interval: this.reconnect_interval,\n max_reconnects: this.max_reconnects,\n ...this.rest_options\n });\n }\n /**\n * Calls a registered RPC method on server.\n * @method\n * @param {String} method - RPC method name\n * @param {Object|Array} params - optional method parameters\n * @param {Number} timeout - RPC reply timeout value\n * @param {Object} ws_opts - options passed to ws\n * @return {Promise}\n */ call(method, params, timeout, ws_opts) {\n if (!ws_opts && \"object\" === typeof timeout) {\n ws_opts = timeout;\n timeout = null;\n }\n return new Promise((resolve, reject)=>{\n if (!this.ready) return reject(new Error(\"socket not ready\"));\n const rpc_id = this.generate_request_id(method, params);\n const message = {\n jsonrpc: \"2.0\",\n method: method,\n params: params || void 0,\n id: rpc_id\n };\n this.socket.send(this.dataPack.encode(message), ws_opts, (error)=>{\n if (error) return reject(error);\n this.queue[rpc_id] = {\n promise: [\n resolve,\n reject\n ]\n };\n if (timeout) this.queue[rpc_id].timeout = setTimeout(()=>{\n delete this.queue[rpc_id];\n reject(new Error(\"reply timeout\"));\n }, timeout);\n });\n });\n }\n /**\n * Logins with the other side of the connection.\n * @method\n * @param {Object} params - Login credentials object\n * @return {Promise}\n */ async login(params) {\n const resp = await this.call(\"rpc.login\", params);\n if (!resp) throw new Error(\"authentication failed\");\n return resp;\n }\n /**\n * Fetches a list of client's methods registered on server.\n * @method\n * @return {Array}\n */ async listMethods() {\n return await this.call(\"__listMethods\");\n }\n /**\n * Sends a JSON-RPC 2.0 notification to server.\n * @method\n * @param {String} method - RPC method name\n * @param {Object} params - optional method parameters\n * @return {Promise}\n */ notify(method, params) {\n return new Promise((resolve, reject)=>{\n if (!this.ready) return reject(new Error(\"socket not ready\"));\n const message = {\n jsonrpc: \"2.0\",\n method: method,\n params: params\n };\n this.socket.send(this.dataPack.encode(message), (error)=>{\n if (error) return reject(error);\n resolve();\n });\n });\n }\n /**\n * Subscribes for a defined event.\n * @method\n * @param {String|Array} event - event name\n * @return {Undefined}\n * @throws {Error}\n */ async subscribe(event) {\n if (typeof event === \"string\") event = [\n event\n ];\n const result = await this.call(\"rpc.on\", event);\n if (typeof event === \"string\" && result[event] !== \"ok\") throw new Error(\"Failed subscribing to an event '\" + event + \"' with: \" + result[event]);\n return result;\n }\n /**\n * Unsubscribes from a defined event.\n * @method\n * @param {String|Array} event - event name\n * @return {Undefined}\n * @throws {Error}\n */ async unsubscribe(event) {\n if (typeof event === \"string\") event = [\n event\n ];\n const result = await this.call(\"rpc.off\", event);\n if (typeof event === \"string\" && result[event] !== \"ok\") throw new Error(\"Failed unsubscribing from an event with: \" + result);\n return result;\n }\n /**\n * Closes a WebSocket connection gracefully.\n * @method\n * @param {Number} code - socket close code\n * @param {String} data - optional data to be sent before closing\n * @return {Undefined}\n */ close(code, data) {\n this.socket.close(code || 1e3, data);\n }\n /**\n * Enable / disable automatic reconnection.\n * @method\n * @param {Boolean} reconnect - enable / disable reconnection\n * @return {Undefined}\n */ setAutoReconnect(reconnect) {\n this.reconnect = reconnect;\n }\n /**\n * Set the interval between reconnection attempts.\n * @method\n * @param {Number} interval - reconnection interval in milliseconds\n * @return {Undefined}\n */ setReconnectInterval(interval) {\n this.reconnect_interval = interval;\n }\n /**\n * Set the maximum number of reconnection attempts.\n * @method\n * @param {Number} max_reconnects - maximum reconnection attempts\n * @return {Undefined}\n */ setMaxReconnects(max_reconnects) {\n this.max_reconnects = max_reconnects;\n }\n /**\n * Connection/Message handler.\n * @method\n * @private\n * @param {String} address - WebSocket API address\n * @param {Object} options - ws options object\n * @return {Undefined}\n */ _connect(address, options) {\n clearTimeout(this.reconnect_timer_id);\n this.socket = this.webSocketFactory(address, options);\n this.socket.addEventListener(\"open\", ()=>{\n this.ready = true;\n this.emit(\"open\");\n this.current_reconnects = 0;\n });\n this.socket.addEventListener(\"message\", ({ data: message })=>{\n if (message instanceof ArrayBuffer) message = (0, $6ZWSX.Buffer).from(message).toString();\n try {\n message = this.dataPack.decode(message);\n } catch (error) {\n return;\n }\n if (message.notification && this.listeners(message.notification).length) {\n if (!Object.keys(message.params).length) return this.emit(message.notification);\n const args = [\n message.notification\n ];\n if (message.params.constructor === Object) args.push(message.params);\n else for(let i = 0; i < message.params.length; i++)args.push(message.params[i]);\n return Promise.resolve().then(()=>{\n this.emit.apply(this, args);\n });\n }\n if (!this.queue[message.id]) {\n if (message.method) return Promise.resolve().then(()=>{\n this.emit(message.method, message?.params);\n });\n return;\n }\n if (\"error\" in message === \"result\" in message) this.queue[message.id].promise[1](new Error('Server response malformed. Response must include either \"result\" or \"error\", but not both.'));\n if (this.queue[message.id].timeout) clearTimeout(this.queue[message.id].timeout);\n if (message.error) this.queue[message.id].promise[1](message.error);\n else this.queue[message.id].promise[0](message.result);\n delete this.queue[message.id];\n });\n this.socket.addEventListener(\"error\", (error)=>this.emit(\"error\", error));\n this.socket.addEventListener(\"close\", ({ code: code, reason: reason })=>{\n if (this.ready) setTimeout(()=>this.emit(\"close\", code, reason), 0);\n this.ready = false;\n this.socket = void 0;\n if (code === 1e3) return;\n this.current_reconnects++;\n if (this.reconnect && (this.max_reconnects > this.current_reconnects || this.max_reconnects === 0)) this.reconnect_timer_id = setTimeout(()=>this._connect(address, options), this.reconnect_interval);\n });\n }\n};\n// src/index.browser.ts\nvar $c01611184c7492cd$export$1f2bb630327ac4b6 = class extends $c01611184c7492cd$export$b43a6d9568fa5272 {\n constructor(address = \"ws://localhost:8080\", { autoconnect: autoconnect = true, reconnect: reconnect = true, reconnect_interval: reconnect_interval = 1e3, max_reconnects: max_reconnects = 5 } = {}, generate_request_id){\n super($c01611184c7492cd$export$3909fb301d3dc8c9, address, {\n autoconnect: autoconnect,\n reconnect: reconnect,\n reconnect_interval: reconnect_interval,\n max_reconnects: max_reconnects\n }, generate_request_id);\n }\n};\n //# sourceMappingURL=out.js.map\n\n});\nparcelRegister(\"3hOXp\", function(module, exports) {\n'use strict';\nvar $264a7caaf26e2751$var$has = Object.prototype.hasOwnProperty, $264a7caaf26e2751$var$prefix = '~';\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @private\n */ function $264a7caaf26e2751$var$Events() {}\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n $264a7caaf26e2751$var$Events.prototype = Object.create(null);\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new $264a7caaf26e2751$var$Events().__proto__) $264a7caaf26e2751$var$prefix = false;\n}\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @private\n */ function $264a7caaf26e2751$var$EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n/**\n * Add a listener for a given event.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} once Specify if the listener is a one-time listener.\n * @returns {EventEmitter}\n * @private\n */ function $264a7caaf26e2751$var$addListener(emitter, event, fn, context, once) {\n if (typeof fn !== 'function') throw new TypeError('The listener must be a function');\n var listener = new $264a7caaf26e2751$var$EE(fn, context || emitter, once), evt = $264a7caaf26e2751$var$prefix ? $264a7caaf26e2751$var$prefix + event : event;\n if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;\n else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);\n else emitter._events[evt] = [\n emitter._events[evt],\n listener\n ];\n return emitter;\n}\n/**\n * Clear event by name.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} evt The Event name.\n * @private\n */ function $264a7caaf26e2751$var$clearEvent(emitter, evt) {\n if (--emitter._eventsCount === 0) emitter._events = new $264a7caaf26e2751$var$Events();\n else delete emitter._events[evt];\n}\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @public\n */ function $264a7caaf26e2751$var$EventEmitter() {\n this._events = new $264a7caaf26e2751$var$Events();\n this._eventsCount = 0;\n}\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @public\n */ $264a7caaf26e2751$var$EventEmitter.prototype.eventNames = function eventNames() {\n var names = [], events, name;\n if (this._eventsCount === 0) return names;\n for(name in events = this._events)if ($264a7caaf26e2751$var$has.call(events, name)) names.push($264a7caaf26e2751$var$prefix ? name.slice(1) : name);\n if (Object.getOwnPropertySymbols) return names.concat(Object.getOwnPropertySymbols(events));\n return names;\n};\n/**\n * Return the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Array} The registered listeners.\n * @public\n */ $264a7caaf26e2751$var$EventEmitter.prototype.listeners = function listeners(event) {\n var evt = $264a7caaf26e2751$var$prefix ? $264a7caaf26e2751$var$prefix + event : event, handlers = this._events[evt];\n if (!handlers) return [];\n if (handlers.fn) return [\n handlers.fn\n ];\n for(var i = 0, l = handlers.length, ee = new Array(l); i < l; i++)ee[i] = handlers[i].fn;\n return ee;\n};\n/**\n * Return the number of listeners listening to a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Number} The number of listeners.\n * @public\n */ $264a7caaf26e2751$var$EventEmitter.prototype.listenerCount = function listenerCount(event) {\n var evt = $264a7caaf26e2751$var$prefix ? $264a7caaf26e2751$var$prefix + event : event, listeners = this._events[evt];\n if (!listeners) return 0;\n if (listeners.fn) return 1;\n return listeners.length;\n};\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @public\n */ $264a7caaf26e2751$var$EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = $264a7caaf26e2751$var$prefix ? $264a7caaf26e2751$var$prefix + event : event;\n if (!this._events[evt]) return false;\n var listeners = this._events[evt], len = arguments.length, args, i;\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n switch(len){\n case 1:\n return listeners.fn.call(listeners.context), true;\n case 2:\n return listeners.fn.call(listeners.context, a1), true;\n case 3:\n return listeners.fn.call(listeners.context, a1, a2), true;\n case 4:\n return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5:\n return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6:\n return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n for(i = 1, args = new Array(len - 1); i < len; i++)args[i - 1] = arguments[i];\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length, j;\n for(i = 0; i < length; i++){\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n switch(len){\n case 1:\n listeners[i].fn.call(listeners[i].context);\n break;\n case 2:\n listeners[i].fn.call(listeners[i].context, a1);\n break;\n case 3:\n listeners[i].fn.call(listeners[i].context, a1, a2);\n break;\n case 4:\n listeners[i].fn.call(listeners[i].context, a1, a2, a3);\n break;\n default:\n if (!args) for(j = 1, args = new Array(len - 1); j < len; j++)args[j - 1] = arguments[j];\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n return true;\n};\n/**\n * Add a listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */ $264a7caaf26e2751$var$EventEmitter.prototype.on = function on(event, fn, context) {\n return $264a7caaf26e2751$var$addListener(this, event, fn, context, false);\n};\n/**\n * Add a one-time listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */ $264a7caaf26e2751$var$EventEmitter.prototype.once = function once(event, fn, context) {\n return $264a7caaf26e2751$var$addListener(this, event, fn, context, true);\n};\n/**\n * Remove the listeners of a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {*} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @public\n */ $264a7caaf26e2751$var$EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = $264a7caaf26e2751$var$prefix ? $264a7caaf26e2751$var$prefix + event : event;\n if (!this._events[evt]) return this;\n if (!fn) {\n $264a7caaf26e2751$var$clearEvent(this, evt);\n return this;\n }\n var listeners = this._events[evt];\n if (listeners.fn) {\n if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) $264a7caaf26e2751$var$clearEvent(this, evt);\n } else {\n for(var i = 0, events = [], length = listeners.length; i < length; i++)if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) events.push(listeners[i]);\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else $264a7caaf26e2751$var$clearEvent(this, evt);\n }\n return this;\n};\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {(String|Symbol)} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @public\n */ $264a7caaf26e2751$var$EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n if (event) {\n evt = $264a7caaf26e2751$var$prefix ? $264a7caaf26e2751$var$prefix + event : event;\n if (this._events[evt]) $264a7caaf26e2751$var$clearEvent(this, evt);\n } else {\n this._events = new $264a7caaf26e2751$var$Events();\n this._eventsCount = 0;\n }\n return this;\n};\n//\n// Alias methods names because people roll like that.\n//\n$264a7caaf26e2751$var$EventEmitter.prototype.off = $264a7caaf26e2751$var$EventEmitter.prototype.removeListener;\n$264a7caaf26e2751$var$EventEmitter.prototype.addListener = $264a7caaf26e2751$var$EventEmitter.prototype.on;\n//\n// Expose the prefix.\n//\n$264a7caaf26e2751$var$EventEmitter.prefixed = $264a7caaf26e2751$var$prefix;\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\n$264a7caaf26e2751$var$EventEmitter.EventEmitter = $264a7caaf26e2751$var$EventEmitter;\nmodule.exports = $264a7caaf26e2751$var$EventEmitter;\n\n});\n\n\nparcelRegister(\"J0sDk\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.shake256 = module.exports.shake128 = module.exports.keccak_512 = module.exports.keccak_384 = module.exports.keccak_256 = module.exports.keccak_224 = module.exports.sha3_512 = module.exports.sha3_384 = module.exports.sha3_256 = module.exports.sha3_224 = module.exports.Keccak = void 0;\nmodule.exports.keccakP = $08748f983f07956b$var$keccakP;\n\nvar $dNiq9 = parcelRequire(\"dNiq9\");\n\nvar $eDgKs = parcelRequire(\"eDgKs\");\n\nvar $3Bcdj = parcelRequire(\"3Bcdj\");\n// Various per round constants calculations\nconst $08748f983f07956b$var$SHA3_PI = [];\nconst $08748f983f07956b$var$SHA3_ROTL = [];\nconst $08748f983f07956b$var$_SHA3_IOTA = [];\nconst $08748f983f07956b$var$_0n = /* @__PURE__ */ BigInt(0);\nconst $08748f983f07956b$var$_1n = /* @__PURE__ */ BigInt(1);\nconst $08748f983f07956b$var$_2n = /* @__PURE__ */ BigInt(2);\nconst $08748f983f07956b$var$_7n = /* @__PURE__ */ BigInt(7);\nconst $08748f983f07956b$var$_256n = /* @__PURE__ */ BigInt(256);\nconst $08748f983f07956b$var$_0x71n = /* @__PURE__ */ BigInt(0x71);\nfor(let round = 0, R = $08748f983f07956b$var$_1n, x = 1, y = 0; round < 24; round++){\n // Pi\n [x, y] = [\n y,\n (2 * x + 3 * y) % 5\n ];\n $08748f983f07956b$var$SHA3_PI.push(2 * (5 * y + x));\n // Rotational\n $08748f983f07956b$var$SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);\n // Iota\n let t = $08748f983f07956b$var$_0n;\n for(let j = 0; j < 7; j++){\n R = (R << $08748f983f07956b$var$_1n ^ (R >> $08748f983f07956b$var$_7n) * $08748f983f07956b$var$_0x71n) % $08748f983f07956b$var$_256n;\n if (R & $08748f983f07956b$var$_2n) t ^= $08748f983f07956b$var$_1n << ($08748f983f07956b$var$_1n << /* @__PURE__ */ BigInt(j)) - $08748f983f07956b$var$_1n;\n }\n $08748f983f07956b$var$_SHA3_IOTA.push(t);\n}\nconst [$08748f983f07956b$var$SHA3_IOTA_H, $08748f983f07956b$var$SHA3_IOTA_L] = /* @__PURE__ */ (0, $eDgKs.split)($08748f983f07956b$var$_SHA3_IOTA, true);\n// Left rotation (without 0, 32, 64)\nconst $08748f983f07956b$var$rotlH = (h, l, s)=>s > 32 ? (0, $eDgKs.rotlBH)(h, l, s) : (0, $eDgKs.rotlSH)(h, l, s);\nconst $08748f983f07956b$var$rotlL = (h, l, s)=>s > 32 ? (0, $eDgKs.rotlBL)(h, l, s) : (0, $eDgKs.rotlSL)(h, l, s);\n/** `keccakf1600` internal function, additionally allows to adjust round count. */ function $08748f983f07956b$var$keccakP(s, rounds = 24) {\n const B = new Uint32Array(10);\n // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)\n for(let round = 24 - rounds; round < 24; round++){\n // Theta θ\n for(let x = 0; x < 10; x++)B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];\n for(let x = 0; x < 10; x += 2){\n const idx1 = (x + 8) % 10;\n const idx0 = (x + 2) % 10;\n const B0 = B[idx0];\n const B1 = B[idx0 + 1];\n const Th = $08748f983f07956b$var$rotlH(B0, B1, 1) ^ B[idx1];\n const Tl = $08748f983f07956b$var$rotlL(B0, B1, 1) ^ B[idx1 + 1];\n for(let y = 0; y < 50; y += 10){\n s[x + y] ^= Th;\n s[x + y + 1] ^= Tl;\n }\n }\n // Rho (ρ) and Pi (π)\n let curH = s[2];\n let curL = s[3];\n for(let t = 0; t < 24; t++){\n const shift = $08748f983f07956b$var$SHA3_ROTL[t];\n const Th = $08748f983f07956b$var$rotlH(curH, curL, shift);\n const Tl = $08748f983f07956b$var$rotlL(curH, curL, shift);\n const PI = $08748f983f07956b$var$SHA3_PI[t];\n curH = s[PI];\n curL = s[PI + 1];\n s[PI] = Th;\n s[PI + 1] = Tl;\n }\n // Chi (χ)\n for(let y = 0; y < 50; y += 10){\n for(let x = 0; x < 10; x++)B[x] = s[y + x];\n for(let x = 0; x < 10; x++)s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];\n }\n // Iota (ι)\n s[0] ^= $08748f983f07956b$var$SHA3_IOTA_H[round];\n s[1] ^= $08748f983f07956b$var$SHA3_IOTA_L[round];\n }\n B.fill(0);\n}\n/** Keccak sponge function. */ class $08748f983f07956b$var$Keccak extends $3Bcdj.Hash {\n // NOTE: we accept arguments in bytes instead of bits here.\n constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24){\n super();\n this.blockLen = blockLen;\n this.suffix = suffix;\n this.outputLen = outputLen;\n this.enableXOF = enableXOF;\n this.rounds = rounds;\n this.pos = 0;\n this.posOut = 0;\n this.finished = false;\n this.destroyed = false;\n // Can be passed from user as dkLen\n (0, $dNiq9.anumber)(outputLen);\n // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes\n // 0 < blockLen < 200\n if (0 >= this.blockLen || this.blockLen >= 200) throw new Error('Sha3 supports only keccak-f1600 function');\n this.state = new Uint8Array(200);\n this.state32 = (0, $3Bcdj.u32)(this.state);\n }\n keccak() {\n if (!$3Bcdj.isLE) (0, $3Bcdj.byteSwap32)(this.state32);\n $08748f983f07956b$var$keccakP(this.state32, this.rounds);\n if (!$3Bcdj.isLE) (0, $3Bcdj.byteSwap32)(this.state32);\n this.posOut = 0;\n this.pos = 0;\n }\n update(data) {\n (0, $dNiq9.aexists)(this);\n const { blockLen: blockLen, state: state } = this;\n data = (0, $3Bcdj.toBytes)(data);\n const len = data.length;\n for(let pos = 0; pos < len;){\n const take = Math.min(blockLen - this.pos, len - pos);\n for(let i = 0; i < take; i++)state[this.pos++] ^= data[pos++];\n if (this.pos === blockLen) this.keccak();\n }\n return this;\n }\n finish() {\n if (this.finished) return;\n this.finished = true;\n const { state: state, suffix: suffix, pos: pos, blockLen: blockLen } = this;\n // Do the padding\n state[pos] ^= suffix;\n if ((suffix & 0x80) !== 0 && pos === blockLen - 1) this.keccak();\n state[blockLen - 1] ^= 0x80;\n this.keccak();\n }\n writeInto(out) {\n (0, $dNiq9.aexists)(this, false);\n (0, $dNiq9.abytes)(out);\n this.finish();\n const bufferOut = this.state;\n const { blockLen: blockLen } = this;\n for(let pos = 0, len = out.length; pos < len;){\n if (this.posOut >= blockLen) this.keccak();\n const take = Math.min(blockLen - this.posOut, len - pos);\n out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);\n this.posOut += take;\n pos += take;\n }\n return out;\n }\n xofInto(out) {\n // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF\n if (!this.enableXOF) throw new Error('XOF is not possible for this instance');\n return this.writeInto(out);\n }\n xof(bytes) {\n (0, $dNiq9.anumber)(bytes);\n return this.xofInto(new Uint8Array(bytes));\n }\n digestInto(out) {\n (0, $dNiq9.aoutput)(out, this);\n if (this.finished) throw new Error('digest() was already called');\n this.writeInto(out);\n this.destroy();\n return out;\n }\n digest() {\n return this.digestInto(new Uint8Array(this.outputLen));\n }\n destroy() {\n this.destroyed = true;\n this.state.fill(0);\n }\n _cloneInto(to) {\n const { blockLen: blockLen, suffix: suffix, outputLen: outputLen, rounds: rounds, enableXOF: enableXOF } = this;\n to || (to = new $08748f983f07956b$var$Keccak(blockLen, suffix, outputLen, enableXOF, rounds));\n to.state32.set(this.state32);\n to.pos = this.pos;\n to.posOut = this.posOut;\n to.finished = this.finished;\n to.rounds = rounds;\n // Suffix can change in cSHAKE\n to.suffix = suffix;\n to.outputLen = outputLen;\n to.enableXOF = enableXOF;\n to.destroyed = this.destroyed;\n return to;\n }\n}\nmodule.exports.Keccak = $08748f983f07956b$var$Keccak;\nconst $08748f983f07956b$var$gen = (suffix, blockLen, outputLen)=>(0, $3Bcdj.wrapConstructor)(()=>new $08748f983f07956b$var$Keccak(blockLen, suffix, outputLen));\n/** SHA3-224 hash function. */ module.exports.sha3_224 = $08748f983f07956b$var$gen(0x06, 144, 28);\n/** SHA3-256 hash function. Different from keccak-256. */ module.exports.sha3_256 = $08748f983f07956b$var$gen(0x06, 136, 32);\n/** SHA3-384 hash function. */ module.exports.sha3_384 = $08748f983f07956b$var$gen(0x06, 104, 48);\n/** SHA3-512 hash function. */ module.exports.sha3_512 = $08748f983f07956b$var$gen(0x06, 72, 64);\n/** keccak-224 hash function. */ module.exports.keccak_224 = $08748f983f07956b$var$gen(0x01, 144, 28);\n/** keccak-256 hash function. Different from SHA3-256. */ module.exports.keccak_256 = $08748f983f07956b$var$gen(0x01, 136, 32);\n/** keccak-384 hash function. */ module.exports.keccak_384 = $08748f983f07956b$var$gen(0x01, 104, 48);\n/** keccak-512 hash function. */ module.exports.keccak_512 = $08748f983f07956b$var$gen(0x01, 72, 64);\nconst $08748f983f07956b$var$genShake = (suffix, blockLen, outputLen)=>(0, $3Bcdj.wrapXOFConstructorWithOpts)((opts = {})=>new $08748f983f07956b$var$Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));\n/** SHAKE128 XOF with 128-bit security. */ module.exports.shake128 = $08748f983f07956b$var$genShake(0x1f, 168, 16);\n/** SHAKE256 XOF with 256-bit security. */ module.exports.shake256 = $08748f983f07956b$var$genShake(0x1f, 136, 32);\n\n});\n\nparcelRegister(\"5r7db\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.encodeToCurve = module.exports.hashToCurve = module.exports.schnorr = module.exports.secp256k1 = void 0;\n\nvar $6XnWx = parcelRequire(\"6XnWx\");\n\nvar $3Bcdj = parcelRequire(\"3Bcdj\");\n\nvar $7OcHe = parcelRequire(\"7OcHe\");\n\nvar $rkPJ6 = parcelRequire(\"rkPJ6\");\n\nvar $2D9sF = parcelRequire(\"2D9sF\");\n\nvar $esaJO = parcelRequire(\"esaJO\");\n\nvar $gNPqy = parcelRequire(\"gNPqy\");\nconst $3f551179096121b9$var$secp256k1P = BigInt('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f');\nconst $3f551179096121b9$var$secp256k1N = BigInt('0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141');\nconst $3f551179096121b9$var$_1n = BigInt(1);\nconst $3f551179096121b9$var$_2n = BigInt(2);\nconst $3f551179096121b9$var$divNearest = (a, b)=>(a + b / $3f551179096121b9$var$_2n) / b;\n/**\n * √n = n^((p+1)/4) for fields p = 3 mod 4. We unwrap the loop and multiply bit-by-bit.\n * (P+1n/4n).toString(2) would produce bits [223x 1, 0, 22x 1, 4x 0, 11, 00]\n */ function $3f551179096121b9$var$sqrtMod(y) {\n const P = $3f551179096121b9$var$secp256k1P;\n // prettier-ignore\n const _3n = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);\n // prettier-ignore\n const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88);\n const b2 = y * y * y % P; // x^3, 11\n const b3 = b2 * b2 * y % P; // x^7\n const b6 = (0, $2D9sF.pow2)(b3, _3n, P) * b3 % P;\n const b9 = (0, $2D9sF.pow2)(b6, _3n, P) * b3 % P;\n const b11 = (0, $2D9sF.pow2)(b9, $3f551179096121b9$var$_2n, P) * b2 % P;\n const b22 = (0, $2D9sF.pow2)(b11, _11n, P) * b11 % P;\n const b44 = (0, $2D9sF.pow2)(b22, _22n, P) * b22 % P;\n const b88 = (0, $2D9sF.pow2)(b44, _44n, P) * b44 % P;\n const b176 = (0, $2D9sF.pow2)(b88, _88n, P) * b88 % P;\n const b220 = (0, $2D9sF.pow2)(b176, _44n, P) * b44 % P;\n const b223 = (0, $2D9sF.pow2)(b220, _3n, P) * b3 % P;\n const t1 = (0, $2D9sF.pow2)(b223, _23n, P) * b22 % P;\n const t2 = (0, $2D9sF.pow2)(t1, _6n, P) * b2 % P;\n const root = (0, $2D9sF.pow2)(t2, $3f551179096121b9$var$_2n, P);\n if (!$3f551179096121b9$var$Fpk1.eql($3f551179096121b9$var$Fpk1.sqr(root), y)) throw new Error('Cannot find square root');\n return root;\n}\nconst $3f551179096121b9$var$Fpk1 = (0, $2D9sF.Field)($3f551179096121b9$var$secp256k1P, undefined, undefined, {\n sqrt: $3f551179096121b9$var$sqrtMod\n});\n/**\n * secp256k1 short weierstrass curve and ECDSA signatures over it.\n *\n * @example\n * import { secp256k1 } from '@noble/curves/secp256k1';\n *\n * const priv = secp256k1.utils.randomPrivateKey();\n * const pub = secp256k1.getPublicKey(priv);\n * const msg = new Uint8Array(32).fill(1); // message hash (not message) in ecdsa\n * const sig = secp256k1.sign(msg, priv); // `{prehash: true}` option is available\n * const isValid = secp256k1.verify(sig, msg, pub) === true;\n */ module.exports.secp256k1 = (0, $7OcHe.createCurve)({\n a: BigInt(0),\n b: BigInt(7),\n Fp: $3f551179096121b9$var$Fpk1,\n n: $3f551179096121b9$var$secp256k1N,\n // Base point (x, y) aka generator point\n Gx: BigInt('55066263022277343669578718895168534326250603453777594175500187360389116729240'),\n Gy: BigInt('32670510020758816978083085130507043184471273380659243275938904335757337482424'),\n h: BigInt(1),\n lowS: true,\n endo: {\n // Endomorphism, see above\n beta: BigInt('0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee'),\n splitScalar: (k)=>{\n const n = $3f551179096121b9$var$secp256k1N;\n const a1 = BigInt('0x3086d221a7d46bcde86c90e49284eb15');\n const b1 = -$3f551179096121b9$var$_1n * BigInt('0xe4437ed6010e88286f547fa90abfe4c3');\n const a2 = BigInt('0x114ca50f7a8e2f3f657c1108d9d44cfd8');\n const b2 = a1;\n const POW_2_128 = BigInt('0x100000000000000000000000000000000'); // (2n**128n).toString(16)\n const c1 = $3f551179096121b9$var$divNearest(b2 * k, n);\n const c2 = $3f551179096121b9$var$divNearest(-b1 * k, n);\n let k1 = (0, $2D9sF.mod)(k - c1 * a1 - c2 * a2, n);\n let k2 = (0, $2D9sF.mod)(-c1 * b1 - c2 * b2, n);\n const k1neg = k1 > POW_2_128;\n const k2neg = k2 > POW_2_128;\n if (k1neg) k1 = n - k1;\n if (k2neg) k2 = n - k2;\n if (k1 > POW_2_128 || k2 > POW_2_128) throw new Error('splitScalar: Endomorphism failed, k=' + k);\n return {\n k1neg: k1neg,\n k1: k1,\n k2neg: k2neg,\n k2: k2\n };\n }\n }\n}, $6XnWx.sha256);\n// Schnorr signatures are superior to ECDSA from above. Below is Schnorr-specific BIP0340 code.\n// https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki\nconst $3f551179096121b9$var$_0n = BigInt(0);\n/** An object mapping tags to their tagged hash prefix of [SHA256(tag) | SHA256(tag)] */ const $3f551179096121b9$var$TAGGED_HASH_PREFIXES = {};\nfunction $3f551179096121b9$var$taggedHash(tag, ...messages) {\n let tagP = $3f551179096121b9$var$TAGGED_HASH_PREFIXES[tag];\n if (tagP === undefined) {\n const tagH = (0, $6XnWx.sha256)(Uint8Array.from(tag, (c)=>c.charCodeAt(0)));\n tagP = (0, $esaJO.concatBytes)(tagH, tagH);\n $3f551179096121b9$var$TAGGED_HASH_PREFIXES[tag] = tagP;\n }\n return (0, $6XnWx.sha256)((0, $esaJO.concatBytes)(tagP, ...messages));\n}\n// ECDSA compact points are 33-byte. Schnorr is 32: we strip first byte 0x02 or 0x03\nconst $3f551179096121b9$var$pointToBytes = (point)=>point.toRawBytes(true).slice(1);\nconst $3f551179096121b9$var$numTo32b = (n)=>(0, $esaJO.numberToBytesBE)(n, 32);\nconst $3f551179096121b9$var$modP = (x)=>(0, $2D9sF.mod)(x, $3f551179096121b9$var$secp256k1P);\nconst $3f551179096121b9$var$modN = (x)=>(0, $2D9sF.mod)(x, $3f551179096121b9$var$secp256k1N);\nconst $3f551179096121b9$var$Point = module.exports.secp256k1.ProjectivePoint;\nconst $3f551179096121b9$var$GmulAdd = (Q, a, b)=>$3f551179096121b9$var$Point.BASE.multiplyAndAddUnsafe(Q, a, b);\n// Calculate point, scalar and bytes\nfunction $3f551179096121b9$var$schnorrGetExtPubKey(priv) {\n let d_ = module.exports.secp256k1.utils.normPrivateKeyToScalar(priv); // same method executed in fromPrivateKey\n let p = $3f551179096121b9$var$Point.fromPrivateKey(d_); // P = d'⋅G; 0 < d' < n check is done inside\n const scalar = p.hasEvenY() ? d_ : $3f551179096121b9$var$modN(-d_);\n return {\n scalar: scalar,\n bytes: $3f551179096121b9$var$pointToBytes(p)\n };\n}\n/**\n * lift_x from BIP340. Convert 32-byte x coordinate to elliptic curve point.\n * @returns valid point checked for being on-curve\n */ function $3f551179096121b9$var$lift_x(x) {\n (0, $esaJO.aInRange)('x', x, $3f551179096121b9$var$_1n, $3f551179096121b9$var$secp256k1P); // Fail if x ≥ p.\n const xx = $3f551179096121b9$var$modP(x * x);\n const c = $3f551179096121b9$var$modP(xx * x + BigInt(7)); // Let c = x³ + 7 mod p.\n let y = $3f551179096121b9$var$sqrtMod(c); // Let y = c^(p+1)/4 mod p.\n if (y % $3f551179096121b9$var$_2n !== $3f551179096121b9$var$_0n) y = $3f551179096121b9$var$modP(-y); // Return the unique point P such that x(P) = x and\n const p = new $3f551179096121b9$var$Point(x, y, $3f551179096121b9$var$_1n); // y(P) = y if y mod 2 = 0 or y(P) = p-y otherwise.\n p.assertValidity();\n return p;\n}\nconst $3f551179096121b9$var$num = $esaJO.bytesToNumberBE;\n/**\n * Create tagged hash, convert it to bigint, reduce modulo-n.\n */ function $3f551179096121b9$var$challenge(...args) {\n return $3f551179096121b9$var$modN($3f551179096121b9$var$num($3f551179096121b9$var$taggedHash('BIP0340/challenge', ...args)));\n}\n/**\n * Schnorr public key is just `x` coordinate of Point as per BIP340.\n */ function $3f551179096121b9$var$schnorrGetPublicKey(privateKey) {\n return $3f551179096121b9$var$schnorrGetExtPubKey(privateKey).bytes; // d'=int(sk). Fail if d'=0 or d'≥n. Ret bytes(d'⋅G)\n}\n/**\n * Creates Schnorr signature as per BIP340. Verifies itself before returning anything.\n * auxRand is optional and is not the sole source of k generation: bad CSPRNG won't be dangerous.\n */ function $3f551179096121b9$var$schnorrSign(message, privateKey, auxRand = (0, $3Bcdj.randomBytes)(32)) {\n const m = (0, $esaJO.ensureBytes)('message', message);\n const { bytes: px, scalar: d } = $3f551179096121b9$var$schnorrGetExtPubKey(privateKey); // checks for isWithinCurveOrder\n const a = (0, $esaJO.ensureBytes)('auxRand', auxRand, 32); // Auxiliary random data a: a 32-byte array\n const t = $3f551179096121b9$var$numTo32b(d ^ $3f551179096121b9$var$num($3f551179096121b9$var$taggedHash('BIP0340/aux', a))); // Let t be the byte-wise xor of bytes(d) and hash/aux(a)\n const rand = $3f551179096121b9$var$taggedHash('BIP0340/nonce', t, px, m); // Let rand = hash/nonce(t || bytes(P) || m)\n const k_ = $3f551179096121b9$var$modN($3f551179096121b9$var$num(rand)); // Let k' = int(rand) mod n\n if (k_ === $3f551179096121b9$var$_0n) throw new Error('sign failed: k is zero'); // Fail if k' = 0.\n const { bytes: rx, scalar: k } = $3f551179096121b9$var$schnorrGetExtPubKey(k_); // Let R = k'⋅G.\n const e = $3f551179096121b9$var$challenge(rx, px, m); // Let e = int(hash/challenge(bytes(R) || bytes(P) || m)) mod n.\n const sig = new Uint8Array(64); // Let sig = bytes(R) || bytes((k + ed) mod n).\n sig.set(rx, 0);\n sig.set($3f551179096121b9$var$numTo32b($3f551179096121b9$var$modN(k + e * d)), 32);\n // If Verify(bytes(P), m, sig) (see below) returns failure, abort\n if (!$3f551179096121b9$var$schnorrVerify(sig, m, px)) throw new Error('sign: Invalid signature produced');\n return sig;\n}\n/**\n * Verifies Schnorr signature.\n * Will swallow errors & return false except for initial type validation of arguments.\n */ function $3f551179096121b9$var$schnorrVerify(signature, message, publicKey) {\n const sig = (0, $esaJO.ensureBytes)('signature', signature, 64);\n const m = (0, $esaJO.ensureBytes)('message', message);\n const pub = (0, $esaJO.ensureBytes)('publicKey', publicKey, 32);\n try {\n const P = $3f551179096121b9$var$lift_x($3f551179096121b9$var$num(pub)); // P = lift_x(int(pk)); fail if that fails\n const r = $3f551179096121b9$var$num(sig.subarray(0, 32)); // Let r = int(sig[0:32]); fail if r ≥ p.\n if (!(0, $esaJO.inRange)(r, $3f551179096121b9$var$_1n, $3f551179096121b9$var$secp256k1P)) return false;\n const s = $3f551179096121b9$var$num(sig.subarray(32, 64)); // Let s = int(sig[32:64]); fail if s ≥ n.\n if (!(0, $esaJO.inRange)(s, $3f551179096121b9$var$_1n, $3f551179096121b9$var$secp256k1N)) return false;\n const e = $3f551179096121b9$var$challenge($3f551179096121b9$var$numTo32b(r), $3f551179096121b9$var$pointToBytes(P), m); // int(challenge(bytes(r)||bytes(P)||m))%n\n const R = $3f551179096121b9$var$GmulAdd(P, s, $3f551179096121b9$var$modN(-e)); // R = s⋅G - e⋅P\n if (!R || !R.hasEvenY() || R.toAffine().x !== r) return false; // -eP == (n-e)P\n return true; // Fail if is_infinite(R) / not has_even_y(R) / x(R) ≠ r.\n } catch (error) {\n return false;\n }\n}\n/**\n * Schnorr signatures over secp256k1.\n * https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki\n * @example\n * import { schnorr } from '@noble/curves/secp256k1';\n * const priv = schnorr.utils.randomPrivateKey();\n * const pub = schnorr.getPublicKey(priv);\n * const msg = new TextEncoder().encode('hello');\n * const sig = schnorr.sign(msg, priv);\n * const isValid = schnorr.verify(sig, msg, pub);\n */ module.exports.schnorr = (()=>({\n getPublicKey: $3f551179096121b9$var$schnorrGetPublicKey,\n sign: $3f551179096121b9$var$schnorrSign,\n verify: $3f551179096121b9$var$schnorrVerify,\n utils: {\n randomPrivateKey: module.exports.secp256k1.utils.randomPrivateKey,\n lift_x: $3f551179096121b9$var$lift_x,\n pointToBytes: $3f551179096121b9$var$pointToBytes,\n numberToBytesBE: $esaJO.numberToBytesBE,\n bytesToNumberBE: $esaJO.bytesToNumberBE,\n taggedHash: $3f551179096121b9$var$taggedHash,\n mod: $2D9sF.mod\n }\n }))();\nconst $3f551179096121b9$var$isoMap = /* @__PURE__ */ (()=>(0, $rkPJ6.isogenyMap)($3f551179096121b9$var$Fpk1, [\n // xNum\n [\n '0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7',\n '0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581',\n '0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262',\n '0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c'\n ],\n // xDen\n [\n '0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b',\n '0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14',\n '0x0000000000000000000000000000000000000000000000000000000000000001'\n ],\n // yNum\n [\n '0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c',\n '0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3',\n '0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931',\n '0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84'\n ],\n // yDen\n [\n '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b',\n '0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573',\n '0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f',\n '0x0000000000000000000000000000000000000000000000000000000000000001'\n ]\n ].map((i)=>i.map((j)=>BigInt(j)))))();\nconst $3f551179096121b9$var$mapSWU = /* @__PURE__ */ (()=>(0, $gNPqy.mapToCurveSimpleSWU)($3f551179096121b9$var$Fpk1, {\n A: BigInt('0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533'),\n B: BigInt('1771'),\n Z: $3f551179096121b9$var$Fpk1.create(BigInt('-11'))\n }))();\nconst $3f551179096121b9$var$htf = /* @__PURE__ */ (()=>(0, $rkPJ6.createHasher)(module.exports.secp256k1.ProjectivePoint, (scalars)=>{\n const { x: x, y: y } = $3f551179096121b9$var$mapSWU($3f551179096121b9$var$Fpk1.create(scalars[0]));\n return $3f551179096121b9$var$isoMap(x, y);\n }, {\n DST: 'secp256k1_XMD:SHA-256_SSWU_RO_',\n encodeDST: 'secp256k1_XMD:SHA-256_SSWU_NU_',\n p: $3f551179096121b9$var$Fpk1.ORDER,\n m: 1,\n k: 128,\n expand: 'xmd',\n hash: $6XnWx.sha256\n }))();\n/** secp256k1 hash-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */ module.exports.hashToCurve = (()=>$3f551179096121b9$var$htf.hashToCurve)();\n/** secp256k1 encode-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */ module.exports.encodeToCurve = (()=>$3f551179096121b9$var$htf.encodeToCurve)();\n\n});\nparcelRegister(\"7OcHe\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.getHash = $5af70d1c5fca3e4e$var$getHash;\nmodule.exports.createCurve = $5af70d1c5fca3e4e$var$createCurve;\n\nvar $70Xw9 = parcelRequire(\"70Xw9\");\n\nvar $3Bcdj = parcelRequire(\"3Bcdj\");\n\nvar $gNPqy = parcelRequire(\"gNPqy\");\n/** connects noble-curves to noble-hashes */ function $5af70d1c5fca3e4e$var$getHash(hash) {\n return {\n hash: hash,\n hmac: (key, ...msgs)=>(0, $70Xw9.hmac)(hash, key, (0, $3Bcdj.concatBytes)(...msgs)),\n randomBytes: $3Bcdj.randomBytes\n };\n}\nfunction $5af70d1c5fca3e4e$var$createCurve(curveDef, defHash) {\n const create = (hash)=>(0, $gNPqy.weierstrass)({\n ...curveDef,\n ...$5af70d1c5fca3e4e$var$getHash(hash)\n });\n return {\n ...create(defHash),\n create: create\n };\n}\n\n});\nparcelRegister(\"70Xw9\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.hmac = module.exports.HMAC = void 0;\n\nvar $dNiq9 = parcelRequire(\"dNiq9\");\n\nvar $3Bcdj = parcelRequire(\"3Bcdj\");\nclass $51b6b372898f65c0$var$HMAC extends $3Bcdj.Hash {\n constructor(hash, _key){\n super();\n this.finished = false;\n this.destroyed = false;\n (0, $dNiq9.ahash)(hash);\n const key = (0, $3Bcdj.toBytes)(_key);\n this.iHash = hash.create();\n if (typeof this.iHash.update !== 'function') throw new Error('Expected instance of class which extends utils.Hash');\n this.blockLen = this.iHash.blockLen;\n this.outputLen = this.iHash.outputLen;\n const blockLen = this.blockLen;\n const pad = new Uint8Array(blockLen);\n // blockLen can be bigger than outputLen\n pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);\n for(let i = 0; i < pad.length; i++)pad[i] ^= 0x36;\n this.iHash.update(pad);\n // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone\n this.oHash = hash.create();\n // Undo internal XOR && apply outer XOR\n for(let i = 0; i < pad.length; i++)pad[i] ^= 106;\n this.oHash.update(pad);\n pad.fill(0);\n }\n update(buf) {\n (0, $dNiq9.aexists)(this);\n this.iHash.update(buf);\n return this;\n }\n digestInto(out) {\n (0, $dNiq9.aexists)(this);\n (0, $dNiq9.abytes)(out, this.outputLen);\n this.finished = true;\n this.iHash.digestInto(out);\n this.oHash.update(out);\n this.oHash.digestInto(out);\n this.destroy();\n }\n digest() {\n const out = new Uint8Array(this.oHash.outputLen);\n this.digestInto(out);\n return out;\n }\n _cloneInto(to) {\n // Create new instance without calling constructor since key already in state and we don't know it.\n to || (to = Object.create(Object.getPrototypeOf(this), {}));\n const { oHash: oHash, iHash: iHash, finished: finished, destroyed: destroyed, blockLen: blockLen, outputLen: outputLen } = this;\n to;\n to.finished = finished;\n to.destroyed = destroyed;\n to.blockLen = blockLen;\n to.outputLen = outputLen;\n to.oHash = oHash._cloneInto(to.oHash);\n to.iHash = iHash._cloneInto(to.iHash);\n return to;\n }\n destroy() {\n this.destroyed = true;\n this.oHash.destroy();\n this.iHash.destroy();\n }\n}\nmodule.exports.HMAC = $51b6b372898f65c0$var$HMAC;\n/**\n * HMAC: RFC2104 message authentication code.\n * @param hash - function that would be used e.g. sha256\n * @param key - message key\n * @param message - message data\n * @example\n * import { hmac } from '@noble/hashes/hmac';\n * import { sha256 } from '@noble/hashes/sha2';\n * const mac1 = hmac(sha256, 'key', 'message');\n */ const $51b6b372898f65c0$var$hmac = (hash, key, message)=>new $51b6b372898f65c0$var$HMAC(hash, key).update(message).digest();\nmodule.exports.hmac = $51b6b372898f65c0$var$hmac;\nmodule.exports.hmac.create = (hash, key)=>new $51b6b372898f65c0$var$HMAC(hash, key);\n\n});\n\nparcelRegister(\"gNPqy\", function(module, exports) {\n\"use strict\";\nObject.defineProperty(module.exports, \"__esModule\", {\n value: true\n});\nmodule.exports.DER = module.exports.DERErr = void 0;\nmodule.exports.weierstrassPoints = $c3b91d553ab14e64$var$weierstrassPoints;\nmodule.exports.weierstrass = $c3b91d553ab14e64$var$weierstrass;\nmodule.exports.SWUFpSqrtRatio = $c3b91d553ab14e64$var$SWUFpSqrtRatio;\nmodule.exports.mapToCurveSimpleSWU = $c3b91d553ab14e64$var$mapToCurveSimpleSWU;\n\nvar $lkFCe = parcelRequire(\"lkFCe\");\n\nvar $2D9sF = parcelRequire(\"2D9sF\");\n\nvar $esaJO = parcelRequire(\"esaJO\");\n\nvar $esaJO = parcelRequire(\"esaJO\");\nfunction $c3b91d553ab14e64$var$validateSigVerOpts(opts) {\n if (opts.lowS !== undefined) (0, $esaJO.abool)('lowS', opts.lowS);\n if (opts.prehash !== undefined) (0, $esaJO.abool)('prehash', opts.prehash);\n}\nfunction $c3b91d553ab14e64$var$validatePointOpts(curve) {\n const opts = (0, $lkFCe.validateBasic)(curve);\n $esaJO.validateObject(opts, {\n a: 'field',\n b: 'field'\n }, {\n allowedPrivateKeyLengths: 'array',\n wrapPrivateKey: 'boolean',\n isTorsionFree: 'function',\n clearCofactor: 'function',\n allowInfinityPoint: 'boolean',\n fromBytes: 'function',\n toBytes: 'function'\n });\n const { endo: endo, Fp: Fp, a: a } = opts;\n if (endo) {\n if (!Fp.eql(a, Fp.ZERO)) throw new Error('invalid endomorphism, can only be defined for Koblitz curves that have a=0');\n if (typeof endo !== 'object' || typeof endo.beta !== 'bigint' || typeof endo.splitScalar !== 'function') throw new Error('invalid endomorphism, expected beta: bigint and splitScalar: function');\n }\n return Object.freeze({\n ...opts\n });\n}\nconst { bytesToNumberBE: $c3b91d553ab14e64$var$b2n, hexToBytes: $c3b91d553ab14e64$var$h2b } = $esaJO;\nclass $c3b91d553ab14e64$var$DERErr extends Error {\n constructor(m = ''){\n super(m);\n }\n}\nmodule.exports.DERErr = $c3b91d553ab14e64$var$DERErr;\n/**\n * ASN.1 DER encoding utilities. ASN is very complex & fragile. Format:\n *\n * [0x30 (SEQUENCE), bytelength, 0x02 (INTEGER), intLength, R, 0x02 (INTEGER), intLength, S]\n *\n * Docs: https://letsencrypt.org/docs/a-warm-welcome-to-asn1-and-der/, https://luca.ntop.org/Teaching/Appunti/asn1.html\n */ module.exports.DER = {\n // asn.1 DER encoding utils\n Err: $c3b91d553ab14e64$var$DERErr,\n // Basic building block is TLV (Tag-Length-Value)\n _tlv: {\n encode: (tag, data)=>{\n const { Err: E } = module.exports.DER;\n if (tag < 0 || tag > 256) throw new E('tlv.encode: wrong tag');\n if (data.length & 1) throw new E('tlv.encode: unpadded data');\n const dataLen = data.length / 2;\n const len = $esaJO.numberToHexUnpadded(dataLen);\n if (len.length / 2 & 128) throw new E('tlv.encode: long form length too big');\n // length of length with long form flag\n const lenLen = dataLen > 127 ? $esaJO.numberToHexUnpadded(len.length / 2 | 128) : '';\n const t = $esaJO.numberToHexUnpadded(tag);\n return t + lenLen + len + data;\n },\n // v - value, l - left bytes (unparsed)\n decode (tag, data) {\n const { Err: E } = module.exports.DER;\n let pos = 0;\n if (tag < 0 || tag > 256) throw new E('tlv.encode: wrong tag');\n if (data.length < 2 || data[pos++] !== tag) throw new E('tlv.decode: wrong tlv');\n const first = data[pos++];\n const isLong = !!(first & 128); // First bit of first length byte is flag for short/long form\n let length = 0;\n if (!isLong) length = first;\n else {\n // Long form: [longFlag(1bit), lengthLength(7bit), length (BE)]\n const lenLen = first & 127;\n if (!lenLen) throw new E('tlv.decode(long): indefinite length not supported');\n if (lenLen > 4) throw new E('tlv.decode(long): byte length is too big'); // this will overflow u32 in js\n const lengthBytes = data.subarray(pos, pos + lenLen);\n if (lengthBytes.length !== lenLen) throw new E('tlv.decode: length bytes not complete');\n if (lengthBytes[0] === 0) throw new E('tlv.decode(long): zero leftmost byte');\n for (const b of lengthBytes)length = length << 8 | b;\n pos += lenLen;\n if (length < 128) throw new E('tlv.decode(long): not minimal encoding');\n }\n const v = data.subarray(pos, pos + length);\n if (v.length !== length) throw new E('tlv.decode: wrong value length');\n return {\n v: v,\n l: data.subarray(pos + length)\n };\n }\n },\n // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,\n // since we always use positive integers here. It must always be empty:\n // - add zero byte if exists\n // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)\n _int: {\n encode (num) {\n const { Err: E } = module.exports.DER;\n if (num < $c3b91d553ab14e64$var$_0n) throw new E('integer: negative integers are not allowed');\n let hex = $esaJO.numberToHexUnpadded(num);\n // Pad with zero byte if negative flag is present\n if (Number.parseInt(hex[0], 16) & 8) hex = '00' + hex;\n if (hex.length & 1) throw new E('unexpected DER parsing assertion: unpadded hex');\n return hex;\n },\n decode (data) {\n const { Err: E } = module.exports.DER;\n if (data[0] & 128) throw new E('invalid signature integer: negative');\n if (data[0] === 0x00 && !(data[1] & 128)) throw new E('invalid signature integer: unnecessary leading zero');\n return $c3b91d553ab14e64$var$b2n(data);\n }\n },\n toSig (hex) {\n // parse DER signature\n const { Err: E, _int: int, _tlv: tlv } = module.exports.DER;\n const data = typeof hex === 'string' ? $c3b91d553ab14e64$var$h2b(hex) : hex;\n $esaJO.abytes(data);\n const { v: seqBytes, l: seqLeftBytes } = tlv.decode(0x30, data);\n if (seqLeftBytes.length) throw new E('invalid signature: left bytes after parsing');\n const { v: rBytes, l: rLeftBytes } = tlv.decode(0x02, seqBytes);\n const { v: sBytes, l: sLeftBytes } = tlv.decode(0x02, rLeftBytes);\n if (sLeftBytes.length) throw new E('invalid signature: left bytes after parsing');\n return {\n r: int.decode(rBytes),\n s: int.decode(sBytes)\n };\n },\n hexFromSig (sig) {\n const { _tlv: tlv, _int: int } = module.exports.DER;\n const rs = tlv.encode(0x02, int.encode(sig.r));\n const ss = tlv.encode(0x02, int.encode(sig.s));\n const seq = rs + ss;\n return tlv.encode(0x30, seq);\n }\n};\n// Be friendly to bad ECMAScript parsers by not using bigint literals\n// prettier-ignore\nconst $c3b91d553ab14e64$var$_0n = BigInt(0), $c3b91d553ab14e64$var$_1n = BigInt(1), $c3b91d553ab14e64$var$_2n = BigInt(2), $c3b91d553ab14e64$var$_3n = BigInt(3), $c3b91d553ab14e64$var$_4n = BigInt(4);\nfunction $c3b91d553ab14e64$var$weierstrassPoints(opts) {\n const CURVE = $c3b91d553ab14e64$var$validatePointOpts(opts);\n const { Fp: Fp } = CURVE; // All curves has same field / group length as for now, but they can differ\n const Fn = (0, $2D9sF.Field)(CURVE.n, CURVE.nBitLength);\n const toBytes = CURVE.toBytes || ((_c, point, _isCompressed)=>{\n const a = point.toAffine();\n return $esaJO.concatBytes(Uint8Array.from([\n 0x04\n ]), Fp.toBytes(a.x), Fp.toBytes(a.y));\n });\n const fromBytes = CURVE.fromBytes || ((bytes)=>{\n // const head = bytes[0];\n const tail = bytes.subarray(1);\n // if (head !== 0x04) throw new Error('Only non-compressed encoding is supported');\n const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES));\n const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));\n return {\n x: x,\n y: y\n };\n });\n /**\n * y² = x³ + ax + b: Short weierstrass curve formula\n * @returns y²\n */ function weierstrassEquation(x) {\n const { a: a, b: b } = CURVE;\n const x2 = Fp.sqr(x); // x * x\n const x3 = Fp.mul(x2, x); // x2 * x\n return Fp.add(Fp.add(x3, Fp.mul(x, a)), b); // x3 + a * x + b\n }\n // Validate whether the passed curve params are valid.\n // We check if curve equation works for generator point.\n // `assertValidity()` won't work: `isTorsionFree()` is not available at this point in bls12-381.\n // ProjectivePoint class has not been initialized yet.\n if (!Fp.eql(Fp.sqr(CURVE.Gy), weierstrassEquation(CURVE.Gx))) throw new Error('bad generator point: equation left != right');\n // Valid group elements reside in range 1..n-1\n function isWithinCurveOrder(num) {\n return $esaJO.inRange(num, $c3b91d553ab14e64$var$_1n, CURVE.n);\n }\n // Validates if priv key is valid and converts it to bigint.\n // Supports options allowedPrivateKeyLengths and wrapPrivateKey.\n function normPrivateKeyToScalar(key) {\n const { allowedPrivateKeyLengths: lengths, nByteLength: nByteLength, wrapPrivateKey: wrapPrivateKey, n: N } = CURVE;\n if (lengths && typeof key !== 'bigint') {\n if ($esaJO.isBytes(key)) key = $esaJO.bytesToHex(key);\n // Normalize to hex string, pad. E.g. P521 would norm 130-132 char hex to 132-char bytes\n if (typeof key !== 'string' || !lengths.includes(key.length)) throw new Error('invalid private key');\n key = key.padStart(nByteLength * 2, '0');\n }\n let num;\n try {\n num = typeof key === 'bigint' ? key : $esaJO.bytesToNumberBE((0, $esaJO.ensureBytes)('private key', key, nByteLength));\n } catch (error) {\n throw new Error('invalid private key, expected hex or ' + nByteLength + ' bytes, got ' + typeof key);\n }\n if (wrapPrivateKey) num = (0, $2D9sF.mod)(num, N); // disabled by default, enabled for BLS\n $esaJO.aInRange('private key', num, $c3b91d553ab14e64$var$_1n, N); // num in range [1..N-1]\n return num;\n }\n function assertPrjPoint(other) {\n if (!(other instanceof Point)) throw new Error('ProjectivePoint expected');\n }\n // Memoized toAffine / validity check. They are heavy. Points are immutable.\n // Converts Projective point to affine (x, y) coordinates.\n // Can accept precomputed Z^-1 - for example, from invertBatch.\n // (x, y, z) ∋ (x=x/z, y=y/z)\n const toAffineMemo = (0, $esaJO.memoized)((p, iz)=>{\n const { px: x, py: y, pz: z } = p;\n // Fast-path for normalized points\n if (Fp.eql(z, Fp.ONE)) return {\n x: x,\n y: y\n };\n const is0 = p.is0();\n // If invZ was 0, we return zero point. However we still want to execute\n // all operations, so we replace invZ with a random number, 1.\n if (iz == null) iz = is0 ? Fp.ONE : Fp.inv(z);\n const ax = Fp.mul(x, iz);\n const ay = Fp.mul(y, iz);\n const zz = Fp.mul(z, iz);\n if (is0) return {\n x: Fp.ZERO,\n y: Fp.ZERO\n };\n if (!Fp.eql(zz, Fp.ONE)) throw new Error('invZ was invalid');\n return {\n x: ax,\n y: ay\n };\n });\n // NOTE: on exception this will crash 'cached' and no value will be set.\n // Otherwise true will be return\n const assertValidMemo = (0, $esaJO.memoized)((p)=>{\n if (p.is0()) {\n // (0, 1, 0) aka ZERO is invalid in most contexts.\n // In BLS, ZERO can be serialized, so we allow it.\n // (0, 0, 0) is invalid representation of ZERO.\n if (CURVE.allowInfinityPoint && !Fp.is0(p.py)) return;\n throw new Error('bad point: ZERO');\n }\n // Some 3rd-party test vectors require different wording between here & `fromCompressedHex`\n const { x: x, y: y } = p.toAffine();\n // Check if x, y are valid field elements\n if (!Fp.isValid(x) || !Fp.isValid(y)) throw new Error('bad point: x or y not FE');\n const left = Fp.sqr(y); // y²\n const right = weierstrassEquation(x); // x³ + ax + b\n if (!Fp.eql(left, right)) throw new Error('bad point: equation left != right');\n if (!p.isTorsionFree()) throw new Error('bad point: not in prime-order subgroup');\n return true;\n });\n /**\n * Projective Point works in 3d / projective (homogeneous) coordinates: (x, y, z) ∋ (x=x/z, y=y/z)\n * Default Point works in 2d / affine coordinates: (x, y)\n * We're doing calculations in projective, because its operations don't require costly inversion.\n */ class Point {\n constructor(px, py, pz){\n this.px = px;\n this.py = py;\n this.pz = pz;\n if (px == null || !Fp.isValid(px)) throw new Error('x required');\n if (py == null || !Fp.isValid(py)) throw new Error('y required');\n if (pz == null || !Fp.isValid(pz)) throw new Error('z required');\n Object.freeze(this);\n }\n // Does not validate if the point is on-curve.\n // Use fromHex instead, or call assertValidity() later.\n static fromAffine(p) {\n const { x: x, y: y } = p || {};\n if (!p || !Fp.isValid(x) || !Fp.isValid(y)) throw new Error('invalid affine point');\n if (p instanceof Point) throw new Error('projective point not allowed');\n const is0 = (i)=>Fp.eql(i, Fp.ZERO);\n // fromAffine(x:0, y:0) would produce (x:0, y:0, z:1), but we need (x:0, y:1, z:0)\n if (is0(x) && is0(y)) return Point.ZERO;\n return new Point(x, y, Fp.ONE);\n }\n get x() {\n return this.toAffine().x;\n }\n get y() {\n return this.toAffine().y;\n }\n /**\n * Takes a bunch of Projective Points but executes only one\n * inversion on all of them. Inversion is very slow operation,\n * so this improves performance massively.\n * Optimization: converts a list of projective points to a list of identical points with Z=1.\n */ static normalizeZ(points) {\n const toInv = Fp.invertBatch(points.map((p)=>p.pz));\n return points.map((p, i)=>p.toAffine(toInv[i])).map(Point.fromAffine);\n }\n /**\n * Converts hash string or Uint8Array to Point.\n * @param hex short/long ECDSA hex\n */ static fromHex(hex) {\n const P = Point.fromAffine(fromBytes((0, $esaJO.ensureBytes)('pointHex', hex)));\n P.assertValidity();\n return P;\n }\n // Multiplies generator point by privateKey.\n static fromPrivateKey(privateKey) {\n return Point.BASE.multiply(normPrivateKeyToScalar(privateKey));\n }\n // Multiscalar Multiplication\n static msm(points, scalars) {\n return (0, $lkFCe.pippenger)(Point, Fn, points, scalars);\n }\n // \"Private method\", don't use it directly\n _setWindowSize(windowSize) {\n wnaf.setWindowSize(this, windowSize);\n }\n // A point on curve is valid if it conforms to equation.\n assertValidity() {\n assertValidMemo(this);\n }\n hasEvenY() {\n const { y: y } = this.toAffine();\n if (Fp.isOdd) return !Fp.isOdd(y);\n throw new Error(\"Field doesn't support isOdd\");\n }\n /**\n * Compare one point to another.\n */ equals(other) {\n assertPrjPoint(other);\n const { px: X1, py: Y1, pz: Z1 } = this;\n const { px: X2, py: Y2, pz: Z2 } = other;\n const U1 = Fp.eql(Fp.mul(X1, Z2), Fp.mul(X2, Z1));\n const U2 = Fp.eql(Fp.mul(Y1, Z2), Fp.mul(Y2, Z1));\n return U1 && U2;\n }\n /**\n * Flips point to one corresponding to (x, -y) in Affine coordinates.\n */ negate() {\n return new Point(this.px, Fp.neg(this.py), this.pz);\n }\n // Renes-Costello-Batina exception-free doubling formula.\n // There is 30% faster Jacobian formula, but it is not complete.\n // https://eprint.iacr.org/2015/1060, algorithm 3\n // Cost: 8M + 3S + 3*a + 2*b3 + 15add.\n double() {\n const { a: a, b: b } = CURVE;\n const b3 = Fp.mul(b, $c3b91d553ab14e64$var$_3n);\n const { px: X1, py: Y1, pz: Z1 } = this;\n let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore\n let t0 = Fp.mul(X1, X1); // step 1\n let t1 = Fp.mul(Y1, Y1);\n let t2 = Fp.mul(Z1, Z1);\n let t3 = Fp.mul(X1, Y1);\n t3 = Fp.add(t3, t3); // step 5\n Z3 = Fp.mul(X1, Z1);\n Z3 = Fp.add(Z3, Z3);\n X3 = Fp.mul(a, Z3);\n Y3 = Fp.mul(b3, t2);\n Y3 = Fp.add(X3, Y3); // step 10\n X3 = Fp.sub(t1, Y3);\n Y3 = Fp.add(t1, Y3);\n Y3 = Fp.mul(X3, Y3);\n X3 = Fp.mul(t3, X3);\n Z3 = Fp.mul(b3, Z3); // step 15\n t2 = Fp.mul(a, t2);\n t3 = Fp.sub(t0, t2);\n t3 = Fp.mul(a, t3);\n t3 = Fp.add(t3, Z3);\n Z3 = Fp.add(t0, t0); // step 20\n t0 = Fp.add(Z3, t0);\n t0 = Fp.add(t0, t2);\n t0 = Fp.mul(t0, t3);\n Y3 = Fp.add(Y3, t0);\n t2 = Fp.mul(Y1, Z1); // step 25\n t2 = Fp.add(t2, t2);\n t0 = Fp.mul(t2, t3);\n X3 = Fp.sub(X3, t0);\n Z3 = Fp.mul(t2, t1);\n Z3 = Fp.add(Z3, Z3); // step 30\n Z3 = Fp.add(Z3, Z3);\n return new Point(X3, Y3, Z3);\n }\n // Renes-Costello-Batina exception-free addition formula.\n // There is 30% faster Jacobian formula, but it is not complete.\n // https://eprint.iacr.org/2015/1060, algorithm 1\n // Cost: 12M + 0S + 3*a + 3*b3 + 23add.\n add(other) {\n assertPrjPoint(other);\n const { px: X1, py: Y1, pz: Z1 } = this;\n const { px: X2, py: Y2, pz: Z2 } = other;\n let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore\n const a = CURVE.a;\n const b3 = Fp.mul(CURVE.b, $c3b91d553ab14e64$var$_3n);\n let t0 = Fp.mul(X1, X2); // step 1\n let t1 = Fp.mul(Y1, Y2);\n let t2 = Fp.mul(Z1, Z2);\n let t3 = Fp.add(X1, Y1);\n let t4 = Fp.add(X2, Y2); // step 5\n t3 = Fp.mul(t3, t4);\n t4 = Fp.add(t0, t1);\n t3 = Fp.sub(t3, t4);\n t4 = Fp.add(X1, Z1);\n let t5 = Fp.add(X2, Z2); // step 10\n t4 = Fp.mul(t4, t5);\n t5 = Fp.add(t0, t2);\n t4 = Fp.sub(t4, t5);\n t5 = Fp.add(Y1, Z1);\n X3 = Fp.add(Y2, Z2); // step 15\n t5 = Fp.mul(t5, X3);\n X3 = Fp.add(t1, t2);\n t5 = Fp.sub(t5, X3);\n Z3 = Fp.mul(a, t4);\n X3 = Fp.mul(b3, t2); // step 20\n Z3 = Fp.add(X3, Z3);\n X3 = Fp.sub(t1, Z3);\n Z3 = Fp.add(t1, Z3);\n Y3 = Fp.mul(X3, Z3);\n t1 = Fp.add(t0, t0); // step 25\n t1 = Fp.add(t1, t0);\n t2 = Fp.mul(a, t2);\n t4 = Fp.mul(b3, t4);\n t1 = Fp.add(t1, t2);\n t2 = Fp.sub(t0, t2); // step 30\n t2 = Fp.mul(a, t2);\n t4 = Fp.add(t4, t2);\n t0 = Fp.mul(t1, t4);\n Y3 = Fp.add(Y3, t0);\n t0 = Fp.mul(t5, t4); // step 35\n X3 = Fp.mul(t3, X3);\n X3 = Fp.sub(X3, t0);\n t0 = Fp.mul(t3, t1);\n Z3 = Fp.mul(t5, Z3);\n Z3 = Fp.add(Z3, t0); // step 40\n return new Point(X3, Y3, Z3);\n }\n subtract(other) {\n return this.add(other.negate());\n }\n is0() {\n return this.equals(Point.ZERO);\n }\n wNAF(n) {\n return wnaf.wNAFCached(this, n, Point.normalizeZ);\n }\n /**\n * Non-constant-time multiplication. Uses double-and-add algorithm.\n * It's faster, but should only be used when you don't care about\n * an exposed private key e.g. sig verification, which works over *public* keys.\n */ multiplyUnsafe(sc) {\n const { endo: endo, n: N } = CURVE;\n $esaJO.aInRange('scalar', sc, $c3b91d553ab14e64$var$_0n, N);\n const I = Point.ZERO;\n if (sc === $c3b91d553ab14e64$var$_0n) return I;\n if (this.is0() || sc === $c3b91d553ab14e64$var$_1n) return this;\n // Case a: no endomorphism. Case b: has precomputes.\n if (!endo || wnaf.hasPrecomputes(this)) return wnaf.wNAFCachedUnsafe(this, sc, Point.normalizeZ);\n // Case c: endomorphism\n let { k1neg: k1neg, k1: k1, k2neg: k2neg, k2: k2 } = endo.splitScalar(sc);\n let k1p = I;\n let k2p = I;\n let d = this;\n while(k1 > $c3b91d553ab14e64$var$_0n || k2 > $c3b91d553ab14e64$var$_0n){\n if (k1 & $c3b91d553ab14e64$var$_1n) k1p = k1p.add(d);\n if (k2 & $c3b91d553ab14e64$var$_1n) k2p = k2p.add(d);\n d = d.double();\n k1 >>= $c3b91d553ab14e64$var$_1n;\n k2 >>= $c3b91d553ab14e64$var$_1n;\n }\n if (k1neg) k1p = k1p.negate();\n if (k2neg) k2p = k2p.negate();\n k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz);\n return k1p.add(k2p);\n }\n /**\n * Constant time multiplication.\n * Uses wNAF method. Windowed method may be 10% faster,\n * but takes 2x longer to generate and consumes 2x memory.\n * Uses precomputes when available.\n * Uses endomorphism for Koblitz curves.\n * @param scalar by which the point would be multiplied\n * @returns New point\n */ multiply(scalar) {\n const { endo: endo, n: N } = CURVE;\n $esaJO.aInRange('scalar', scalar, $c3b91d553ab14e64$var$_1n, N);\n let point, fake; // Fake point is used to const-time mult\n if (endo) {\n const { k1neg: k1neg, k1: k1, k2neg: k2neg, k2: k2 } = endo.splitScalar(scalar);\n let { p: k1p, f: f1p } = this.wNAF(k1);\n let { p: k2p, f: f2p } = this.wNAF(k2);\n k1p = wnaf.constTimeNegate(k1neg, k1p);\n k2p = wnaf.constTimeNegate(k2neg, k2p);\n k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz);\n point = k1p.add(k2p);\n fake = f1p.add(f2p);\n } else {\n const { p: p, f: f } = this.wNAF(scalar);\n point = p;\n fake = f;\n }\n // Normalize `z` for both points, but return only real one\n return Point.normalizeZ([\n point,\n fake\n ])[0];\n }\n /**\n * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.\n * Not using Strauss-Shamir trick: precomputation tables are faster.\n * The trick could be useful if both P and Q are not G (not in our case).\n * @returns non-zero affine point\n */ multiplyAndAddUnsafe(Q, a, b) {\n const G = Point.BASE; // No Strauss-Shamir trick: we have 10% faster G precomputes\n const mul = (P, a // Select faster multiply() method\n )=>a === $c3b91d553ab14e64$var$_0n || a === $c3b91d553ab14e64$var$_1n || !P.equals(G) ? P.multiplyUnsafe(a) : P.multiply(a);\n const sum = mul(this, a).add(mul(Q, b));\n return sum.is0() ? undefined : sum;\n }\n // Converts Projective point to affine (x, y) coordinates.\n // Can accept precomputed Z^-1 - for example, from invertBatch.\n // (x, y, z) ∋ (x=x/z, y=y/z)\n toAffine(iz) {\n return toAffineMemo(this, iz);\n }\n isTorsionFree() {\n const { h: cofactor, isTorsionFree: isTorsionFree } = CURVE;\n if (cofactor === $c3b91d553ab14e64$var$_1n) return true; // No subgroups, always torsion-free\n if (isTorsionFree) return isTorsionFree(Point, this);\n throw new Error('isTorsionFree() has not been declared for the elliptic curve');\n }\n clearCofactor() {\n const { h: cofactor, clearCofactor: clearCofactor } = CURVE;\n if (cofactor === $c3b91d553ab14e64$var$_1n) return this; // Fast-path\n if (clearCofactor) return clearCofactor(Point, this);\n return this.multiplyUnsafe(CURVE.h);\n }\n toRawBytes(isCompressed = true) {\n (0, $esaJO.abool)('isCompressed', isCompressed);\n this.assertValidity();\n return toBytes(Point, this, isCompressed);\n }\n toHex(isCompressed = true) {\n (0, $esaJO.abool)('isCompressed', isCompressed);\n return $esaJO.bytesToHex(this.toRawBytes(isCompressed));\n }\n }\n Point.BASE = new Point(CURVE.Gx, CURVE.Gy, Fp.ONE);\n Point.ZERO = new Point(Fp.ZERO, Fp.ONE, Fp.ZERO);\n const _bits = CURVE.nBitLength;\n const wnaf = (0, $lkFCe.wNAF)(Point, CURVE.endo ? Math.ceil(_bits / 2) : _bits);\n // Validate if generator point is on curve\n return {\n CURVE: CURVE,\n ProjectivePoint: Point,\n normPrivateKeyToScalar: normPrivateKeyToScalar,\n weierstrassEquation: weierstrassEquation,\n isWithinCurveOrder: isWithinCurveOrder\n };\n}\nfunction $c3b91d553ab14e64$var$validateOpts(curve) {\n const opts = (0, $lkFCe.validateBasic)(curve);\n $esaJO.validateObject(opts, {\n hash: 'hash',\n hmac: 'function',\n randomBytes: 'function'\n }, {\n bits2int: 'function',\n bits2int_modN: 'function',\n lowS: 'boolean'\n });\n return Object.freeze({\n lowS: true,\n ...opts\n });\n}\n/**\n * Creates short weierstrass curve and ECDSA signature methods for it.\n * @example\n * import { Field } from '@noble/curves/abstract/modular';\n * // Before that, define BigInt-s: a, b, p, n, Gx, Gy\n * const curve = weierstrass({ a, b, Fp: Field(p), n, Gx, Gy, h: 1n })\n */ function $c3b91d553ab14e64$var$weierstrass(curveDef) {\n const CURVE = $c3b91d553ab14e64$var$validateOpts(curveDef);\n const { Fp: Fp, n: CURVE_ORDER } = CURVE;\n const compressedLen = Fp.BYTES + 1; // e.g. 33 for 32\n const uncompressedLen = 2 * Fp.BYTES + 1; // e.g. 65 for 32\n function modN(a) {\n return (0, $2D9sF.mod)(a, CURVE_ORDER);\n }\n function invN(a) {\n return (0, $2D9sF.invert)(a, CURVE_ORDER);\n }\n const { ProjectivePoint: Point, normPrivateKeyToScalar: normPrivateKeyToScalar, weierstrassEquation: weierstrassEquation, isWithinCurveOrder: isWithinCurveOrder } = $c3b91d553ab14e64$var$weierstrassPoints({\n ...CURVE,\n toBytes (_c, point, isCompressed) {\n const a = point.toAffine();\n const x = Fp.toBytes(a.x);\n const cat = $esaJO.concatBytes;\n (0, $esaJO.abool)('isCompressed', isCompressed);\n if (isCompressed) return cat(Uint8Array.from([\n point.hasEvenY() ? 0x02 : 0x03\n ]), x);\n else return cat(Uint8Array.from([\n 0x04\n ]), x, Fp.toBytes(a.y));\n },\n fromBytes (bytes) {\n const len = bytes.length;\n const head = bytes[0];\n const tail = bytes.subarray(1);\n // this.assertValidity() is done inside of fromHex\n if (len === compressedLen && (head === 0x02 || head === 0x03)) {\n const x = $esaJO.bytesToNumberBE(tail);\n if (!$esaJO.inRange(x, $c3b91d553ab14e64$var$_1n, Fp.ORDER)) throw new Error('Point is not on curve');\n const y2 = weierstrassEquation(x); // y² = x³ + ax + b\n let y;\n try {\n y = Fp.sqrt(y2); // y = y² ^ (p+1)/4\n } catch (sqrtError) {\n const suffix = sqrtError instanceof Error ? ': ' + sqrtError.message : '';\n throw new Error('Point is not on curve' + suffix);\n }\n const isYOdd = (y & $c3b91d553ab14e64$var$_1n) === $c3b91d553ab14e64$var$_1n;\n // ECDSA\n const isHeadOdd = (head & 1) === 1;\n if (isHeadOdd !== isYOdd) y = Fp.neg(y);\n return {\n x: x,\n y: y\n };\n } else if (len === uncompressedLen && head === 0x04) {\n const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES));\n const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));\n return {\n x: x,\n y: y\n };\n } else {\n const cl = compressedLen;\n const ul = uncompressedLen;\n throw new Error('invalid Point, expected length of ' + cl + ', or uncompressed ' + ul + ', got ' + len);\n }\n }\n });\n const numToNByteStr = (num)=>$esaJO.bytesToHex($esaJO.numberToBytesBE(num, CURVE.nByteLength));\n function isBiggerThanHalfOrder(number) {\n const HALF = CURVE_ORDER >> $c3b91d553ab14e64$var$_1n;\n return number > HALF;\n }\n function normalizeS(s) {\n return isBiggerThanHalfOrder(s) ? modN(-s) : s;\n }\n // slice bytes num\n const slcNum = (b, from, to)=>$esaJO.bytesToNumberBE(b.slice(from, to));\n /**\n * ECDSA signature with its (r, s) properties. Supports DER & compact representations.\n */ class Signature {\n constructor(r, s, recovery){\n this.r = r;\n this.s = s;\n this.recovery = recovery;\n this.assertValidity();\n }\n // pair (bytes of r, bytes of s)\n static fromCompact(hex) {\n const l = CURVE.nByteLength;\n hex = (0, $esaJO.ensureBytes)('compactSignature', hex, l * 2);\n return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l));\n }\n // DER encoded ECDSA signature\n // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script\n static fromDER(hex) {\n const { r: r, s: s } = module.exports.DER.toSig((0, $esaJO.ensureBytes)('DER', hex));\n return new Signature(r, s);\n }\n assertValidity() {\n $esaJO.aInRange('r', this.r, $c3b91d553ab14e64$var$_1n, CURVE_ORDER); // r in [1..N]\n $esaJO.aInRange('s', this.s, $c3b91d553ab14e64$var$_1n, CURVE_ORDER); // s in [1..N]\n }\n addRecoveryBit(recovery) {\n return new Signature(this.r, this.s, recovery);\n }\n recoverPublicKey(msgHash) {\n const { r: r, s: s, recovery: rec } = this;\n const h = bits2int_modN((0, $esaJO.ensureBytes)('msgHash', msgHash)); // Truncate hash\n if (rec == null || ![\n 0,\n 1,\n 2,\n 3\n ].includes(rec)) throw new Error('recovery id invalid');\n const radj = rec === 2 || rec === 3 ? r + CURVE.n : r;\n if (radj >= Fp.ORDER) throw new Error('recovery id 2 or 3 invalid');\n const prefix = (rec & 1) === 0 ? '02' : '03';\n const R = Point.fromHex(prefix + numToNByteStr(radj));\n const ir = invN(radj); // r^-1\n const u1 = modN(-h * ir); // -hr^-1\n const u2 = modN(s * ir); // sr^-1\n const Q = Point.BASE.multiplyAndAddUnsafe(R, u1, u2); // (sr^-1)R-(hr^-1)G = -(hr^-1)G + (sr^-1)\n if (!Q) throw new Error('point at infinify'); // unsafe is fine: no priv data leaked\n Q.assertValidity();\n return Q;\n }\n // Signatures should be low-s, to prevent malleability.\n hasHighS() {\n return isBiggerThanHalfOrder(this.s);\n }\n normalizeS() {\n return this.hasHighS() ? new Signature(this.r, modN(-this.s), this.recovery) : this;\n }\n // DER-encoded\n toDERRawBytes() {\n return $esaJO.hexToBytes(this.toDERHex());\n }\n toDERHex() {\n return module.exports.DER.hexFromSig({\n r: this.r,\n s: this.s\n });\n }\n // padded bytes of r, then padded bytes of s\n toCompactRawBytes() {\n return $esaJO.hexToBytes(this.toCompactHex());\n }\n toCompactHex() {\n return numToNByteStr(this.r) + numToNByteStr(this.s);\n }\n }\n const utils = {\n isValidPrivateKey (privateKey) {\n try {\n normPrivateKeyToScalar(privateKey);\n return true;\n } catch (error) {\n return false;\n }\n },\n normPrivateKeyToScalar: normPrivateKeyToScalar,\n /**\n * Produces cryptographically secure private key from random of size\n * (groupLen + ceil(groupLen / 2)) with modulo bias being negligible.\n */ randomPrivateKey: ()=>{\n const length = (0, $2D9sF.getMinHashLength)(CURVE.n);\n return (0, $2D9sF.mapHashToField)(CURVE.randomBytes(length), CURVE.n);\n },\n /**\n * Creates precompute table for an arbitrary EC point. Makes point \"cached\".\n * Allows to massively speed-up `point.multiply(scalar)`.\n * @returns cached point\n * @example\n * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey));\n * fast.multiply(privKey); // much faster ECDH now\n */ precompute (windowSize = 8, point = Point.BASE) {\n point._setWindowSize(windowSize);\n point.multiply(BigInt(3)); // 3 is arbitrary, just need any number here\n return point;\n }\n };\n /**\n * Computes public key for a private key. Checks for validity of the private key.\n * @param privateKey private key\n * @param isCompressed whether to return compact (default), or full key\n * @returns Public key, full when isCompressed=false; short when isCompressed=true\n */ function getPublicKey(privateKey, isCompressed = true) {\n return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed);\n }\n /**\n * Quick and dirty check for item being public key. Does not validate hex, or being on-curve.\n */ function isProbPub(item) {\n const arr = $esaJO.isBytes(item);\n const str = typeof item === 'string';\n const len = (arr || str) && item.length;\n if (arr) return len === compressedLen || len === uncompressedLen;\n if (str) return len === 2 * compressedLen || len === 2 * uncompressedLen;\n if (item instanceof Point) return true;\n return false;\n }\n /**\n * ECDH (Elliptic Curve Diffie Hellman).\n * Computes shared public key from private key and public key.\n * Checks: 1) private key validity 2) shared key is on-curve.\n * Does NOT hash the result.\n * @param privateA private key\n * @param publicB different public key\n * @param isCompressed whether to return compact (default), or full key\n * @returns shared public key\n */ function getSharedSecret(privateA, publicB, isCompressed = true) {\n if (isProbPub(privateA)) throw new Error('first arg must be private key');\n if (!isProbPub(publicB)) throw new Error('second arg must be public key');\n const b = Point.fromHex(publicB); // check for being on-curve\n return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);\n }\n // RFC6979: ensure ECDSA msg is X bytes and < N. RFC suggests optional truncating via bits2octets.\n // FIPS 186-4 4.6 suggests the leftmost min(nBitLen, outLen) bits, which matches bits2int.\n // bits2int can produce res>N, we can do mod(res, N) since the bitLen is the same.\n // int2octets can't be used; pads small msgs with 0: unacceptatble for trunc as per RFC vectors\n const bits2int = CURVE.bits2int || function(bytes) {\n // Our custom check \"just in case\"\n if (bytes.length > 8192) throw new Error('input is too large');\n // For curves with nBitLength % 8 !== 0: bits2octets(bits2octets(m)) !== bits2octets(m)\n // for some cases, since bytes.length * 8 is not actual bitLength.\n const num = $esaJO.bytesToNumberBE(bytes); // check for == u8 done here\n const delta = bytes.length * 8 - CURVE.nBitLength; // truncate to nBitLength leftmost bits\n return delta > 0 ? num >> BigInt(delta) : num;\n };\n const bits2int_modN = CURVE.bits2int_modN || function(bytes) {\n return modN(bits2int(bytes)); // can't use bytesToNumberBE here\n };\n // NOTE: pads output with zero as per spec\n const ORDER_MASK = $esaJO.bitMask(CURVE.nBitLength);\n /**\n * Converts to bytes. Checks if num in `[0..ORDER_MASK-1]` e.g.: `[0..2^256-1]`.\n */ function int2octets(num) {\n $esaJO.aInRange('num < 2^' + CURVE.nBitLength, num, $c3b91d553ab14e64$var$_0n, ORDER_MASK);\n // works with order, can have different size than numToField!\n return $esaJO.numberToBytesBE(num, CURVE.nByteLength);\n }\n // Steps A, D of RFC6979 3.2\n // Creates RFC6979 seed; converts msg/privKey to numbers.\n // Used only in sign, not in verify.\n // NOTE: we cannot assume here that msgHash has same amount of bytes as curve order,\n // this will be invalid at least for P521. Also it can be bigger for P224 + SHA256\n function prepSig(msgHash, privateKey, opts = defaultSigOpts) {\n if ([\n 'recovered',\n 'canonical'\n ].some((k)=>k in opts)) throw new Error('sign() legacy options not supported');\n const { hash: hash, randomBytes: randomBytes } = CURVE;\n let { lowS: lowS, prehash: prehash, extraEntropy: ent } = opts; // generates low-s sigs by default\n if (lowS == null) lowS = true; // RFC6979 3.2: we skip step A, because we already provide hash\n msgHash = (0, $esaJO.ensureBytes)('msgHash', msgHash);\n $c3b91d553ab14e64$var$validateSigVerOpts(opts);\n if (prehash) msgHash = (0, $esaJO.ensureBytes)('prehashed msgHash', hash(msgHash));\n // We can't later call bits2octets, since nested bits2int is broken for curves\n // with nBitLength % 8 !== 0. Because of that, we unwrap it here as int2octets call.\n // const bits2octets = (bits) => int2octets(bits2int_modN(bits))\n const h1int = bits2int_modN(msgHash);\n const d = normPrivateKeyToScalar(privateKey); // validate private key, convert to bigint\n const seedArgs = [\n int2octets(d),\n int2octets(h1int)\n ];\n // extraEntropy. RFC6979 3.6: additional k' (optional).\n if (ent != null && ent !== false) {\n // K = HMAC_K(V || 0x00 || int2octets(x) || bits2octets(h1) || k')\n const e = ent === true ? randomBytes(Fp.BYTES) : ent; // generate random bytes OR pass as-is\n seedArgs.push((0, $esaJO.ensureBytes)('extraEntropy', e)); // check for being bytes\n }\n const seed = $esaJO.concatBytes(...seedArgs); // Step D of RFC6979 3.2\n const m = h1int; // NOTE: no need to call bits2int second time here, it is inside truncateHash!\n // Converts signature params into point w r/s, checks result for validity.\n function k2sig(kBytes) {\n // RFC 6979 Section 3.2, step 3: k = bits2int(T)\n const k = bits2int(kBytes); // Cannot use fields methods, since it is group element\n if (!isWithinCurveOrder(k)) return; // Important: all mod() calls here must be done over N\n const ik = invN(k); // k^-1 mod n\n const q = Point.BASE.multiply(k).toAffine(); // q = Gk\n const r = modN(q.x); // r = q.x mod n\n if (r === $c3b91d553ab14e64$var$_0n) return;\n // Can use scalar blinding b^-1(bm + bdr) where b ∈ [1,q−1] according to\n // https://tches.iacr.org/index.php/TCHES/article/view/7337/6509. We've decided against it:\n // a) dependency on CSPRNG b) 15% slowdown c) doesn't really help since bigints are not CT\n const s = modN(ik * modN(m + r * d)); // Not using blinding here\n if (s === $c3b91d553ab14e64$var$_0n) return;\n let recovery = (q.x === r ? 0 : 2) | Number(q.y & $c3b91d553ab14e64$var$_1n); // recovery bit (2 or 3, when q.x > n)\n let normS = s;\n if (lowS && isBiggerThanHalfOrder(s)) {\n normS = normalizeS(s); // if lowS was passed, ensure s is always\n recovery ^= 1; // // in the bottom half of N\n }\n return new Signature(r, normS, recovery); // use normS, not s\n }\n return {\n seed: seed,\n k2sig: k2sig\n };\n }\n const defaultSigOpts = {\n lowS: CURVE.lowS,\n prehash: false\n };\n const defaultVerOpts = {\n lowS: CURVE.lowS,\n prehash: false\n };\n /**\n * Signs message hash with a private key.\n * ```\n * sign(m, d, k) where\n * (x, y) = G × k\n * r = x mod n\n * s = (m + dr)/k mod n\n * ```\n * @param msgHash NOT message. msg needs to be hashed to `msgHash`, or use `prehash`.\n * @param privKey private key\n * @param opts lowS for non-malleable sigs. extraEntropy for mixing randomness into k. prehash will hash first arg.\n * @returns signature with recovery param\n */ function sign(msgHash, privKey, opts = defaultSigOpts) {\n const { seed: seed, k2sig: k2sig } = prepSig(msgHash, privKey, opts); // Steps A, D of RFC6979 3.2.\n const C = CURVE;\n const drbg = $esaJO.createHmacDrbg(C.hash.outputLen, C.nByteLength, C.hmac);\n return drbg(seed, k2sig); // Steps B, C, D, E, F, G\n }\n // Enable precomputes. Slows down first publicKey computation by 20ms.\n Point.BASE._setWindowSize(8);\n // utils.precompute(8, ProjectivePoint.BASE)\n /**\n * Verifies a signature against message hash and public key.\n * Rejects lowS signatures by default: to override,\n * specify option `{lowS: false}`. Implements section 4.1.4 from https://www.secg.org/sec1-v2.pdf:\n *\n * ```\n * verify(r, s, h, P) where\n * U1 = hs^-1 mod n\n * U2 = rs^-1 mod n\n * R = U1⋅G - U2⋅P\n * mod(R.x, n) == r\n * ```\n */ function verify(signature, msgHash, publicKey, opts = defaultVerOpts) {\n const sg = signature;\n msgHash = (0, $esaJO.ensureBytes)('msgHash', msgHash);\n publicKey = (0, $esaJO.ensureBytes)('publicKey', publicKey);\n const { lowS: lowS, prehash: prehash, format: format } = opts;\n // Verify opts, deduce signature format\n $c3b91d553ab14e64$var$validateSigVerOpts(opts);\n if ('strict' in opts) throw new Error('options.strict was renamed to lowS');\n if (format !== undefined && format !== 'compact' && format !== 'der') throw new Error('format must be compact or der');\n const isHex = typeof sg === 'string' || $esaJO.isBytes(sg);\n const isObj = !isHex && !format && typeof sg === 'object' && sg !== null && typeof sg.r === 'bigint' && typeof sg.s === 'bigint';\n if (!isHex && !isObj) throw new Error('invalid signature, expected Uint8Array, hex string or Signature instance');\n let _sig = undefined;\n let P;\n try {\n if (isObj) _sig = new Signature(sg.r, sg.s);\n if (isHex) {\n // Signature can be represented in 2 ways: compact (2*nByteLength) & DER (variable-length).\n // Since DER can also be 2*nByteLength bytes, we check for it first.\n try {\n if (format !== 'compact') _sig = Signature.fromDER(sg);\n } catch (derError) {\n if (!(derError instanceof module.exports.DER.Err)) throw derError;\n }\n if (!_sig && format !== 'der') _sig = Signature.fromCompact(sg);\n }\n P = Point.fromHex(publicKey);\n } catch (error) {\n return false;\n }\n if (!_sig) return false;\n if (lowS && _sig.hasHighS()) return false;\n if (prehash) msgHash = CURVE.hash(msgHash);\n const { r: r, s: s } = _sig;\n const h = bits2int_modN(msgHash); // Cannot use fields methods, since it is group element\n const is = invN(s); // s^-1\n const u1 = modN(h * is); // u1 = hs^-1 mod n\n const u2 = modN(r * is); // u2 = rs^-1 mod n\n const R = Point.BASE.multiplyAndAddUnsafe(P, u1, u2)?.toAffine(); // R = u1⋅G + u2⋅P\n if (!R) return false;\n const v = modN(R.x);\n return v === r;\n }\n return {\n CURVE: CURVE,\n getPublicKey: getPublicKey,\n getSharedSecret: getSharedSecret,\n sign: sign,\n verify: verify,\n ProjectivePoint: Point,\n Signature: Signature,\n utils: utils\n };\n}\n/**\n * Implementation of the Shallue and van de Woestijne method for any weierstrass curve.\n * TODO: check if there is a way to merge this with uvRatio in Edwards; move to modular.\n * b = True and y = sqrt(u / v) if (u / v) is square in F, and\n * b = False and y = sqrt(Z * (u / v)) otherwise.\n * @param Fp\n * @param Z\n * @returns\n */ function $c3b91d553ab14e64$var$SWUFpSqrtRatio(Fp, Z) {\n // Generic implementation\n const q = Fp.ORDER;\n let l = $c3b91d553ab14e64$var$_0n;\n for(let o = q - $c3b91d553ab14e64$var$_1n; o % $c3b91d553ab14e64$var$_2n === $c3b91d553ab14e64$var$_0n; o /= $c3b91d553ab14e64$var$_2n)l += $c3b91d553ab14e64$var$_1n;\n const c1 = l; // 1. c1, the largest integer such that 2^c1 divides q - 1.\n // We need 2n ** c1 and 2n ** (c1-1). We can't use **; but we can use <<.\n // 2n ** c1 == 2n << (c1-1)\n const _2n_pow_c1_1 = $c3b91d553ab14e64$var$_2n << c1 - $c3b91d553ab14e64$var$_1n - $c3b91d553ab14e64$var$_1n;\n const _2n_pow_c1 = _2n_pow_c1_1 * $c3b91d553ab14e64$var$_2n;\n const c2 = (q - $c3b91d553ab14e64$var$_1n) / _2n_pow_c1; // 2. c2 = (q - 1) / (2^c1) # Integer arithmetic\n const c3 = (c2 - $c3b91d553ab14e64$var$_1n) / $c3b91d553ab14e64$var$_2n; // 3. c3 = (c2 - 1) / 2 # Integer arithmetic\n const c4 = _2n_pow_c1 - $c3b91d553ab14e64$var$_1n; // 4. c4 = 2^c1 - 1 # Integer arithmetic\n const c5 = _2n_pow_c1_1; // 5. c5 = 2^(c1 - 1) # Integer arithmetic\n const c6 = Fp.pow(Z, c2); // 6. c6 = Z^c2\n const c7 = Fp.pow(Z, (c2 + $c3b91d553ab14e64$var$_1n) / $c3b91d553ab14e64$var$_2n); // 7. c7 = Z^((c2 + 1) / 2)\n let sqrtRatio = (u, v)=>{\n let tv1 = c6; // 1. tv1 = c6\n let tv2 = Fp.pow(v, c4); // 2. tv2 = v^c4\n let tv3 = Fp.sqr(tv2); // 3. tv3 = tv2^2\n tv3 = Fp.mul(tv3, v); // 4. tv3 = tv3 * v\n let tv5 = Fp.mul(u, tv3); // 5. tv5 = u * tv3\n tv5 = Fp.pow(tv5, c3); // 6. tv5 = tv5^c3\n tv5 = Fp.mul(tv5, tv2); // 7. tv5 = tv5 * tv2\n tv2 = Fp.mul(tv5, v); // 8. tv2 = tv5 * v\n tv3 = Fp.mul(tv5, u); // 9. tv3 = tv5 * u\n let tv4 = Fp.mul(tv3, tv2); // 10. tv4 = tv3 * tv2\n tv5 = Fp.pow(tv4, c5); // 11. tv5 = tv4^c5\n let isQR = Fp.eql(tv5, Fp.ONE); // 12. isQR = tv5 == 1\n tv2 = Fp.mul(tv3, c7); // 13. tv2 = tv3 * c7\n tv5 = Fp.mul(tv4, tv1); // 14. tv5 = tv4 * tv1\n tv3 = Fp.cmov(tv2, tv3, isQR); // 15. tv3 = CMOV(tv2, tv3, isQR)\n tv4 = Fp.cmov(tv5, tv4, isQR); // 16. tv4 = CMOV(tv5, tv4, isQR)\n // 17. for i in (c1, c1 - 1, ..., 2):\n for(let i = c1; i > $c3b91d553ab14e64$var$_1n; i--){\n let tv5 = i - $c3b91d553ab14e64$var$_2n; // 18. tv5 = i - 2\n tv5 = $c3b91d553ab14e64$var$_2n << tv5 - $c3b91d553ab14e64$var$_1n; // 19. tv5 = 2^tv5\n let tvv5 = Fp.pow(tv4, tv5); // 20. tv5 = tv4^tv5\n const e1 = Fp.eql(tvv5, Fp.ONE); // 21. e1 = tv5 == 1\n tv2 = Fp.mul(tv3, tv1); // 22. tv2 = tv3 * tv1\n tv1 = Fp.mul(tv1, tv1); // 23. tv1 = tv1 * tv1\n tvv5 = Fp.mul(tv4, tv1); // 24. tv5 = tv4 * tv1\n tv3 = Fp.cmov(tv2, tv3, e1); // 25. tv3 = CMOV(tv2, tv3, e1)\n tv4 = Fp.cmov(tvv5, tv4, e1); // 26. tv4 = CMOV(tv5, tv4, e1)\n }\n return {\n isValid: isQR,\n value: tv3\n };\n };\n if (Fp.ORDER % $c3b91d553ab14e64$var$_4n === $c3b91d553ab14e64$var$_3n) {\n // sqrt_ratio_3mod4(u, v)\n const c1 = (Fp.ORDER - $c3b91d553ab14e64$var$_3n) / $c3b91d553ab14e64$var$_4n; // 1. c1 = (q - 3) / 4 # Integer arithmetic\n const c2 = Fp.sqrt(Fp.neg(Z)); // 2. c2 = sqrt(-Z)\n sqrtRatio = (u, v)=>{\n let tv1 = Fp.sqr(v); // 1. tv1 = v^2\n const tv2 = Fp.mul(u, v); // 2. tv2 = u * v\n tv1 = Fp.mul(tv1, tv2); // 3. tv1 = tv1 * tv2\n let y1 = Fp.pow(tv1, c1); // 4. y1 = tv1^c1\n y1 = Fp.mul(y1, tv2); // 5. y1 = y1 * tv2\n const y2 = Fp.mul(y1, c2); // 6. y2 = y1 * c2\n const tv3 = Fp.mul(Fp.sqr(y1), v); // 7. tv3 = y1^2; 8. tv3 = tv3 * v\n const isQR = Fp.eql(tv3, u); // 9. isQR = tv3 == u\n let y = Fp.cmov(y2, y1, isQR); // 10. y = CMOV(y2, y1, isQR)\n return {\n isValid: isQR,\n value: y\n }; // 11. return (isQR, y) isQR ? y : y*c2\n };\n }\n // No curves uses that\n // if (Fp.ORDER % _8n === _5n) // sqrt_ratio_5mod8\n return sqrtRatio;\n}\n/**\n * Simplified Shallue-van de Woestijne-Ulas Method\n * https://www.rfc-editor.org/rfc/rfc9380#section-6.6.2\n */ function $c3b91d553ab14e64$var$mapToCurveSimpleSWU(Fp, opts) {\n (0, $2D9sF.validateField)(Fp);\n if (!Fp.isValid(opts.A) || !Fp.isValid(opts.B) || !Fp.isValid(opts.Z)) throw new Error('mapToCurveSimpleSWU: invalid opts');\n const sqrtRatio = $c3b91d553ab14e64$var$SWUFpSqrtRatio(Fp, opts.Z);\n if (!Fp.isOdd) throw new Error('Fp.isOdd is not implemented!');\n // Input: u, an element of F.\n // Output: (x, y), a point on E.\n return (u)=>{\n // prettier-ignore\n let tv1, tv2, tv3, tv4, tv5, tv6, x, y;\n tv1 = Fp.sqr(u); // 1. tv1 = u^2\n tv1 = Fp.mul(tv1, opts.Z); // 2. tv1 = Z * tv1\n tv2 = Fp.sqr(tv1); // 3. tv2 = tv1^2\n tv2 = Fp.add(tv2, tv1); // 4. tv2 = tv2 + tv1\n tv3 = Fp.add(tv2, Fp.ONE); // 5. tv3 = tv2 + 1\n tv3 = Fp.mul(tv3, opts.B); // 6. tv3 = B * tv3\n tv4 = Fp.cmov(opts.Z, Fp.neg(tv2), !Fp.eql(tv2, Fp.ZERO)); // 7. tv4 = CMOV(Z, -tv2, tv2 != 0)\n tv4 = Fp.mul(tv4, opts.A); // 8. tv4 = A * tv4\n tv2 = Fp.sqr(tv3); // 9. tv2 = tv3^2\n tv6 = Fp.sqr(tv4); // 10. tv6 = tv4^2\n tv5 = Fp.mul(tv6, opts.A); // 11. tv5 = A * tv6\n tv2 = Fp.add(tv2, tv5); // 12. tv2 = tv2 + tv5\n tv2 = Fp.mul(tv2, tv3); // 13. tv2 = tv2 * tv3\n tv6 = Fp.mul(tv6, tv4); // 14. tv6 = tv6 * tv4\n tv5 = Fp.mul(tv6, opts.B); // 15. tv5 = B * tv6\n tv2 = Fp.add(tv2, tv5); // 16. tv2 = tv2 + tv5\n x = Fp.mul(tv1, tv3); // 17. x = tv1 * tv3\n const { isValid: isValid, value: value } = sqrtRatio(tv2, tv6); // 18. (is_gx1_square, y1) = sqrt_ratio(tv2, tv6)\n y = Fp.mul(tv1, u); // 19. y = tv1 * u -> Z * u^3 * y1\n y = Fp.mul(y, value); // 20. y = y * y1\n x = Fp.cmov(x, tv3, isValid); // 21. x = CMOV(x, tv3, is_gx1_square)\n y = Fp.cmov(y, value, isValid); // 22. y = CMOV(y, y1, is_gx1_square)\n const e1 = Fp.isOdd(u) === Fp.isOdd(y); // 23. e1 = sgn0(u) == sgn0(y)\n y = Fp.cmov(Fp.neg(y), y, e1); // 24. y = CMOV(-y, y, e1)\n x = Fp.div(x, tv4); // 25. x = x / tv4\n return {\n x: x,\n y: y\n };\n };\n}\n\n});\n\n\n\n\nparcelRegister(\"iJxGt\", function(module, exports) {\n\n$parcel$export(module.exports, \"SolanaSignAndSendTransaction\", () => $da368ee8f406d58d$export$dd64f32469f35f81);\n/** Name of the feature. */ const $da368ee8f406d58d$export$dd64f32469f35f81 = 'solana:signAndSendTransaction';\n\n});\n\nparcelRegister(\"7KE4n\", function(module, exports) {\n\n$parcel$export(module.exports, \"SolanaSignMessage\", () => $5a4be9421d6e6c61$export$22c7939a38084172);\n/** Name of the feature. */ const $5a4be9421d6e6c61$export$22c7939a38084172 = 'solana:signMessage';\n\n});\n\nparcelRegister(\"d2raY\", function(module, exports) {\n\n$parcel$export(module.exports, \"SolanaSignTransaction\", () => $97e08ae06ec466db$export$54187c3796d0ecb);\n/** Name of the feature. */ const $97e08ae06ec466db$export$54187c3796d0ecb = 'solana:signTransaction';\n\n});\n\nparcelRegister(\"fSpOt\", function(module, exports) {\n\nvar $Gr8vk = parcelRequire(\"Gr8vk\");\nmodule.exports = $Gr8vk(\"lHJg1\").then(()=>parcelRequire('3lp4m'));\n\n});\nparcelRegister(\"Gr8vk\", function(module, exports) {\n\"use strict\";\n\nfunction $07f8f9093a769793$var$load(id) {\n // eslint-disable-next-line no-undef\n return import((parcelRequire(\"27Lyk\")).resolve(id));\n}\nmodule.exports = $07f8f9093a769793$var$load;\n\n});\n\n\nparcelRegister(\"hSLYn\", function(module, exports) {\n\nvar $Gr8vk = parcelRequire(\"Gr8vk\");\nmodule.exports = $Gr8vk(\"2Wmvo\").then(()=>parcelRequire('8VMga'));\n\n});\n\nvar $7838cb9756bfe4d4$exports = {};\n\n(parcelRequire(\"27Lyk\")).register(new URL(\"\", import.meta.url).toString(), JSON.parse(\"[\\\"lWpsB\\\",\\\"index.5c102541.js\\\",\\\"lHJg1\\\",\\\"esm.f2712bf6.js\\\",\\\"2Wmvo\\\",\\\"esm.9a35aeda.js\\\"]\"));\n\nvar $28edd11f6c7e9f5f$exports = {};\n'use strict';\nvar $28edd11f6c7e9f5f$var$has = Object.prototype.hasOwnProperty, $28edd11f6c7e9f5f$var$prefix = '~';\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @private\n */ function $28edd11f6c7e9f5f$var$Events() {}\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n $28edd11f6c7e9f5f$var$Events.prototype = Object.create(null);\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new $28edd11f6c7e9f5f$var$Events().__proto__) $28edd11f6c7e9f5f$var$prefix = false;\n}\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @private\n */ function $28edd11f6c7e9f5f$var$EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n/**\n * Add a listener for a given event.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} once Specify if the listener is a one-time listener.\n * @returns {EventEmitter}\n * @private\n */ function $28edd11f6c7e9f5f$var$addListener(emitter, event, fn, context, once) {\n if (typeof fn !== 'function') throw new TypeError('The listener must be a function');\n var listener = new $28edd11f6c7e9f5f$var$EE(fn, context || emitter, once), evt = $28edd11f6c7e9f5f$var$prefix ? $28edd11f6c7e9f5f$var$prefix + event : event;\n if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;\n else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);\n else emitter._events[evt] = [\n emitter._events[evt],\n listener\n ];\n return emitter;\n}\n/**\n * Clear event by name.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} evt The Event name.\n * @private\n */ function $28edd11f6c7e9f5f$var$clearEvent(emitter, evt) {\n if (--emitter._eventsCount === 0) emitter._events = new $28edd11f6c7e9f5f$var$Events();\n else delete emitter._events[evt];\n}\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @public\n */ function $28edd11f6c7e9f5f$var$EventEmitter() {\n this._events = new $28edd11f6c7e9f5f$var$Events();\n this._eventsCount = 0;\n}\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @public\n */ $28edd11f6c7e9f5f$var$EventEmitter.prototype.eventNames = function eventNames() {\n var names = [], events, name;\n if (this._eventsCount === 0) return names;\n for(name in events = this._events)if ($28edd11f6c7e9f5f$var$has.call(events, name)) names.push($28edd11f6c7e9f5f$var$prefix ? name.slice(1) : name);\n if (Object.getOwnPropertySymbols) return names.concat(Object.getOwnPropertySymbols(events));\n return names;\n};\n/**\n * Return the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Array} The registered listeners.\n * @public\n */ $28edd11f6c7e9f5f$var$EventEmitter.prototype.listeners = function listeners(event) {\n var evt = $28edd11f6c7e9f5f$var$prefix ? $28edd11f6c7e9f5f$var$prefix + event : event, handlers = this._events[evt];\n if (!handlers) return [];\n if (handlers.fn) return [\n handlers.fn\n ];\n for(var i = 0, l = handlers.length, ee = new Array(l); i < l; i++)ee[i] = handlers[i].fn;\n return ee;\n};\n/**\n * Return the number of listeners listening to a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Number} The number of listeners.\n * @public\n */ $28edd11f6c7e9f5f$var$EventEmitter.prototype.listenerCount = function listenerCount(event) {\n var evt = $28edd11f6c7e9f5f$var$prefix ? $28edd11f6c7e9f5f$var$prefix + event : event, listeners = this._events[evt];\n if (!listeners) return 0;\n if (listeners.fn) return 1;\n return listeners.length;\n};\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @public\n */ $28edd11f6c7e9f5f$var$EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = $28edd11f6c7e9f5f$var$prefix ? $28edd11f6c7e9f5f$var$prefix + event : event;\n if (!this._events[evt]) return false;\n var listeners = this._events[evt], len = arguments.length, args, i;\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n switch(len){\n case 1:\n return listeners.fn.call(listeners.context), true;\n case 2:\n return listeners.fn.call(listeners.context, a1), true;\n case 3:\n return listeners.fn.call(listeners.context, a1, a2), true;\n case 4:\n return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5:\n return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6:\n return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n for(i = 1, args = new Array(len - 1); i < len; i++)args[i - 1] = arguments[i];\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length, j;\n for(i = 0; i < length; i++){\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n switch(len){\n case 1:\n listeners[i].fn.call(listeners[i].context);\n break;\n case 2:\n listeners[i].fn.call(listeners[i].context, a1);\n break;\n case 3:\n listeners[i].fn.call(listeners[i].context, a1, a2);\n break;\n case 4:\n listeners[i].fn.call(listeners[i].context, a1, a2, a3);\n break;\n default:\n if (!args) for(j = 1, args = new Array(len - 1); j < len; j++)args[j - 1] = arguments[j];\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n return true;\n};\n/**\n * Add a listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */ $28edd11f6c7e9f5f$var$EventEmitter.prototype.on = function on(event, fn, context) {\n return $28edd11f6c7e9f5f$var$addListener(this, event, fn, context, false);\n};\n/**\n * Add a one-time listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */ $28edd11f6c7e9f5f$var$EventEmitter.prototype.once = function once(event, fn, context) {\n return $28edd11f6c7e9f5f$var$addListener(this, event, fn, context, true);\n};\n/**\n * Remove the listeners of a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {*} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @public\n */ $28edd11f6c7e9f5f$var$EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = $28edd11f6c7e9f5f$var$prefix ? $28edd11f6c7e9f5f$var$prefix + event : event;\n if (!this._events[evt]) return this;\n if (!fn) {\n $28edd11f6c7e9f5f$var$clearEvent(this, evt);\n return this;\n }\n var listeners = this._events[evt];\n if (listeners.fn) {\n if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) $28edd11f6c7e9f5f$var$clearEvent(this, evt);\n } else {\n for(var i = 0, events = [], length = listeners.length; i < length; i++)if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) events.push(listeners[i]);\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else $28edd11f6c7e9f5f$var$clearEvent(this, evt);\n }\n return this;\n};\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {(String|Symbol)} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @public\n */ $28edd11f6c7e9f5f$var$EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n if (event) {\n evt = $28edd11f6c7e9f5f$var$prefix ? $28edd11f6c7e9f5f$var$prefix + event : event;\n if (this._events[evt]) $28edd11f6c7e9f5f$var$clearEvent(this, evt);\n } else {\n this._events = new $28edd11f6c7e9f5f$var$Events();\n this._eventsCount = 0;\n }\n return this;\n};\n//\n// Alias methods names because people roll like that.\n//\n$28edd11f6c7e9f5f$var$EventEmitter.prototype.off = $28edd11f6c7e9f5f$var$EventEmitter.prototype.removeListener;\n$28edd11f6c7e9f5f$var$EventEmitter.prototype.addListener = $28edd11f6c7e9f5f$var$EventEmitter.prototype.on;\n//\n// Expose the prefix.\n//\n$28edd11f6c7e9f5f$var$EventEmitter.prefixed = $28edd11f6c7e9f5f$var$prefix;\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\n$28edd11f6c7e9f5f$var$EventEmitter.EventEmitter = $28edd11f6c7e9f5f$var$EventEmitter;\n$28edd11f6c7e9f5f$exports = $28edd11f6c7e9f5f$var$EventEmitter;\n\n\nclass $92c515b2e16b5c4e$export$f46ec6f9dba8711d extends Error {\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n constructor(message, error){\n super(message);\n this.error = error;\n }\n}\nclass $92c515b2e16b5c4e$export$d65db264eda99cd7 extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletNotReadyError';\n }\n}\nclass $92c515b2e16b5c4e$export$9a551f94af9b0bf8 extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletLoadError';\n }\n}\nclass $92c515b2e16b5c4e$export$9525019988612a5e extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletConfigError';\n }\n}\nclass $92c515b2e16b5c4e$export$38f21f1c810261c7 extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletConnectionError';\n }\n}\nclass $92c515b2e16b5c4e$export$bf7028c52ebda81e extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletDisconnectedError';\n }\n}\nclass $92c515b2e16b5c4e$export$92e2b26fad5723ee extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletDisconnectionError';\n }\n}\nclass $92c515b2e16b5c4e$export$cd6fa2f8e2a8a612 extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletAccountError';\n }\n}\nclass $92c515b2e16b5c4e$export$735bef3bfb0f2c86 extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletPublicKeyError';\n }\n}\nclass $92c515b2e16b5c4e$export$c2957028686b1575 extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletKeypairError';\n }\n}\nclass $92c515b2e16b5c4e$export$313d299817c74896 extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletNotConnectedError';\n }\n}\nclass $92c515b2e16b5c4e$export$769332ac3f90f46c extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletSendTransactionError';\n }\n}\nclass $92c515b2e16b5c4e$export$96f177062fdd8180 extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletSignTransactionError';\n }\n}\nclass $92c515b2e16b5c4e$export$2622c1721bbd4b17 extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletSignMessageError';\n }\n}\nclass $92c515b2e16b5c4e$export$a4c7d3c66e3cdd6c extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletSignInError';\n }\n}\nclass $92c515b2e16b5c4e$export$ec3efbdc71ef5c8c extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletTimeoutError';\n }\n}\nclass $92c515b2e16b5c4e$export$c87b9320dc154c95 extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletWindowBlockedError';\n }\n}\nclass $92c515b2e16b5c4e$export$d02b2d00a97edcea extends $92c515b2e16b5c4e$export$f46ec6f9dba8711d {\n constructor(){\n super(...arguments);\n this.name = 'WalletWindowClosedError';\n }\n}\n\n\nvar $a27aaf340df890aa$export$2a7b8071105d05b6;\n(function(WalletReadyState) {\n /**\n * User-installable wallets can typically be detected by scanning for an API\n * that they've injected into the global context. If such an API is present,\n * we consider the wallet to have been installed.\n */ WalletReadyState[\"Installed\"] = \"Installed\";\n WalletReadyState[\"NotDetected\"] = \"NotDetected\";\n /**\n * Loadable wallets are always available to you. Since you can load them at\n * any time, it's meaningless to say that they have been detected.\n */ WalletReadyState[\"Loadable\"] = \"Loadable\";\n /**\n * If a wallet is not supported on a given platform (eg. server-rendering, or\n * mobile) then it will stay in the `Unsupported` state.\n */ WalletReadyState[\"Unsupported\"] = \"Unsupported\";\n})($a27aaf340df890aa$export$2a7b8071105d05b6 || ($a27aaf340df890aa$export$2a7b8071105d05b6 = {}));\nclass $a27aaf340df890aa$export$2af1ea2892adc469 extends (0, (/*@__PURE__*/$parcel$interopDefault($28edd11f6c7e9f5f$exports))) {\n get connected() {\n return !!this.publicKey;\n }\n async autoConnect() {\n await this.connect();\n }\n async prepareTransaction(transaction, connection, options = {}) {\n const publicKey = this.publicKey;\n if (!publicKey) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n transaction.feePayer = transaction.feePayer || publicKey;\n transaction.recentBlockhash = transaction.recentBlockhash || (await connection.getLatestBlockhash({\n commitment: options.preflightCommitment,\n minContextSlot: options.minContextSlot\n })).blockhash;\n return transaction;\n }\n}\nfunction $a27aaf340df890aa$export$378bae4c88e0b46e(detect) {\n // Early return when server-side rendering\n if (typeof window === 'undefined' || typeof document === 'undefined') return;\n const disposers = [];\n function detectAndDispose() {\n const detected = detect();\n if (detected) for (const dispose of disposers)dispose();\n }\n // Strategy #1: Try detecting every second.\n const interval = // TODO: #334 Replace with idle callback strategy.\n setInterval(detectAndDispose, 1000);\n disposers.push(()=>clearInterval(interval));\n // Strategy #2: Detect as soon as the DOM becomes 'ready'/'interactive'.\n if (// Implies that `DOMContentLoaded` has not yet fired.\n document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', detectAndDispose, {\n once: true\n });\n disposers.push(()=>document.removeEventListener('DOMContentLoaded', detectAndDispose));\n }\n // Strategy #3: Detect after the `window` has fully loaded.\n if (// If the `complete` state has been reached, we're too late.\n document.readyState !== 'complete') {\n window.addEventListener('load', detectAndDispose, {\n once: true\n });\n disposers.push(()=>window.removeEventListener('load', detectAndDispose));\n }\n // Strategy #4: Detect synchronously, now.\n detectAndDispose();\n}\nfunction $a27aaf340df890aa$export$bf89b558d1e273a2() {\n // SSR: return false\n if (!navigator) return false;\n const userAgent = navigator.userAgent.toLowerCase();\n // if on iOS the user agent will contain either iPhone or iPad\n // caveat: if requesting desktop site then this won't work\n const isIos = userAgent.includes('iphone') || userAgent.includes('ipad');\n // if in a webview then it will not include Safari\n // note that other iOS browsers also include Safari\n // so we will redirect only if Safari is also included\n const isSafari = userAgent.includes('safari');\n return isIos && isSafari;\n}\n\n\n\nfunction $afa5c06c212ba160$export$37ce1cc82e255d8(transaction) {\n return 'version' in transaction;\n}\n\n\nclass $71b3859dfb523e38$export$9a51bf5d1bea9e98 extends (0, $a27aaf340df890aa$export$2af1ea2892adc469) {\n async sendTransaction(transaction, connection, options = {}) {\n let emit = true;\n try {\n if ((0, $afa5c06c212ba160$export$37ce1cc82e255d8)(transaction)) {\n if (!this.supportedTransactionVersions) throw new (0, $92c515b2e16b5c4e$export$769332ac3f90f46c)(`Sending versioned transactions isn't supported by this wallet`);\n if (!this.supportedTransactionVersions.has(transaction.version)) throw new (0, $92c515b2e16b5c4e$export$769332ac3f90f46c)(`Sending transaction version ${transaction.version} isn't supported by this wallet`);\n try {\n transaction = await this.signTransaction(transaction);\n const rawTransaction = transaction.serialize();\n return await connection.sendRawTransaction(rawTransaction, options);\n } catch (error) {\n // If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event\n if (error instanceof (0, $92c515b2e16b5c4e$export$96f177062fdd8180)) {\n emit = false;\n throw error;\n }\n throw new (0, $92c515b2e16b5c4e$export$769332ac3f90f46c)(error?.message, error);\n }\n } else try {\n const { signers: signers, ...sendOptions } = options;\n transaction = await this.prepareTransaction(transaction, connection, sendOptions);\n signers?.length && transaction.partialSign(...signers);\n transaction = await this.signTransaction(transaction);\n const rawTransaction = transaction.serialize();\n return await connection.sendRawTransaction(rawTransaction, sendOptions);\n } catch (error) {\n // If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event\n if (error instanceof (0, $92c515b2e16b5c4e$export$96f177062fdd8180)) {\n emit = false;\n throw error;\n }\n throw new (0, $92c515b2e16b5c4e$export$769332ac3f90f46c)(error?.message, error);\n }\n } catch (error) {\n if (emit) this.emit('error', error);\n throw error;\n }\n }\n async signAllTransactions(transactions) {\n for (const transaction of transactions)if ((0, $afa5c06c212ba160$export$37ce1cc82e255d8)(transaction)) {\n if (!this.supportedTransactionVersions) throw new (0, $92c515b2e16b5c4e$export$96f177062fdd8180)(`Signing versioned transactions isn't supported by this wallet`);\n if (!this.supportedTransactionVersions.has(transaction.version)) throw new (0, $92c515b2e16b5c4e$export$96f177062fdd8180)(`Signing transaction version ${transaction.version} isn't supported by this wallet`);\n }\n const signedTransactions = [];\n for (const transaction of transactions)signedTransactions.push(await this.signTransaction(transaction));\n return signedTransactions;\n }\n}\nclass $71b3859dfb523e38$export$9db08bcddd106c96 extends $71b3859dfb523e38$export$9a51bf5d1bea9e98 {\n}\nclass $71b3859dfb523e38$export$9779f871ffdb3d87 extends $71b3859dfb523e38$export$9db08bcddd106c96 {\n}\n\n\n\nvar $gNDby = parcelRequire(\"gNDby\");\nconst $35fb31345295b098$export$c094e79b0fad9c07 = 'Backpack';\nclass $35fb31345295b098$export$9c8fcf9b2dfe1d6a extends (0, $71b3859dfb523e38$export$9db08bcddd106c96) {\n constructor(config = {}){\n super();\n this.name = $35fb31345295b098$export$c094e79b0fad9c07;\n this.url = 'https://backpack.app';\n this.icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAbvSURBVHgB7Z1dUtxGEMf/LZH3fU0V4PUJQg4QVj5BnBOAT2BzAsMJAicwPoHJCRDrAxifgLVxVV73ObDqdEtsjKn4C8+0NDv9e7AxprRC85uvnp4RYYW5qKpxCVTcYKsgfiDfGjMwIsZIvh7d/lkmzAiYy5fzhultyZhdlagf1vU5VhjCiiGFXq01zYSJdqWgx/hB5AHN5I/6iuilyFBjxVgZAdqCZ34ORoVIqAzSOhxsvq6PsSIkL4A281LwL2IW/F1UhLKgRz/X9QyJUyBhuuae31gWviLjiPF1wxeX29vPkTjJtgAftrd3GHSMnmHw4eZ0uodESVKAoRT+kpQlSE6Ats/XZv/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3cbRaOjLRzDXnKZVj9GBIILUJBtbVzyj9HAU19AgR6I9VzDtwCgMXpAo2Yxp0v/Ybi49ennJtIFEPMY/TCKHTvv+aTSUQzBgwrQ92YHbQVi3UN3GAVZhrf/jzECE1SAq/7n4yOJ074KPSBcJoii598vxgwrqAByg70HZJZbr0JJ0G5XZz5Z1e1rYccA5TAicqEk0O5ECl/3LvYys7mLTLHHCEzS7wz6Esv3+nyYTF58rwha63XAl8PG1aCnhesWq6EdOcKM3WvmXRHh+Gvv/tNVTJlJPC4a3RVEK72+sCSZ4+J/FBVhTUS43J7gJqFjrnl33A3sxtCa3nAWhX6bbAT4hJugCsNZ2TGA8224AJnjAmSOC5A5LkDmuACZ4wJkjguQOS5A5rgAmeMCZI4LkDkuQOa4AJnjAmSOC5A5LkDmuACZ4wJkjguQOWEFYJvz85xwBBWgKM1P68oKKsI/36ACdC9nsDlWPTsIJ5t1Hfw01OBjgI1p/YwLegIibw0CwESz9gUYZ2d/wHEcx3Ecx3Ecx3Ecx3HuS5QjfdrXxTHv3JzEkd2xKwHR9xPNuKGjzdf1MSIQXAA9XUsuuw8nKPpK3PWzs+AvrgwqgP1LojOjoEf3fRv6Zy+JgBSLOGfaOx1NE/6o+rCrgeT9fWp4SljmuACZ4wJkjguQOS5A5rgAmeMCZI4LkDkuQOa4AJnjAmSOC5A5LkDmuACZ4wJkjguQOS5A5rgAmeMCZI4LkDkuQOa4AJnj5wRmTlABqHQBohKhggUVYAEEP8fO+UiMgziDCvCwrnU3aw0nOATMQu8LVIIPAq+JdAerdwWBaQ/fjEBwAaQVmMnN7sEJCB3EqP3tlRGJy6qqmPkFMcZw7sucmfZiHQ6hRBNgSXdaCHbA7KeFfBvz9pxlxtl1gcN2XBWRfwHK959XFRG6AgAAAABJRU5ErkJggg==';\n this.supportedTransactionVersions = null;\n this._readyState = typeof window === 'undefined' || typeof document === 'undefined' ? (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Unsupported : (0, $a27aaf340df890aa$export$2a7b8071105d05b6).NotDetected;\n this._disconnected = ()=>{\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n this._wallet = null;\n this._publicKey = null;\n this.emit('error', new (0, $92c515b2e16b5c4e$export$bf7028c52ebda81e)());\n this.emit('disconnect');\n }\n };\n this._connecting = false;\n this._wallet = null;\n this._publicKey = null;\n if (this._readyState !== (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Unsupported) (0, $a27aaf340df890aa$export$378bae4c88e0b46e)(()=>{\n if (window.backpack?.isBackpack) {\n this._readyState = (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Installed;\n this.emit('readyStateChange', this._readyState);\n return true;\n }\n return false;\n });\n }\n get publicKey() {\n return this._publicKey;\n }\n get connecting() {\n return this._connecting;\n }\n get connected() {\n return !!this._wallet?.isConnected;\n }\n get readyState() {\n return this._readyState;\n }\n async connect() {\n try {\n if (this.connected || this.connecting) return;\n if (this._readyState !== (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Installed) throw new (0, $92c515b2e16b5c4e$export$d65db264eda99cd7)();\n this._connecting = true;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const wallet = window.backpack;\n try {\n await wallet.connect();\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$38f21f1c810261c7)(error?.message, error);\n }\n if (!wallet.publicKey) throw new (0, $92c515b2e16b5c4e$export$cd6fa2f8e2a8a612)();\n let publicKey;\n try {\n publicKey = new (0, $gNDby.PublicKey)(wallet.publicKey.toBytes());\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$735bef3bfb0f2c86)(error?.message, error);\n }\n wallet.on('disconnect', this._disconnected);\n this._wallet = wallet;\n this._publicKey = publicKey;\n this.emit('connect', publicKey);\n } catch (error) {\n this.emit('error', error);\n throw error;\n } finally{\n this._connecting = false;\n }\n }\n async disconnect() {\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n this._wallet = null;\n this._publicKey = null;\n try {\n await wallet.disconnect();\n } catch (error) {\n this.emit('error', new (0, $92c515b2e16b5c4e$export$92e2b26fad5723ee)(error?.message, error));\n }\n }\n this.emit('disconnect');\n }\n async sendTransaction(transaction, connection, options = {}) {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n const { signers: signers, ...sendOptions } = options;\n try {\n return await wallet.send(transaction, signers, sendOptions, connection, this.publicKey);\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$769332ac3f90f46c)(error?.message, error);\n }\n } catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signTransaction(transaction) {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n try {\n return await wallet.signTransaction(transaction, this.publicKey);\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$96f177062fdd8180)(error?.message, error);\n }\n } catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signAllTransactions(transactions) {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n try {\n return await wallet.signAllTransactions(transactions, this.publicKey);\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$96f177062fdd8180)(error?.message, error);\n }\n } catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signMessage(message) {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n try {\n return await wallet.signMessage(message, this.publicKey);\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$2622c1721bbd4b17)(error?.message, error);\n }\n } catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n}\n\n\n\nvar $gNDby = parcelRequire(\"gNDby\");\nconst $27b337e06adc69ec$export$37766f30d842581a = 'Phantom';\nclass $27b337e06adc69ec$export$a8fff984faa686f6 extends (0, $71b3859dfb523e38$export$9db08bcddd106c96) {\n constructor(config = {}){\n super();\n this.name = $27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uOTY1OCA3NC42OTg5IDQ2LjE3MDQgNzQuNjk4OSA0Mi41Nzk0Qzc0LjY5ODkgMzguOTg4NSA3Ni43ODE2IDM3LjE5MzEgNzkuMTg3NSAzNy4xOTMxQzgxLjU1NzUgMzcuMTkzMSA4My42NzYxIDM4Ljk4ODUgODMuNjc2MSA0Mi41Nzk0Wk03MC4yMTAzIDQyLjU3OTVDNzAuMjEwMyA0Ni4xNzA0IDY4LjA5MTYgNDcuOTY1OCA2NS43MjE2IDQ3Ljk2NThDNjMuMzE1NyA0Ny45NjU4IDYxLjIzMyA0Ni4xNzA0IDYxLjIzMyA0Mi41Nzk1QzYxLjIzMyAzOC45ODg1IDYzLjMxNTcgMzcuMTkzMSA2NS43MjE2IDM3LjE5MzFDNjguMDkxNiAzNy4xOTMxIDcwLjIxMDMgMzguOTg4NSA3MC4yMTAzIDQyLjU3OTVaIiBmaWxsPSIjRkZGREY4Ii8+Cjwvc3ZnPg==';\n this.supportedTransactionVersions = new Set([\n 'legacy',\n 0\n ]);\n this._readyState = typeof window === 'undefined' || typeof document === 'undefined' ? (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Unsupported : (0, $a27aaf340df890aa$export$2a7b8071105d05b6).NotDetected;\n this._disconnected = ()=>{\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n wallet.off('accountChanged', this._accountChanged);\n this._wallet = null;\n this._publicKey = null;\n this.emit('error', new (0, $92c515b2e16b5c4e$export$bf7028c52ebda81e)());\n this.emit('disconnect');\n }\n };\n this._accountChanged = (newPublicKey)=>{\n const publicKey = this._publicKey;\n if (!publicKey) return;\n try {\n newPublicKey = new (0, $gNDby.PublicKey)(newPublicKey.toBytes());\n } catch (error) {\n this.emit('error', new (0, $92c515b2e16b5c4e$export$735bef3bfb0f2c86)(error?.message, error));\n return;\n }\n if (publicKey.equals(newPublicKey)) return;\n this._publicKey = newPublicKey;\n this.emit('connect', newPublicKey);\n };\n this._connecting = false;\n this._wallet = null;\n this._publicKey = null;\n if (this._readyState !== (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Unsupported) {\n if ((0, $a27aaf340df890aa$export$bf89b558d1e273a2)()) {\n // when in iOS (not webview), set Phantom as loadable instead of checking for install\n this._readyState = (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Loadable;\n this.emit('readyStateChange', this._readyState);\n } else (0, $a27aaf340df890aa$export$378bae4c88e0b46e)(()=>{\n if (window.phantom?.solana?.isPhantom || window.solana?.isPhantom) {\n this._readyState = (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Installed;\n this.emit('readyStateChange', this._readyState);\n return true;\n }\n return false;\n });\n }\n }\n get publicKey() {\n return this._publicKey;\n }\n get connecting() {\n return this._connecting;\n }\n get readyState() {\n return this._readyState;\n }\n async autoConnect() {\n // Skip autoconnect in the Loadable state\n // We can't redirect to a universal link without user input\n if (this.readyState === (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Installed) await this.connect();\n }\n async connect() {\n try {\n if (this.connected || this.connecting) return;\n if (this.readyState === (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Loadable) {\n // redirect to the Phantom /browse universal link\n // this will open the current URL in the Phantom in-wallet browser\n const url = encodeURIComponent(window.location.href);\n const ref = encodeURIComponent(window.location.origin);\n window.location.href = `https://phantom.app/ul/browse/${url}?ref=${ref}`;\n return;\n }\n if (this.readyState !== (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Installed) throw new (0, $92c515b2e16b5c4e$export$d65db264eda99cd7)();\n this._connecting = true;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const wallet = window.phantom?.solana || window.solana;\n if (!wallet.isConnected) try {\n await wallet.connect();\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$38f21f1c810261c7)(error?.message, error);\n }\n if (!wallet.publicKey) throw new (0, $92c515b2e16b5c4e$export$cd6fa2f8e2a8a612)();\n let publicKey;\n try {\n publicKey = new (0, $gNDby.PublicKey)(wallet.publicKey.toBytes());\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$735bef3bfb0f2c86)(error?.message, error);\n }\n wallet.on('disconnect', this._disconnected);\n wallet.on('accountChanged', this._accountChanged);\n this._wallet = wallet;\n this._publicKey = publicKey;\n this.emit('connect', publicKey);\n } catch (error) {\n this.emit('error', error);\n throw error;\n } finally{\n this._connecting = false;\n }\n }\n async disconnect() {\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n wallet.off('accountChanged', this._accountChanged);\n this._wallet = null;\n this._publicKey = null;\n try {\n await wallet.disconnect();\n } catch (error) {\n this.emit('error', new (0, $92c515b2e16b5c4e$export$92e2b26fad5723ee)(error?.message, error));\n }\n }\n this.emit('disconnect');\n }\n async sendTransaction(transaction, connection, options = {}) {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n try {\n const { signers: signers, ...sendOptions } = options;\n if ((0, $afa5c06c212ba160$export$37ce1cc82e255d8)(transaction)) signers?.length && transaction.sign(signers);\n else {\n transaction = await this.prepareTransaction(transaction, connection, sendOptions);\n signers?.length && transaction.partialSign(...signers);\n }\n sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment;\n const { signature: signature } = await wallet.signAndSendTransaction(transaction, sendOptions);\n return signature;\n } catch (error) {\n if (error instanceof (0, $92c515b2e16b5c4e$export$f46ec6f9dba8711d)) throw error;\n throw new (0, $92c515b2e16b5c4e$export$769332ac3f90f46c)(error?.message, error);\n }\n } catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signTransaction(transaction) {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n try {\n return await wallet.signTransaction(transaction) || transaction;\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$96f177062fdd8180)(error?.message, error);\n }\n } catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signAllTransactions(transactions) {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n try {\n return await wallet.signAllTransactions(transactions) || transactions;\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$96f177062fdd8180)(error?.message, error);\n }\n } catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signMessage(message) {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n try {\n const { signature: signature } = await wallet.signMessage(message);\n return signature;\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$2622c1721bbd4b17)(error?.message, error);\n }\n } catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n}\n\n\n\nvar $gNDby = parcelRequire(\"gNDby\");\nvar $aff560f1983590b4$var$__classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n};\nvar $aff560f1983590b4$var$__classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;\n};\nvar $aff560f1983590b4$var$_RegisterWalletEvent_detail;\nfunction $aff560f1983590b4$export$ecffa18c0543eceb(wallet) {\n const callback = ({ register: register })=>register(wallet);\n try {\n window.dispatchEvent(new $aff560f1983590b4$var$RegisterWalletEvent(callback));\n } catch (error) {\n console.error('wallet-standard:register-wallet event could not be dispatched\\n', error);\n }\n try {\n window.addEventListener('wallet-standard:app-ready', ({ detail: api })=>callback(api));\n } catch (error) {\n console.error('wallet-standard:app-ready event listener could not be added\\n', error);\n }\n}\nclass $aff560f1983590b4$var$RegisterWalletEvent extends Event {\n get detail() {\n return $aff560f1983590b4$var$__classPrivateFieldGet(this, $aff560f1983590b4$var$_RegisterWalletEvent_detail, \"f\");\n }\n get type() {\n return 'wallet-standard:register-wallet';\n }\n constructor(callback){\n super('wallet-standard:register-wallet', {\n bubbles: false,\n cancelable: false,\n composed: false\n });\n $aff560f1983590b4$var$_RegisterWalletEvent_detail.set(this, void 0);\n $aff560f1983590b4$var$__classPrivateFieldSet(this, $aff560f1983590b4$var$_RegisterWalletEvent_detail, callback, \"f\");\n }\n /** @deprecated */ preventDefault() {\n throw new Error('preventDefault cannot be called');\n }\n /** @deprecated */ stopImmediatePropagation() {\n throw new Error('stopImmediatePropagation cannot be called');\n }\n /** @deprecated */ stopPropagation() {\n throw new Error('stopPropagation cannot be called');\n }\n}\n$aff560f1983590b4$var$_RegisterWalletEvent_detail = new WeakMap();\nfunction $aff560f1983590b4$export$2dd0e8edbdeb04ec(wallet) {\n var _a;\n $aff560f1983590b4$export$ecffa18c0543eceb(wallet);\n try {\n ((_a = window.navigator).wallets || (_a.wallets = [])).push(({ register: register })=>register(wallet));\n } catch (error) {\n console.error('window.navigator.wallets could not be pushed\\n', error);\n }\n}\n\n\n\n/** Solana Mainnet (beta) cluster, e.g. https://api.mainnet-beta.solana.com */ const $54a90126d2f96ce7$export$bba9a228295b3963 = 'solana:mainnet';\nconst $54a90126d2f96ce7$export$654cc095bd2e650 = 'solana:devnet';\nconst $54a90126d2f96ce7$export$76575b7bf4de1f40 = 'solana:testnet';\nconst $54a90126d2f96ce7$export$483699a75281444c = 'solana:localnet';\nconst $54a90126d2f96ce7$export$d77e7f94b1f6bf7d = [\n $54a90126d2f96ce7$export$bba9a228295b3963,\n $54a90126d2f96ce7$export$654cc095bd2e650,\n $54a90126d2f96ce7$export$76575b7bf4de1f40,\n $54a90126d2f96ce7$export$483699a75281444c\n];\nfunction $54a90126d2f96ce7$export$d8f86f4d3d9fc2b5(chain) {\n return $54a90126d2f96ce7$export$d77e7f94b1f6bf7d.includes(chain);\n}\n\n\n\nvar $iJxGt = parcelRequire(\"iJxGt\");\nvar $7KE4n = parcelRequire(\"7KE4n\");\nvar $d2raY = parcelRequire(\"d2raY\");\n/** Name of the feature. */ const $744408f28809a335$export$cc68487eeb93b1d4 = 'standard:connect';\nconst $744408f28809a335$export$59e6910693f047c2 = $744408f28809a335$export$cc68487eeb93b1d4;\n\n/** Name of the feature. */ const $393285782087969c$export$38dbd4bbb9b696e6 = 'standard:disconnect';\nconst $393285782087969c$export$9e282393ab352bcd = $393285782087969c$export$38dbd4bbb9b696e6;\n\n/** Name of the feature. */ const $f4859eee1867cbdd$export$5296443ca9e9fa0f = 'standard:events';\nconst $f4859eee1867cbdd$export$ada873a34909da65 = $f4859eee1867cbdd$export$5296443ca9e9fa0f;\n\n\n/** @internal */ const $db254428317cd776$export$1ca1ec8b29a4ce27 = 'data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjMxIiB2aWV3Qm94PSIwIDAgMzEgMzEiIHdpZHRoPSIzMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PGxpbmVhckdyYWRpZW50IGlkPSJhIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjIwLjI1IiB4Mj0iMjYuNTcxIiB5MT0iMjcuMTczIiB5Mj0iMTkuODU4Ij48c3RvcCBvZmZzZXQ9Ii4wOCIgc3RvcC1jb2xvcj0iIzk5NDVmZiIvPjxzdG9wIG9mZnNldD0iLjMiIHN0b3AtY29sb3I9IiM4NzUyZjMiLz48c3RvcCBvZmZzZXQ9Ii41IiBzdG9wLWNvbG9yPSIjNTQ5N2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cy0uMDE4LS4wNTUtLjAzOS0uMDc2em0tNi40MzEtLjk4M2g2LjIwOWEuMzEuMzEgMCAwIDAgLjEyMS0uMDI0Yy4wMzgtLjAxNi4wNzMtLjA0LjEwMS0uMDdsMS4zMS0xLjM2OGMuMDItLjAyMS4wMzQtLjA0Ny4wMzktLjA3NnMuMDAxLS4wNTgtLjAxLS4wODRhLjE1LjE1IDAgMCAwIC0uMDU2LS4wNjVjLS4wMjUtLjAxNi0uMDU0LS4wMjQtLjA4My0uMDI0aC02LjIwOGEuMzEuMzEgMCAwIDAgLS4xMjEuMDI1Yy0uMDM4LjAxNi0uMDcyLjA0LS4xMDEuMDY5bC0xLjMxIDEuMzY4Yy0uMDIuMDIxLS4wMzQuMDQ3LS4wMzkuMDc2cy0uMDAxLjA1OC4wMS4wODQuMDMxLjA0OS4wNTYuMDY1LjA1NC4wMjQuMDgzLjAyNHoiIGZpbGw9InVybCgjYSkiLz48L3N2Zz4=';\n\n\nvar $047e59d25887ab3f$var$__classPrivateFieldGet = undefined && undefined.__classPrivateFieldGet || function(receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n};\nvar $047e59d25887ab3f$var$__classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function(receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;\n};\nvar $047e59d25887ab3f$var$_SolflareMetaMaskWallet_instances, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_listeners, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_version, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_name, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_icon, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_on, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_emit, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_off, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_connect, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_disconnect, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_signAndSendTransaction, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_signTransaction, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_signMessage;\n\nclass $047e59d25887ab3f$export$b9711d1b27bbdcc {\n constructor(){\n $047e59d25887ab3f$var$_SolflareMetaMaskWallet_instances.add(this);\n $047e59d25887ab3f$var$_SolflareMetaMaskWallet_listeners.set(this, {});\n $047e59d25887ab3f$var$_SolflareMetaMaskWallet_version.set(this, '1.0.0');\n $047e59d25887ab3f$var$_SolflareMetaMaskWallet_name.set(this, 'MetaMask');\n $047e59d25887ab3f$var$_SolflareMetaMaskWallet_icon.set(this, (0, $db254428317cd776$export$1ca1ec8b29a4ce27));\n $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask.set(this, null);\n $047e59d25887ab3f$var$_SolflareMetaMaskWallet_on.set(this, (event, listener)=>{\n $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_listeners, \"f\")[event]?.push(listener) || ($047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_listeners, \"f\")[event] = [\n listener\n ]);\n return ()=>$047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_instances, \"m\", $047e59d25887ab3f$var$_SolflareMetaMaskWallet_off).call(this, event, listener);\n });\n $047e59d25887ab3f$var$_SolflareMetaMaskWallet_connect.set(this, async ()=>{\n if (!$047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask, \"f\")) {\n let SolflareMetaMaskClass;\n try {\n SolflareMetaMaskClass = (await (parcelRequire(\"fSpOt\"))).default;\n } catch (error) {\n throw new Error('Unable to load Solflare MetaMask SDK');\n }\n $047e59d25887ab3f$var$__classPrivateFieldSet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask, new SolflareMetaMaskClass(), \"f\");\n $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask, \"f\").on('standard_change', (properties)=>$047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_instances, \"m\", $047e59d25887ab3f$var$_SolflareMetaMaskWallet_emit).call(this, 'change', properties));\n }\n if (!this.accounts.length) await $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask, \"f\").connect();\n return {\n accounts: this.accounts\n };\n });\n $047e59d25887ab3f$var$_SolflareMetaMaskWallet_disconnect.set(this, async ()=>{\n if (!$047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask, \"f\")) return;\n await $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask, \"f\").disconnect();\n });\n $047e59d25887ab3f$var$_SolflareMetaMaskWallet_signAndSendTransaction.set(this, async (...inputs)=>{\n if (!$047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask, \"f\")) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n return await $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask, \"f\").standardSignAndSendTransaction(...inputs);\n });\n $047e59d25887ab3f$var$_SolflareMetaMaskWallet_signTransaction.set(this, async (...inputs)=>{\n if (!$047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask, \"f\")) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n return await $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask, \"f\").standardSignTransaction(...inputs);\n });\n $047e59d25887ab3f$var$_SolflareMetaMaskWallet_signMessage.set(this, async (...inputs)=>{\n if (!$047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask, \"f\")) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n return await $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask, \"f\").standardSignMessage(...inputs);\n });\n }\n get version() {\n return $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_version, \"f\");\n }\n get name() {\n return $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_name, \"f\");\n }\n get icon() {\n return $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_icon, \"f\");\n }\n get chains() {\n return [\n (0, $54a90126d2f96ce7$export$bba9a228295b3963),\n (0, $54a90126d2f96ce7$export$654cc095bd2e650),\n (0, $54a90126d2f96ce7$export$76575b7bf4de1f40)\n ];\n }\n get features() {\n return {\n [(0, $744408f28809a335$export$cc68487eeb93b1d4)]: {\n version: '1.0.0',\n connect: $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_connect, \"f\")\n },\n [(0, $393285782087969c$export$38dbd4bbb9b696e6)]: {\n version: '1.0.0',\n disconnect: $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_disconnect, \"f\")\n },\n [(0, $f4859eee1867cbdd$export$5296443ca9e9fa0f)]: {\n version: '1.0.0',\n on: $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_on, \"f\")\n },\n [(0, $iJxGt.SolanaSignAndSendTransaction)]: {\n version: '1.0.0',\n supportedTransactionVersions: [\n 'legacy',\n 0\n ],\n signAndSendTransaction: $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_signAndSendTransaction, \"f\")\n },\n [(0, $d2raY.SolanaSignTransaction)]: {\n version: '1.0.0',\n supportedTransactionVersions: [\n 'legacy',\n 0\n ],\n signTransaction: $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_signTransaction, \"f\")\n },\n [(0, $7KE4n.SolanaSignMessage)]: {\n version: '1.0.0',\n signMessage: $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_signMessage, \"f\")\n }\n };\n }\n get accounts() {\n return $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask, \"f\") ? $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask, \"f\").standardAccounts : [];\n }\n}\n$047e59d25887ab3f$var$_SolflareMetaMaskWallet_listeners = new WeakMap(), $047e59d25887ab3f$var$_SolflareMetaMaskWallet_version = new WeakMap(), $047e59d25887ab3f$var$_SolflareMetaMaskWallet_name = new WeakMap(), $047e59d25887ab3f$var$_SolflareMetaMaskWallet_icon = new WeakMap(), $047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask = new WeakMap(), $047e59d25887ab3f$var$_SolflareMetaMaskWallet_on = new WeakMap(), $047e59d25887ab3f$var$_SolflareMetaMaskWallet_connect = new WeakMap(), $047e59d25887ab3f$var$_SolflareMetaMaskWallet_disconnect = new WeakMap(), $047e59d25887ab3f$var$_SolflareMetaMaskWallet_signAndSendTransaction = new WeakMap(), $047e59d25887ab3f$var$_SolflareMetaMaskWallet_signTransaction = new WeakMap(), $047e59d25887ab3f$var$_SolflareMetaMaskWallet_signMessage = new WeakMap(), $047e59d25887ab3f$var$_SolflareMetaMaskWallet_instances = new WeakSet(), $047e59d25887ab3f$var$_SolflareMetaMaskWallet_emit = function _SolflareMetaMaskWallet_emit(event, ...args) {\n // eslint-disable-next-line prefer-spread\n $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_listeners, \"f\")[event]?.forEach((listener)=>listener.apply(null, args));\n}, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_off = function _SolflareMetaMaskWallet_off(event, listener) {\n $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_listeners, \"f\")[event] = $047e59d25887ab3f$var$__classPrivateFieldGet(this, $047e59d25887ab3f$var$_SolflareMetaMaskWallet_listeners, \"f\")[event]?.filter((existingListener)=>listener !== existingListener);\n};\n\n\nlet $44e588f5cc38e309$var$registered = false;\nfunction $44e588f5cc38e309$var$register() {\n if ($44e588f5cc38e309$var$registered) return;\n (0, $aff560f1983590b4$export$ecffa18c0543eceb)(new (0, $047e59d25887ab3f$export$b9711d1b27bbdcc)());\n $44e588f5cc38e309$var$registered = true;\n}\nasync function $44e588f5cc38e309$export$2dd247ebd3228ce5() {\n const id = 'solflare-detect-metamask';\n function postMessage() {\n window.postMessage({\n target: 'metamask-contentscript',\n data: {\n name: 'metamask-provider',\n data: {\n id: id,\n jsonrpc: '2.0',\n method: 'wallet_getSnaps'\n }\n }\n }, window.location.origin);\n }\n function onMessage(event) {\n const message = event.data;\n if (message?.target === 'metamask-inpage' && message.data?.name === 'metamask-provider') {\n if (message.data.data?.id === id) {\n window.removeEventListener('message', onMessage);\n if (!message.data.data.error) $44e588f5cc38e309$var$register();\n } else postMessage();\n }\n }\n window.addEventListener('message', onMessage);\n window.setTimeout(()=>window.removeEventListener('message', onMessage), 5000);\n postMessage();\n}\n\n\nconst $8315e39d7cf92168$export$588524c4690a874f = 'Solflare';\n\nclass $8315e39d7cf92168$export$9fd69c70c5f8b9b4 extends (0, $71b3859dfb523e38$export$9db08bcddd106c96) {\n constructor(config = {}){\n super();\n this.name = $8315e39d7cf92168$export$588524c4690a874f;\n this.url = 'https://solflare.com';\n this.icon = 'data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjUwIiB2aWV3Qm94PSIwIDAgNTAgNTAiIHdpZHRoPSI1MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PGxpbmVhckdyYWRpZW50IGlkPSJhIj48c3RvcCBvZmZzZXQ9IjAiIHN0b3AtY29sb3I9IiNmZmMxMGIiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNmYjNmMmUiLz48L2xpbmVhckdyYWRpZW50PjxsaW5lYXJHcmFkaWVudCBpZD0iYiIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiIHgxPSI2LjQ3ODM1IiB4Mj0iMzQuOTEwNyIgeGxpbms6aHJlZj0iI2EiIHkxPSI3LjkyIiB5Mj0iMzMuNjU5MyIvPjxyYWRpYWxHcmFkaWVudCBpZD0iYyIgY3g9IjAiIGN5PSIwIiBncmFkaWVudFRyYW5zZm9ybT0ibWF0cml4KDQuOTkyMTg4MzIgMTIuMDYzODc5NjMgLTEyLjE4MTEzNjU1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NDAzem0tMjQuNjI5Ni0yMi40Nzk3Yy41MjUgMCAuOTUwNi40MjA5NzMuOTUwNi45NDAyNyAwIC41MTkzLS40MjU2Ljk0MDI3LS45NTA2Ljk0MDI3LS41MjUxIDAtLjk1MDctLjQyMDk3LS45NTA3LS45NDAyNyAwLS41MTkyOTcuNDI1Ni0uOTQwMjcuOTUwNy0uOTQwMjd6IiBmaWxsPSJ1cmwoI2IpIi8+PHBhdGggZD0ibTI0LjU3MSAzMi43NzkyYzQuOTU5NiAwIDguOTgwMi0zLjk3NjUgOC45ODAyLTguODgxOSAwLTQuOTA1My00LjAyMDYtOC44ODE5LTguOTgwMi04Ljg4MTlzLTguOTgwMiAzLjk3NjYtOC45ODAyIDguODgxOWMwIDQuOTA1NCA0LjAyMDYgOC44ODE5IDguOTgwMiA4Ljg4MTl6IiBmaWxsPSJ1cmwoI2MpIi8+PC9zdmc+';\n this.supportedTransactionVersions = new Set([\n 'legacy',\n 0\n ]);\n this._readyState = typeof window === 'undefined' || typeof document === 'undefined' ? (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Unsupported : (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Loadable;\n this._disconnected = ()=>{\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n this._wallet = null;\n this._publicKey = null;\n this.emit('error', new (0, $92c515b2e16b5c4e$export$bf7028c52ebda81e)());\n this.emit('disconnect');\n }\n };\n this._accountChanged = (newPublicKey)=>{\n if (!newPublicKey) return;\n const publicKey = this._publicKey;\n if (!publicKey) return;\n try {\n newPublicKey = new (0, $gNDby.PublicKey)(newPublicKey.toBytes());\n } catch (error) {\n this.emit('error', new (0, $92c515b2e16b5c4e$export$735bef3bfb0f2c86)(error?.message, error));\n return;\n }\n if (publicKey.equals(newPublicKey)) return;\n this._publicKey = newPublicKey;\n this.emit('connect', newPublicKey);\n };\n this._connecting = false;\n this._publicKey = null;\n this._wallet = null;\n this._config = config;\n if (this._readyState !== (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Unsupported) {\n (0, $a27aaf340df890aa$export$378bae4c88e0b46e)(()=>{\n if (window.solflare?.isSolflare || window.SolflareApp) {\n this._readyState = (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Installed;\n this.emit('readyStateChange', this._readyState);\n return true;\n }\n return false;\n });\n (0, $44e588f5cc38e309$export$2dd247ebd3228ce5)();\n }\n }\n get publicKey() {\n return this._publicKey;\n }\n get connecting() {\n return this._connecting;\n }\n get connected() {\n return !!this._wallet?.connected;\n }\n get readyState() {\n return this._readyState;\n }\n async autoConnect() {\n // Skip autoconnect in the Loadable state on iOS\n // We can't redirect to a universal link without user input\n if (!(this.readyState === (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Loadable && (0, $a27aaf340df890aa$export$bf89b558d1e273a2)())) await this.connect();\n }\n async connect() {\n try {\n if (this.connected || this.connecting) return;\n if (this._readyState !== (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Loadable && this._readyState !== (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Installed) throw new (0, $92c515b2e16b5c4e$export$d65db264eda99cd7)();\n // redirect to the Solflare /browse universal link\n // this will open the current URL in the Solflare in-wallet browser\n if (this.readyState === (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Loadable && (0, $a27aaf340df890aa$export$bf89b558d1e273a2)()) {\n const url = encodeURIComponent(window.location.href);\n const ref = encodeURIComponent(window.location.origin);\n window.location.href = `https://solflare.com/ul/v1/browse/${url}?ref=${ref}`;\n return;\n }\n let SolflareClass;\n try {\n SolflareClass = (await (parcelRequire(\"hSLYn\"))).default;\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$9a551f94af9b0bf8)(error?.message, error);\n }\n let wallet;\n try {\n wallet = new SolflareClass({\n network: this._config.network\n });\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$9525019988612a5e)(error?.message, error);\n }\n this._connecting = true;\n if (!wallet.connected) try {\n await wallet.connect();\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$38f21f1c810261c7)(error?.message, error);\n }\n if (!wallet.publicKey) throw new (0, $92c515b2e16b5c4e$export$38f21f1c810261c7)();\n let publicKey;\n try {\n publicKey = new (0, $gNDby.PublicKey)(wallet.publicKey.toBytes());\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$735bef3bfb0f2c86)(error?.message, error);\n }\n wallet.on('disconnect', this._disconnected);\n wallet.on('accountChanged', this._accountChanged);\n this._wallet = wallet;\n this._publicKey = publicKey;\n this.emit('connect', publicKey);\n } catch (error) {\n this.emit('error', error);\n throw error;\n } finally{\n this._connecting = false;\n }\n }\n async disconnect() {\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n wallet.off('accountChanged', this._accountChanged);\n this._wallet = null;\n this._publicKey = null;\n try {\n await wallet.disconnect();\n } catch (error) {\n this.emit('error', new (0, $92c515b2e16b5c4e$export$92e2b26fad5723ee)(error?.message, error));\n }\n }\n this.emit('disconnect');\n }\n async sendTransaction(transaction, connection, options = {}) {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n try {\n const { signers: signers, ...sendOptions } = options;\n if ((0, $afa5c06c212ba160$export$37ce1cc82e255d8)(transaction)) signers?.length && transaction.sign(signers);\n else {\n transaction = await this.prepareTransaction(transaction, connection, sendOptions);\n signers?.length && transaction.partialSign(...signers);\n }\n sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment;\n return await wallet.signAndSendTransaction(transaction, sendOptions);\n } catch (error) {\n if (error instanceof (0, $92c515b2e16b5c4e$export$f46ec6f9dba8711d)) throw error;\n throw new (0, $92c515b2e16b5c4e$export$769332ac3f90f46c)(error?.message, error);\n }\n } catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signTransaction(transaction) {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n try {\n return await wallet.signTransaction(transaction) || transaction;\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$96f177062fdd8180)(error?.message, error);\n }\n } catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signAllTransactions(transactions) {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n try {\n return await wallet.signAllTransactions(transactions) || transactions;\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$96f177062fdd8180)(error?.message, error);\n }\n } catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signMessage(message) {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new (0, $92c515b2e16b5c4e$export$313d299817c74896)();\n try {\n return await wallet.signMessage(message, 'utf8');\n } catch (error) {\n throw new (0, $92c515b2e16b5c4e$export$2622c1721bbd4b17)(error?.message, error);\n }\n } catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n}\n\n\nvar $0e615402198d55c8$export$90767a7ae4c388dc;\n(function(WalletAdapterNetwork) {\n WalletAdapterNetwork[\"Mainnet\"] = \"mainnet-beta\";\n WalletAdapterNetwork[\"Testnet\"] = \"testnet\";\n WalletAdapterNetwork[\"Devnet\"] = \"devnet\";\n})($0e615402198d55c8$export$90767a7ae4c388dc || ($0e615402198d55c8$export$90767a7ae4c388dc = {}));\n\n\n\nvar $gNDby = parcelRequire(\"gNDby\");\n\nvar $6ZWSX = parcelRequire(\"6ZWSX\");\nvar $543d6d2a56ed7d8d$require$Buffer = $6ZWSX.Buffer;\nlet $543d6d2a56ed7d8d$var$walletConnectConnectedWallet;\nlet $543d6d2a56ed7d8d$var$walletConnectWallets = [];\nfunction $543d6d2a56ed7d8d$var$onReadyStateChange(readyState) {\n console.log(\"onReadyStateChange\", readyState);\n if (!this) {\n console.log(\"no adapter\");\n return;\n }\n console.log(\"adapter\", this);\n console.log(\"readyState\", readyState);\n $543d6d2a56ed7d8d$var$establishEmitter();\n if (window.walletConnectEventElement) window.walletConnectEventElement.dispatchEvent(new CustomEvent(\"walletReadyStateChange\", {\n detail: {\n name: this.name,\n ready_state: readyState.toString()\n }\n }));\n}\nfunction $543d6d2a56ed7d8d$var$onConnect() {\n if (!this) {\n console.log(\"no adapter\");\n return;\n }\n console.log(\"adapter\", this);\n console.log(\"connected\", this.connected);\n console.log(\"publicKey\", this.publicKey?.toString());\n if (this.connected) {\n $543d6d2a56ed7d8d$var$walletConnectConnectedWallet = this;\n window.walletConnectedPubKey = this.publicKey?.toString() || \"\";\n }\n $543d6d2a56ed7d8d$var$establishEmitter();\n if (window.walletConnectEventElement) window.walletConnectEventElement.dispatchEvent(new CustomEvent(\"walletConnect\", {\n detail: {\n public_key: this.publicKey?.toString()\n }\n }));\n}\nfunction $543d6d2a56ed7d8d$var$onAccountChanged(newPublicKey) {\n console.log(\"adapter\", this);\n console.log(\"publicKey\", newPublicKey?.toString());\n if (newPublicKey) window.walletConnectedPubKey = newPublicKey?.toString() || \"\";\n $543d6d2a56ed7d8d$var$establishEmitter();\n if (window.walletConnectEventElement) window.walletConnectEventElement.dispatchEvent(new CustomEvent(\"walletAccountChange\", {\n detail: {\n public_key: newPublicKey?.toString()\n }\n }));\n}\nfunction $543d6d2a56ed7d8d$var$onDisconnect() {\n console.log(\"adapter\", this);\n console.log(\"disconnected\");\n $543d6d2a56ed7d8d$var$walletConnectConnectedWallet = undefined;\n window.walletConnectedPubKey = \"\";\n $543d6d2a56ed7d8d$var$establishEmitter();\n if (window.walletConnectEventElement) window.walletConnectEventElement.dispatchEvent(new CustomEvent(\"walletDisconnected\", {\n detail: {\n public_key: \"\"\n }\n }));\n}\nfunction $543d6d2a56ed7d8d$var$onError(error) {\n console.error(error);\n $543d6d2a56ed7d8d$var$establishEmitter();\n if (window.walletConnectEventElement) window.walletConnectEventElement.dispatchEvent(new CustomEvent(\"walletError\", {\n detail: {\n error: error.toString()\n }\n }));\n}\nwindow.walletConnected = ()=>window.walletConnectedPubKey || \"\";\nwindow.walletsAlert = (message)=>{\n window.alert(message);\n};\nwindow.walletsDetected = ()=>{\n let walletsDetected = $543d6d2a56ed7d8d$var$walletConnectWallets.filter((adapter)=>adapter.readyState == (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Installed).map((adapter)=>{\n return {\n name: adapter.name,\n icon: adapter.icon\n };\n });\n return walletsDetected;\n};\nwindow.walletsConnect = async (walletName)=>{\n const adapter = $543d6d2a56ed7d8d$var$walletConnectWallets.find((adapter)=>adapter.name === walletName);\n if (!adapter) throw new Error(`Wallet not found: ${walletName}`);\n console.log(`adapter ${adapter.name} in state ${adapter.readyState}`);\n if (adapter.readyState == (0, $a27aaf340df890aa$export$2a7b8071105d05b6).Installed) {\n console.log(`adapter ${adapter.name} is installed. connecting...`);\n await adapter.connect();\n return adapter.publicKey.toString();\n } else console.log(`adapter ${adapter.name} is not installed.`);\n return;\n};\nwindow.walletsDisconnect = async ()=>{\n if ($543d6d2a56ed7d8d$var$walletConnectConnectedWallet) {\n console.log(\"disconnecting wallet\");\n await $543d6d2a56ed7d8d$var$walletConnectConnectedWallet.disconnect();\n }\n};\nlet $543d6d2a56ed7d8d$var$establishEmitter = ()=>{\n if (window.walletConnectEventElementName && document.getElementById(window.walletConnectEventElementName)) {\n window.walletConnectEventElement = document.getElementById(window.walletConnectEventElementName);\n return window.walletConnectEventElement;\n }\n};\nwindow.walletsLoad = (eventElement)=>{\n // WalletConnect code\n window.walletConnectEventElement = document.getElementById(eventElement);\n window.walletConnectEventElementName = eventElement;\n console.log(`${(0, $8315e39d7cf92168$export$588524c4690a874f)} wallet adapter`);\n console.log(`${(0, $27b337e06adc69ec$export$37766f30d842581a)} wallet adapter`);\n console.log(`${(0, $35fb31345295b098$export$c094e79b0fad9c07)} wallet adapter`);\n const network = (0, $0e615402198d55c8$export$90767a7ae4c388dc).Mainnet;\n // const network = WalletAdapterNetwork.Devnet;\n $543d6d2a56ed7d8d$var$walletConnectWallets = [\n new (0, $8315e39d7cf92168$export$9fd69c70c5f8b9b4)({\n network: network\n }),\n new (0, $35fb31345295b098$export$9c8fcf9b2dfe1d6a)({\n network: network\n }),\n new (0, $27b337e06adc69ec$export$a8fff984faa686f6)({\n network: network\n })\n ];\n $543d6d2a56ed7d8d$var$walletConnectWallets.forEach((adapter)=>{\n adapter.on(\"readyStateChange\", $543d6d2a56ed7d8d$var$onReadyStateChange, adapter);\n adapter.on(\"connect\", $543d6d2a56ed7d8d$var$onConnect, adapter);\n adapter.on(\"disconnect\", $543d6d2a56ed7d8d$var$onDisconnect, adapter);\n adapter.on(\"accountChanged\", $543d6d2a56ed7d8d$var$onAccountChanged, adapter);\n adapter.on(\"error\", $543d6d2a56ed7d8d$var$onError);\n });\n return $543d6d2a56ed7d8d$var$walletConnectWallets.map((adapter)=>adapter.name);\n// adapter.on('disconnect', onDisconnect);\n};\nwindow.walletsSign = async (encodedTx)=>{\n console.log(`encodedTx to sign: ${encodedTx}`);\n if ($543d6d2a56ed7d8d$var$walletConnectConnectedWallet) {\n const tx = (0, $gNDby.Transaction).from($543d6d2a56ed7d8d$require$Buffer.from(encodedTx, \"base64\"));\n if (\"signTransaction\" in $543d6d2a56ed7d8d$var$walletConnectConnectedWallet) {\n const signedTx = await $543d6d2a56ed7d8d$var$walletConnectConnectedWallet.signTransaction(tx);\n const serialized = signedTx.serialize().toString(\"base64\");\n console.log(`signature: ${serialized}`);\n return serialized;\n }\n throw new Error(`Wallet ${$543d6d2a56ed7d8d$var$walletConnectConnectedWallet.name} does not support signing transactions`);\n }\n};\n\n\n//# sourceMappingURL=index.5c102541.js.map\n","\"use strict\";\n\nvar mapping = new Map();\nfunction register(baseUrl, manifest) {\n for (var i = 0; i < manifest.length - 1; i += 2) {\n mapping.set(manifest[i], {\n baseUrl: baseUrl,\n path: manifest[i + 1]\n });\n }\n}\nfunction resolve(id) {\n var resolved = mapping.get(id);\n if (resolved == null) {\n throw new Error('Could not resolve bundle with id ' + id);\n }\n return new URL(resolved.path, resolved.baseUrl).toString();\n}\nmodule.exports.register = register;\nmodule.exports.resolve = resolve;","/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\n/* eslint-disable no-proto */\n\n'use strict'\n\nconst base64 = require('base64-js')\nconst ieee754 = require('ieee754')\nconst customInspectSymbol =\n (typeof Symbol === 'function' && typeof Symbol['for'] === 'function') // eslint-disable-line dot-notation\n ? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation\n : null\n\nexports.Buffer = Buffer\nexports.SlowBuffer = SlowBuffer\nexports.INSPECT_MAX_BYTES = 50\n\nconst K_MAX_LENGTH = 0x7fffffff\nexports.kMaxLength = K_MAX_LENGTH\n\n/**\n * If `Buffer.TYPED_ARRAY_SUPPORT`:\n * === true Use Uint8Array implementation (fastest)\n * === false Print warning and recommend using `buffer` v4.x which has an Object\n * implementation (most compatible, even IE6)\n *\n * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,\n * Opera 11.6+, iOS 4.2+.\n *\n * We report that the browser does not support typed arrays if the are not subclassable\n * using __proto__. Firefox 4-29 lacks support for adding new properties to `Uint8Array`\n * (See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438). IE 10 lacks support\n * for __proto__ and has a buggy typed array implementation.\n */\nBuffer.TYPED_ARRAY_SUPPORT = typedArraySupport()\n\nif (!Buffer.TYPED_ARRAY_SUPPORT && typeof console !== 'undefined' &&\n typeof console.error === 'function') {\n console.error(\n 'This browser lacks typed array (Uint8Array) support which is required by ' +\n '`buffer` v5.x. Use `buffer` v4.x if you require old browser support.'\n )\n}\n\nfunction typedArraySupport () {\n // Can typed array instances can be augmented?\n try {\n const arr = new Uint8Array(1)\n const proto = { foo: function () { return 42 } }\n Object.setPrototypeOf(proto, Uint8Array.prototype)\n Object.setPrototypeOf(arr, proto)\n return arr.foo() === 42\n } catch (e) {\n return false\n }\n}\n\nObject.defineProperty(Buffer.prototype, 'parent', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.buffer\n }\n})\n\nObject.defineProperty(Buffer.prototype, 'offset', {\n enumerable: true,\n get: function () {\n if (!Buffer.isBuffer(this)) return undefined\n return this.byteOffset\n }\n})\n\nfunction createBuffer (length) {\n if (length > K_MAX_LENGTH) {\n throw new RangeError('The value \"' + length + '\" is invalid for option \"size\"')\n }\n // Return an augmented `Uint8Array` instance\n const buf = new Uint8Array(length)\n Object.setPrototypeOf(buf, Buffer.prototype)\n return buf\n}\n\n/**\n * The Buffer constructor returns instances of `Uint8Array` that have their\n * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of\n * `Uint8Array`, so the returned instances will have all the node `Buffer` methods\n * and the `Uint8Array` methods. Square bracket notation works as expected -- it\n * returns a single octet.\n *\n * The `Uint8Array` prototype remains unmodified.\n */\n\nfunction Buffer (arg, encodingOrOffset, length) {\n // Common case.\n if (typeof arg === 'number') {\n if (typeof encodingOrOffset === 'string') {\n throw new TypeError(\n 'The \"string\" argument must be of type string. Received type number'\n )\n }\n return allocUnsafe(arg)\n }\n return from(arg, encodingOrOffset, length)\n}\n\nBuffer.poolSize = 8192 // not used by this implementation\n\nfunction from (value, encodingOrOffset, length) {\n if (typeof value === 'string') {\n return fromString(value, encodingOrOffset)\n }\n\n if (ArrayBuffer.isView(value)) {\n return fromArrayView(value)\n }\n\n if (value == null) {\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n }\n\n if (isInstance(value, ArrayBuffer) ||\n (value && isInstance(value.buffer, ArrayBuffer))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof SharedArrayBuffer !== 'undefined' &&\n (isInstance(value, SharedArrayBuffer) ||\n (value && isInstance(value.buffer, SharedArrayBuffer)))) {\n return fromArrayBuffer(value, encodingOrOffset, length)\n }\n\n if (typeof value === 'number') {\n throw new TypeError(\n 'The \"value\" argument must not be of type number. Received type number'\n )\n }\n\n const valueOf = value.valueOf && value.valueOf()\n if (valueOf != null && valueOf !== value) {\n return Buffer.from(valueOf, encodingOrOffset, length)\n }\n\n const b = fromObject(value)\n if (b) return b\n\n if (typeof Symbol !== 'undefined' && Symbol.toPrimitive != null &&\n typeof value[Symbol.toPrimitive] === 'function') {\n return Buffer.from(value[Symbol.toPrimitive]('string'), encodingOrOffset, length)\n }\n\n throw new TypeError(\n 'The first argument must be one of type string, Buffer, ArrayBuffer, Array, ' +\n 'or Array-like Object. Received type ' + (typeof value)\n )\n}\n\n/**\n * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError\n * if value is a number.\n * Buffer.from(str[, encoding])\n * Buffer.from(array)\n * Buffer.from(buffer)\n * Buffer.from(arrayBuffer[, byteOffset[, length]])\n **/\nBuffer.from = function (value, encodingOrOffset, length) {\n return from(value, encodingOrOffset, length)\n}\n\n// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:\n// https://github.com/feross/buffer/pull/148\nObject.setPrototypeOf(Buffer.prototype, Uint8Array.prototype)\nObject.setPrototypeOf(Buffer, Uint8Array)\n\nfunction assertSize (size) {\n if (typeof size !== 'number') {\n throw new TypeError('\"size\" argument must be of type number')\n } else if (size < 0) {\n throw new RangeError('The value \"' + size + '\" is invalid for option \"size\"')\n }\n}\n\nfunction alloc (size, fill, encoding) {\n assertSize(size)\n if (size <= 0) {\n return createBuffer(size)\n }\n if (fill !== undefined) {\n // Only pay attention to encoding if it's a string. This\n // prevents accidentally sending in a number that would\n // be interpreted as a start offset.\n return typeof encoding === 'string'\n ? createBuffer(size).fill(fill, encoding)\n : createBuffer(size).fill(fill)\n }\n return createBuffer(size)\n}\n\n/**\n * Creates a new filled Buffer instance.\n * alloc(size[, fill[, encoding]])\n **/\nBuffer.alloc = function (size, fill, encoding) {\n return alloc(size, fill, encoding)\n}\n\nfunction allocUnsafe (size) {\n assertSize(size)\n return createBuffer(size < 0 ? 0 : checked(size) | 0)\n}\n\n/**\n * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.\n * */\nBuffer.allocUnsafe = function (size) {\n return allocUnsafe(size)\n}\n/**\n * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.\n */\nBuffer.allocUnsafeSlow = function (size) {\n return allocUnsafe(size)\n}\n\nfunction fromString (string, encoding) {\n if (typeof encoding !== 'string' || encoding === '') {\n encoding = 'utf8'\n }\n\n if (!Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n\n const length = byteLength(string, encoding) | 0\n let buf = createBuffer(length)\n\n const actual = buf.write(string, encoding)\n\n if (actual !== length) {\n // Writing a hex string, for example, that contains invalid characters will\n // cause everything after the first invalid character to be ignored. (e.g.\n // 'abxxcd' will be treated as 'ab')\n buf = buf.slice(0, actual)\n }\n\n return buf\n}\n\nfunction fromArrayLike (array) {\n const length = array.length < 0 ? 0 : checked(array.length) | 0\n const buf = createBuffer(length)\n for (let i = 0; i < length; i += 1) {\n buf[i] = array[i] & 255\n }\n return buf\n}\n\nfunction fromArrayView (arrayView) {\n if (isInstance(arrayView, Uint8Array)) {\n const copy = new Uint8Array(arrayView)\n return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength)\n }\n return fromArrayLike(arrayView)\n}\n\nfunction fromArrayBuffer (array, byteOffset, length) {\n if (byteOffset < 0 || array.byteLength < byteOffset) {\n throw new RangeError('\"offset\" is outside of buffer bounds')\n }\n\n if (array.byteLength < byteOffset + (length || 0)) {\n throw new RangeError('\"length\" is outside of buffer bounds')\n }\n\n let buf\n if (byteOffset === undefined && length === undefined) {\n buf = new Uint8Array(array)\n } else if (length === undefined) {\n buf = new Uint8Array(array, byteOffset)\n } else {\n buf = new Uint8Array(array, byteOffset, length)\n }\n\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(buf, Buffer.prototype)\n\n return buf\n}\n\nfunction fromObject (obj) {\n if (Buffer.isBuffer(obj)) {\n const len = checked(obj.length) | 0\n const buf = createBuffer(len)\n\n if (buf.length === 0) {\n return buf\n }\n\n obj.copy(buf, 0, 0, len)\n return buf\n }\n\n if (obj.length !== undefined) {\n if (typeof obj.length !== 'number' || numberIsNaN(obj.length)) {\n return createBuffer(0)\n }\n return fromArrayLike(obj)\n }\n\n if (obj.type === 'Buffer' && Array.isArray(obj.data)) {\n return fromArrayLike(obj.data)\n }\n}\n\nfunction checked (length) {\n // Note: cannot use `length < K_MAX_LENGTH` here because that fails when\n // length is NaN (which is otherwise coerced to zero.)\n if (length >= K_MAX_LENGTH) {\n throw new RangeError('Attempt to allocate Buffer larger than maximum ' +\n 'size: 0x' + K_MAX_LENGTH.toString(16) + ' bytes')\n }\n return length | 0\n}\n\nfunction SlowBuffer (length) {\n if (+length != length) { // eslint-disable-line eqeqeq\n length = 0\n }\n return Buffer.alloc(+length)\n}\n\nBuffer.isBuffer = function isBuffer (b) {\n return b != null && b._isBuffer === true &&\n b !== Buffer.prototype // so Buffer.isBuffer(Buffer.prototype) will be false\n}\n\nBuffer.compare = function compare (a, b) {\n if (isInstance(a, Uint8Array)) a = Buffer.from(a, a.offset, a.byteLength)\n if (isInstance(b, Uint8Array)) b = Buffer.from(b, b.offset, b.byteLength)\n if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {\n throw new TypeError(\n 'The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array'\n )\n }\n\n if (a === b) return 0\n\n let x = a.length\n let y = b.length\n\n for (let i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i]\n y = b[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\nBuffer.isEncoding = function isEncoding (encoding) {\n switch (String(encoding).toLowerCase()) {\n case 'hex':\n case 'utf8':\n case 'utf-8':\n case 'ascii':\n case 'latin1':\n case 'binary':\n case 'base64':\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return true\n default:\n return false\n }\n}\n\nBuffer.concat = function concat (list, length) {\n if (!Array.isArray(list)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n }\n\n if (list.length === 0) {\n return Buffer.alloc(0)\n }\n\n let i\n if (length === undefined) {\n length = 0\n for (i = 0; i < list.length; ++i) {\n length += list[i].length\n }\n }\n\n const buffer = Buffer.allocUnsafe(length)\n let pos = 0\n for (i = 0; i < list.length; ++i) {\n let buf = list[i]\n if (isInstance(buf, Uint8Array)) {\n if (pos + buf.length > buffer.length) {\n if (!Buffer.isBuffer(buf)) buf = Buffer.from(buf)\n buf.copy(buffer, pos)\n } else {\n Uint8Array.prototype.set.call(\n buffer,\n buf,\n pos\n )\n }\n } else if (!Buffer.isBuffer(buf)) {\n throw new TypeError('\"list\" argument must be an Array of Buffers')\n } else {\n buf.copy(buffer, pos)\n }\n pos += buf.length\n }\n return buffer\n}\n\nfunction byteLength (string, encoding) {\n if (Buffer.isBuffer(string)) {\n return string.length\n }\n if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {\n return string.byteLength\n }\n if (typeof string !== 'string') {\n throw new TypeError(\n 'The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. ' +\n 'Received type ' + typeof string\n )\n }\n\n const len = string.length\n const mustMatch = (arguments.length > 2 && arguments[2] === true)\n if (!mustMatch && len === 0) return 0\n\n // Use a for loop to avoid recursion\n let loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'ascii':\n case 'latin1':\n case 'binary':\n return len\n case 'utf8':\n case 'utf-8':\n return utf8ToBytes(string).length\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return len * 2\n case 'hex':\n return len >>> 1\n case 'base64':\n return base64ToBytes(string).length\n default:\n if (loweredCase) {\n return mustMatch ? -1 : utf8ToBytes(string).length // assume utf8\n }\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\nBuffer.byteLength = byteLength\n\nfunction slowToString (encoding, start, end) {\n let loweredCase = false\n\n // No need to verify that \"this.length <= MAX_UINT32\" since it's a read-only\n // property of a typed array.\n\n // This behaves neither like String nor Uint8Array in that we set start/end\n // to their upper/lower bounds if the value passed is out of range.\n // undefined is handled specially as per ECMA-262 6th Edition,\n // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.\n if (start === undefined || start < 0) {\n start = 0\n }\n // Return early if start > this.length. Done here to prevent potential uint32\n // coercion fail below.\n if (start > this.length) {\n return ''\n }\n\n if (end === undefined || end > this.length) {\n end = this.length\n }\n\n if (end <= 0) {\n return ''\n }\n\n // Force coercion to uint32. This will also coerce falsey/NaN values to 0.\n end >>>= 0\n start >>>= 0\n\n if (end <= start) {\n return ''\n }\n\n if (!encoding) encoding = 'utf8'\n\n while (true) {\n switch (encoding) {\n case 'hex':\n return hexSlice(this, start, end)\n\n case 'utf8':\n case 'utf-8':\n return utf8Slice(this, start, end)\n\n case 'ascii':\n return asciiSlice(this, start, end)\n\n case 'latin1':\n case 'binary':\n return latin1Slice(this, start, end)\n\n case 'base64':\n return base64Slice(this, start, end)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return utf16leSlice(this, start, end)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = (encoding + '').toLowerCase()\n loweredCase = true\n }\n }\n}\n\n// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)\n// to detect a Buffer instance. It's not possible to use `instanceof Buffer`\n// reliably in a browserify context because there could be multiple different\n// copies of the 'buffer' package in use. This method works even for Buffer\n// instances that were created from another copy of the `buffer` package.\n// See: https://github.com/feross/buffer/issues/154\nBuffer.prototype._isBuffer = true\n\nfunction swap (b, n, m) {\n const i = b[n]\n b[n] = b[m]\n b[m] = i\n}\n\nBuffer.prototype.swap16 = function swap16 () {\n const len = this.length\n if (len % 2 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 16-bits')\n }\n for (let i = 0; i < len; i += 2) {\n swap(this, i, i + 1)\n }\n return this\n}\n\nBuffer.prototype.swap32 = function swap32 () {\n const len = this.length\n if (len % 4 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 32-bits')\n }\n for (let i = 0; i < len; i += 4) {\n swap(this, i, i + 3)\n swap(this, i + 1, i + 2)\n }\n return this\n}\n\nBuffer.prototype.swap64 = function swap64 () {\n const len = this.length\n if (len % 8 !== 0) {\n throw new RangeError('Buffer size must be a multiple of 64-bits')\n }\n for (let i = 0; i < len; i += 8) {\n swap(this, i, i + 7)\n swap(this, i + 1, i + 6)\n swap(this, i + 2, i + 5)\n swap(this, i + 3, i + 4)\n }\n return this\n}\n\nBuffer.prototype.toString = function toString () {\n const length = this.length\n if (length === 0) return ''\n if (arguments.length === 0) return utf8Slice(this, 0, length)\n return slowToString.apply(this, arguments)\n}\n\nBuffer.prototype.toLocaleString = Buffer.prototype.toString\n\nBuffer.prototype.equals = function equals (b) {\n if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')\n if (this === b) return true\n return Buffer.compare(this, b) === 0\n}\n\nBuffer.prototype.inspect = function inspect () {\n let str = ''\n const max = exports.INSPECT_MAX_BYTES\n str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim()\n if (this.length > max) str += ' ... '\n return ''\n}\nif (customInspectSymbol) {\n Buffer.prototype[customInspectSymbol] = Buffer.prototype.inspect\n}\n\nBuffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {\n if (isInstance(target, Uint8Array)) {\n target = Buffer.from(target, target.offset, target.byteLength)\n }\n if (!Buffer.isBuffer(target)) {\n throw new TypeError(\n 'The \"target\" argument must be one of type Buffer or Uint8Array. ' +\n 'Received type ' + (typeof target)\n )\n }\n\n if (start === undefined) {\n start = 0\n }\n if (end === undefined) {\n end = target ? target.length : 0\n }\n if (thisStart === undefined) {\n thisStart = 0\n }\n if (thisEnd === undefined) {\n thisEnd = this.length\n }\n\n if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {\n throw new RangeError('out of range index')\n }\n\n if (thisStart >= thisEnd && start >= end) {\n return 0\n }\n if (thisStart >= thisEnd) {\n return -1\n }\n if (start >= end) {\n return 1\n }\n\n start >>>= 0\n end >>>= 0\n thisStart >>>= 0\n thisEnd >>>= 0\n\n if (this === target) return 0\n\n let x = thisEnd - thisStart\n let y = end - start\n const len = Math.min(x, y)\n\n const thisCopy = this.slice(thisStart, thisEnd)\n const targetCopy = target.slice(start, end)\n\n for (let i = 0; i < len; ++i) {\n if (thisCopy[i] !== targetCopy[i]) {\n x = thisCopy[i]\n y = targetCopy[i]\n break\n }\n }\n\n if (x < y) return -1\n if (y < x) return 1\n return 0\n}\n\n// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,\n// OR the last index of `val` in `buffer` at offset <= `byteOffset`.\n//\n// Arguments:\n// - buffer - a Buffer to search\n// - val - a string, Buffer, or number\n// - byteOffset - an index into `buffer`; will be clamped to an int32\n// - encoding - an optional encoding, relevant is val is a string\n// - dir - true for indexOf, false for lastIndexOf\nfunction bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {\n // Empty buffer means no match\n if (buffer.length === 0) return -1\n\n // Normalize byteOffset\n if (typeof byteOffset === 'string') {\n encoding = byteOffset\n byteOffset = 0\n } else if (byteOffset > 0x7fffffff) {\n byteOffset = 0x7fffffff\n } else if (byteOffset < -0x80000000) {\n byteOffset = -0x80000000\n }\n byteOffset = +byteOffset // Coerce to Number.\n if (numberIsNaN(byteOffset)) {\n // byteOffset: it it's undefined, null, NaN, \"foo\", etc, search whole buffer\n byteOffset = dir ? 0 : (buffer.length - 1)\n }\n\n // Normalize byteOffset: negative offsets start from the end of the buffer\n if (byteOffset < 0) byteOffset = buffer.length + byteOffset\n if (byteOffset >= buffer.length) {\n if (dir) return -1\n else byteOffset = buffer.length - 1\n } else if (byteOffset < 0) {\n if (dir) byteOffset = 0\n else return -1\n }\n\n // Normalize val\n if (typeof val === 'string') {\n val = Buffer.from(val, encoding)\n }\n\n // Finally, search either indexOf (if dir is true) or lastIndexOf\n if (Buffer.isBuffer(val)) {\n // Special case: looking for empty string/buffer always fails\n if (val.length === 0) {\n return -1\n }\n return arrayIndexOf(buffer, val, byteOffset, encoding, dir)\n } else if (typeof val === 'number') {\n val = val & 0xFF // Search for a byte value [0-255]\n if (typeof Uint8Array.prototype.indexOf === 'function') {\n if (dir) {\n return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)\n } else {\n return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)\n }\n }\n return arrayIndexOf(buffer, [val], byteOffset, encoding, dir)\n }\n\n throw new TypeError('val must be string, number or Buffer')\n}\n\nfunction arrayIndexOf (arr, val, byteOffset, encoding, dir) {\n let indexSize = 1\n let arrLength = arr.length\n let valLength = val.length\n\n if (encoding !== undefined) {\n encoding = String(encoding).toLowerCase()\n if (encoding === 'ucs2' || encoding === 'ucs-2' ||\n encoding === 'utf16le' || encoding === 'utf-16le') {\n if (arr.length < 2 || val.length < 2) {\n return -1\n }\n indexSize = 2\n arrLength /= 2\n valLength /= 2\n byteOffset /= 2\n }\n }\n\n function read (buf, i) {\n if (indexSize === 1) {\n return buf[i]\n } else {\n return buf.readUInt16BE(i * indexSize)\n }\n }\n\n let i\n if (dir) {\n let foundIndex = -1\n for (i = byteOffset; i < arrLength; i++) {\n if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {\n if (foundIndex === -1) foundIndex = i\n if (i - foundIndex + 1 === valLength) return foundIndex * indexSize\n } else {\n if (foundIndex !== -1) i -= i - foundIndex\n foundIndex = -1\n }\n }\n } else {\n if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength\n for (i = byteOffset; i >= 0; i--) {\n let found = true\n for (let j = 0; j < valLength; j++) {\n if (read(arr, i + j) !== read(val, j)) {\n found = false\n break\n }\n }\n if (found) return i\n }\n }\n\n return -1\n}\n\nBuffer.prototype.includes = function includes (val, byteOffset, encoding) {\n return this.indexOf(val, byteOffset, encoding) !== -1\n}\n\nBuffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, true)\n}\n\nBuffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {\n return bidirectionalIndexOf(this, val, byteOffset, encoding, false)\n}\n\nfunction hexWrite (buf, string, offset, length) {\n offset = Number(offset) || 0\n const remaining = buf.length - offset\n if (!length) {\n length = remaining\n } else {\n length = Number(length)\n if (length > remaining) {\n length = remaining\n }\n }\n\n const strLen = string.length\n\n if (length > strLen / 2) {\n length = strLen / 2\n }\n let i\n for (i = 0; i < length; ++i) {\n const parsed = parseInt(string.substr(i * 2, 2), 16)\n if (numberIsNaN(parsed)) return i\n buf[offset + i] = parsed\n }\n return i\n}\n\nfunction utf8Write (buf, string, offset, length) {\n return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nfunction asciiWrite (buf, string, offset, length) {\n return blitBuffer(asciiToBytes(string), buf, offset, length)\n}\n\nfunction base64Write (buf, string, offset, length) {\n return blitBuffer(base64ToBytes(string), buf, offset, length)\n}\n\nfunction ucs2Write (buf, string, offset, length) {\n return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)\n}\n\nBuffer.prototype.write = function write (string, offset, length, encoding) {\n // Buffer#write(string)\n if (offset === undefined) {\n encoding = 'utf8'\n length = this.length\n offset = 0\n // Buffer#write(string, encoding)\n } else if (length === undefined && typeof offset === 'string') {\n encoding = offset\n length = this.length\n offset = 0\n // Buffer#write(string, offset[, length][, encoding])\n } else if (isFinite(offset)) {\n offset = offset >>> 0\n if (isFinite(length)) {\n length = length >>> 0\n if (encoding === undefined) encoding = 'utf8'\n } else {\n encoding = length\n length = undefined\n }\n } else {\n throw new Error(\n 'Buffer.write(string, encoding, offset[, length]) is no longer supported'\n )\n }\n\n const remaining = this.length - offset\n if (length === undefined || length > remaining) length = remaining\n\n if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {\n throw new RangeError('Attempt to write outside buffer bounds')\n }\n\n if (!encoding) encoding = 'utf8'\n\n let loweredCase = false\n for (;;) {\n switch (encoding) {\n case 'hex':\n return hexWrite(this, string, offset, length)\n\n case 'utf8':\n case 'utf-8':\n return utf8Write(this, string, offset, length)\n\n case 'ascii':\n case 'latin1':\n case 'binary':\n return asciiWrite(this, string, offset, length)\n\n case 'base64':\n // Warning: maxLength not taken into account in base64Write\n return base64Write(this, string, offset, length)\n\n case 'ucs2':\n case 'ucs-2':\n case 'utf16le':\n case 'utf-16le':\n return ucs2Write(this, string, offset, length)\n\n default:\n if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)\n encoding = ('' + encoding).toLowerCase()\n loweredCase = true\n }\n }\n}\n\nBuffer.prototype.toJSON = function toJSON () {\n return {\n type: 'Buffer',\n data: Array.prototype.slice.call(this._arr || this, 0)\n }\n}\n\nfunction base64Slice (buf, start, end) {\n if (start === 0 && end === buf.length) {\n return base64.fromByteArray(buf)\n } else {\n return base64.fromByteArray(buf.slice(start, end))\n }\n}\n\nfunction utf8Slice (buf, start, end) {\n end = Math.min(buf.length, end)\n const res = []\n\n let i = start\n while (i < end) {\n const firstByte = buf[i]\n let codePoint = null\n let bytesPerSequence = (firstByte > 0xEF)\n ? 4\n : (firstByte > 0xDF)\n ? 3\n : (firstByte > 0xBF)\n ? 2\n : 1\n\n if (i + bytesPerSequence <= end) {\n let secondByte, thirdByte, fourthByte, tempCodePoint\n\n switch (bytesPerSequence) {\n case 1:\n if (firstByte < 0x80) {\n codePoint = firstByte\n }\n break\n case 2:\n secondByte = buf[i + 1]\n if ((secondByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)\n if (tempCodePoint > 0x7F) {\n codePoint = tempCodePoint\n }\n }\n break\n case 3:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)\n if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {\n codePoint = tempCodePoint\n }\n }\n break\n case 4:\n secondByte = buf[i + 1]\n thirdByte = buf[i + 2]\n fourthByte = buf[i + 3]\n if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {\n tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)\n if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {\n codePoint = tempCodePoint\n }\n }\n }\n }\n\n if (codePoint === null) {\n // we did not generate a valid codePoint so insert a\n // replacement char (U+FFFD) and advance only 1 byte\n codePoint = 0xFFFD\n bytesPerSequence = 1\n } else if (codePoint > 0xFFFF) {\n // encode to utf16 (surrogate pair dance)\n codePoint -= 0x10000\n res.push(codePoint >>> 10 & 0x3FF | 0xD800)\n codePoint = 0xDC00 | codePoint & 0x3FF\n }\n\n res.push(codePoint)\n i += bytesPerSequence\n }\n\n return decodeCodePointsArray(res)\n}\n\n// Based on http://stackoverflow.com/a/22747272/680742, the browser with\n// the lowest limit is Chrome, with 0x10000 args.\n// We go 1 magnitude less, for safety\nconst MAX_ARGUMENTS_LENGTH = 0x1000\n\nfunction decodeCodePointsArray (codePoints) {\n const len = codePoints.length\n if (len <= MAX_ARGUMENTS_LENGTH) {\n return String.fromCharCode.apply(String, codePoints) // avoid extra slice()\n }\n\n // Decode in chunks to avoid \"call stack size exceeded\".\n let res = ''\n let i = 0\n while (i < len) {\n res += String.fromCharCode.apply(\n String,\n codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)\n )\n }\n return res\n}\n\nfunction asciiSlice (buf, start, end) {\n let ret = ''\n end = Math.min(buf.length, end)\n\n for (let i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i] & 0x7F)\n }\n return ret\n}\n\nfunction latin1Slice (buf, start, end) {\n let ret = ''\n end = Math.min(buf.length, end)\n\n for (let i = start; i < end; ++i) {\n ret += String.fromCharCode(buf[i])\n }\n return ret\n}\n\nfunction hexSlice (buf, start, end) {\n const len = buf.length\n\n if (!start || start < 0) start = 0\n if (!end || end < 0 || end > len) end = len\n\n let out = ''\n for (let i = start; i < end; ++i) {\n out += hexSliceLookupTable[buf[i]]\n }\n return out\n}\n\nfunction utf16leSlice (buf, start, end) {\n const bytes = buf.slice(start, end)\n let res = ''\n // If bytes.length is odd, the last 8 bits must be ignored (same as node.js)\n for (let i = 0; i < bytes.length - 1; i += 2) {\n res += String.fromCharCode(bytes[i] + (bytes[i + 1] * 256))\n }\n return res\n}\n\nBuffer.prototype.slice = function slice (start, end) {\n const len = this.length\n start = ~~start\n end = end === undefined ? len : ~~end\n\n if (start < 0) {\n start += len\n if (start < 0) start = 0\n } else if (start > len) {\n start = len\n }\n\n if (end < 0) {\n end += len\n if (end < 0) end = 0\n } else if (end > len) {\n end = len\n }\n\n if (end < start) end = start\n\n const newBuf = this.subarray(start, end)\n // Return an augmented `Uint8Array` instance\n Object.setPrototypeOf(newBuf, Buffer.prototype)\n\n return newBuf\n}\n\n/*\n * Need to make sure that buffer isn't trying to write out of bounds.\n */\nfunction checkOffset (offset, ext, length) {\n if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')\n if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')\n}\n\nBuffer.prototype.readUintLE =\nBuffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let val = this[offset]\n let mul = 1\n let i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUintBE =\nBuffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n checkOffset(offset, byteLength, this.length)\n }\n\n let val = this[offset + --byteLength]\n let mul = 1\n while (byteLength > 0 && (mul *= 0x100)) {\n val += this[offset + --byteLength] * mul\n }\n\n return val\n}\n\nBuffer.prototype.readUint8 =\nBuffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n return this[offset]\n}\n\nBuffer.prototype.readUint16LE =\nBuffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return this[offset] | (this[offset + 1] << 8)\n}\n\nBuffer.prototype.readUint16BE =\nBuffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n return (this[offset] << 8) | this[offset + 1]\n}\n\nBuffer.prototype.readUint32LE =\nBuffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return ((this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16)) +\n (this[offset + 3] * 0x1000000)\n}\n\nBuffer.prototype.readUint32BE =\nBuffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] * 0x1000000) +\n ((this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n this[offset + 3])\n}\n\nBuffer.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const lo = first +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 24\n\n const hi = this[++offset] +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n last * 2 ** 24\n\n return BigInt(lo) + (BigInt(hi) << BigInt(32))\n})\n\nBuffer.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const hi = first * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n this[++offset]\n\n const lo = this[++offset] * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n last\n\n return (BigInt(hi) << BigInt(32)) + BigInt(lo)\n})\n\nBuffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let val = this[offset]\n let mul = 1\n let i = 0\n while (++i < byteLength && (mul *= 0x100)) {\n val += this[offset + i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) checkOffset(offset, byteLength, this.length)\n\n let i = byteLength\n let mul = 1\n let val = this[offset + --i]\n while (i > 0 && (mul *= 0x100)) {\n val += this[offset + --i] * mul\n }\n mul *= 0x80\n\n if (val >= mul) val -= Math.pow(2, 8 * byteLength)\n\n return val\n}\n\nBuffer.prototype.readInt8 = function readInt8 (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 1, this.length)\n if (!(this[offset] & 0x80)) return (this[offset])\n return ((0xff - this[offset] + 1) * -1)\n}\n\nBuffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n const val = this[offset] | (this[offset + 1] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 2, this.length)\n const val = this[offset + 1] | (this[offset] << 8)\n return (val & 0x8000) ? val | 0xFFFF0000 : val\n}\n\nBuffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset]) |\n (this[offset + 1] << 8) |\n (this[offset + 2] << 16) |\n (this[offset + 3] << 24)\n}\n\nBuffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n\n return (this[offset] << 24) |\n (this[offset + 1] << 16) |\n (this[offset + 2] << 8) |\n (this[offset + 3])\n}\n\nBuffer.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const val = this[offset + 4] +\n this[offset + 5] * 2 ** 8 +\n this[offset + 6] * 2 ** 16 +\n (last << 24) // Overflow\n\n return (BigInt(val) << BigInt(32)) +\n BigInt(first +\n this[++offset] * 2 ** 8 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 24)\n})\n\nBuffer.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE (offset) {\n offset = offset >>> 0\n validateNumber(offset, 'offset')\n const first = this[offset]\n const last = this[offset + 7]\n if (first === undefined || last === undefined) {\n boundsError(offset, this.length - 8)\n }\n\n const val = (first << 24) + // Overflow\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n this[++offset]\n\n return (BigInt(val) << BigInt(32)) +\n BigInt(this[++offset] * 2 ** 24 +\n this[++offset] * 2 ** 16 +\n this[++offset] * 2 ** 8 +\n last)\n})\n\nBuffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, true, 23, 4)\n}\n\nBuffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 4, this.length)\n return ieee754.read(this, offset, false, 23, 4)\n}\n\nBuffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, true, 52, 8)\n}\n\nBuffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {\n offset = offset >>> 0\n if (!noAssert) checkOffset(offset, 8, this.length)\n return ieee754.read(this, offset, false, 52, 8)\n}\n\nfunction checkInt (buf, value, offset, ext, max, min) {\n if (!Buffer.isBuffer(buf)) throw new TypeError('\"buffer\" argument must be a Buffer instance')\n if (value > max || value < min) throw new RangeError('\"value\" argument is out of bounds')\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n}\n\nBuffer.prototype.writeUintLE =\nBuffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n const maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n let mul = 1\n let i = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUintBE =\nBuffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n byteLength = byteLength >>> 0\n if (!noAssert) {\n const maxBytes = Math.pow(2, 8 * byteLength) - 1\n checkInt(this, value, offset, byteLength, maxBytes, 0)\n }\n\n let i = byteLength - 1\n let mul = 1\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n this[offset + i] = (value / mul) & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeUint8 =\nBuffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeUint16LE =\nBuffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeUint16BE =\nBuffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeUint32LE =\nBuffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset + 3] = (value >>> 24)\n this[offset + 2] = (value >>> 16)\n this[offset + 1] = (value >>> 8)\n this[offset] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeUint32BE =\nBuffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nfunction wrtBigUInt64LE (buf, value, offset, min, max) {\n checkIntBI(value, min, max, buf, offset, 7)\n\n let lo = Number(value & BigInt(0xffffffff))\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n lo = lo >> 8\n buf[offset++] = lo\n let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n hi = hi >> 8\n buf[offset++] = hi\n return offset\n}\n\nfunction wrtBigUInt64BE (buf, value, offset, min, max) {\n checkIntBI(value, min, max, buf, offset, 7)\n\n let lo = Number(value & BigInt(0xffffffff))\n buf[offset + 7] = lo\n lo = lo >> 8\n buf[offset + 6] = lo\n lo = lo >> 8\n buf[offset + 5] = lo\n lo = lo >> 8\n buf[offset + 4] = lo\n let hi = Number(value >> BigInt(32) & BigInt(0xffffffff))\n buf[offset + 3] = hi\n hi = hi >> 8\n buf[offset + 2] = hi\n hi = hi >> 8\n buf[offset + 1] = hi\n hi = hi >> 8\n buf[offset] = hi\n return offset + 8\n}\n\nBuffer.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE (value, offset = 0) {\n return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))\n})\n\nBuffer.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE (value, offset = 0) {\n return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt('0xffffffffffffffff'))\n})\n\nBuffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n const limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n let i = 0\n let mul = 1\n let sub = 0\n this[offset] = value & 0xFF\n while (++i < byteLength && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n const limit = Math.pow(2, (8 * byteLength) - 1)\n\n checkInt(this, value, offset, byteLength, limit - 1, -limit)\n }\n\n let i = byteLength - 1\n let mul = 1\n let sub = 0\n this[offset + i] = value & 0xFF\n while (--i >= 0 && (mul *= 0x100)) {\n if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {\n sub = 1\n }\n this[offset + i] = ((value / mul) >> 0) - sub & 0xFF\n }\n\n return offset + byteLength\n}\n\nBuffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)\n if (value < 0) value = 0xff + value + 1\n this[offset] = (value & 0xff)\n return offset + 1\n}\n\nBuffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n return offset + 2\n}\n\nBuffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)\n this[offset] = (value >>> 8)\n this[offset + 1] = (value & 0xff)\n return offset + 2\n}\n\nBuffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n this[offset] = (value & 0xff)\n this[offset + 1] = (value >>> 8)\n this[offset + 2] = (value >>> 16)\n this[offset + 3] = (value >>> 24)\n return offset + 4\n}\n\nBuffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)\n if (value < 0) value = 0xffffffff + value + 1\n this[offset] = (value >>> 24)\n this[offset + 1] = (value >>> 16)\n this[offset + 2] = (value >>> 8)\n this[offset + 3] = (value & 0xff)\n return offset + 4\n}\n\nBuffer.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE (value, offset = 0) {\n return wrtBigUInt64LE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))\n})\n\nBuffer.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE (value, offset = 0) {\n return wrtBigUInt64BE(this, value, offset, -BigInt('0x8000000000000000'), BigInt('0x7fffffffffffffff'))\n})\n\nfunction checkIEEE754 (buf, value, offset, ext, max, min) {\n if (offset + ext > buf.length) throw new RangeError('Index out of range')\n if (offset < 0) throw new RangeError('Index out of range')\n}\n\nfunction writeFloat (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)\n }\n ieee754.write(buf, value, offset, littleEndian, 23, 4)\n return offset + 4\n}\n\nBuffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {\n return writeFloat(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {\n return writeFloat(this, value, offset, false, noAssert)\n}\n\nfunction writeDouble (buf, value, offset, littleEndian, noAssert) {\n value = +value\n offset = offset >>> 0\n if (!noAssert) {\n checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)\n }\n ieee754.write(buf, value, offset, littleEndian, 52, 8)\n return offset + 8\n}\n\nBuffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {\n return writeDouble(this, value, offset, true, noAssert)\n}\n\nBuffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {\n return writeDouble(this, value, offset, false, noAssert)\n}\n\n// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)\nBuffer.prototype.copy = function copy (target, targetStart, start, end) {\n if (!Buffer.isBuffer(target)) throw new TypeError('argument should be a Buffer')\n if (!start) start = 0\n if (!end && end !== 0) end = this.length\n if (targetStart >= target.length) targetStart = target.length\n if (!targetStart) targetStart = 0\n if (end > 0 && end < start) end = start\n\n // Copy 0 bytes; we're done\n if (end === start) return 0\n if (target.length === 0 || this.length === 0) return 0\n\n // Fatal error conditions\n if (targetStart < 0) {\n throw new RangeError('targetStart out of bounds')\n }\n if (start < 0 || start >= this.length) throw new RangeError('Index out of range')\n if (end < 0) throw new RangeError('sourceEnd out of bounds')\n\n // Are we oob?\n if (end > this.length) end = this.length\n if (target.length - targetStart < end - start) {\n end = target.length - targetStart + start\n }\n\n const len = end - start\n\n if (this === target && typeof Uint8Array.prototype.copyWithin === 'function') {\n // Use built-in when available, missing from IE11\n this.copyWithin(targetStart, start, end)\n } else {\n Uint8Array.prototype.set.call(\n target,\n this.subarray(start, end),\n targetStart\n )\n }\n\n return len\n}\n\n// Usage:\n// buffer.fill(number[, offset[, end]])\n// buffer.fill(buffer[, offset[, end]])\n// buffer.fill(string[, offset[, end]][, encoding])\nBuffer.prototype.fill = function fill (val, start, end, encoding) {\n // Handle string cases:\n if (typeof val === 'string') {\n if (typeof start === 'string') {\n encoding = start\n start = 0\n end = this.length\n } else if (typeof end === 'string') {\n encoding = end\n end = this.length\n }\n if (encoding !== undefined && typeof encoding !== 'string') {\n throw new TypeError('encoding must be a string')\n }\n if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {\n throw new TypeError('Unknown encoding: ' + encoding)\n }\n if (val.length === 1) {\n const code = val.charCodeAt(0)\n if ((encoding === 'utf8' && code < 128) ||\n encoding === 'latin1') {\n // Fast path: If `val` fits into a single byte, use that numeric value.\n val = code\n }\n }\n } else if (typeof val === 'number') {\n val = val & 255\n } else if (typeof val === 'boolean') {\n val = Number(val)\n }\n\n // Invalid ranges are not set to a default, so can range check early.\n if (start < 0 || this.length < start || this.length < end) {\n throw new RangeError('Out of range index')\n }\n\n if (end <= start) {\n return this\n }\n\n start = start >>> 0\n end = end === undefined ? this.length : end >>> 0\n\n if (!val) val = 0\n\n let i\n if (typeof val === 'number') {\n for (i = start; i < end; ++i) {\n this[i] = val\n }\n } else {\n const bytes = Buffer.isBuffer(val)\n ? val\n : Buffer.from(val, encoding)\n const len = bytes.length\n if (len === 0) {\n throw new TypeError('The value \"' + val +\n '\" is invalid for argument \"value\"')\n }\n for (i = 0; i < end - start; ++i) {\n this[i + start] = bytes[i % len]\n }\n }\n\n return this\n}\n\n// CUSTOM ERRORS\n// =============\n\n// Simplified versions from Node, changed for Buffer-only usage\nconst errors = {}\nfunction E (sym, getMessage, Base) {\n errors[sym] = class NodeError extends Base {\n constructor () {\n super()\n\n Object.defineProperty(this, 'message', {\n value: getMessage.apply(this, arguments),\n writable: true,\n configurable: true\n })\n\n // Add the error code to the name to include it in the stack trace.\n this.name = `${this.name} [${sym}]`\n // Access the stack to generate the error message including the error code\n // from the name.\n this.stack // eslint-disable-line no-unused-expressions\n // Reset the name to the actual name.\n delete this.name\n }\n\n get code () {\n return sym\n }\n\n set code (value) {\n Object.defineProperty(this, 'code', {\n configurable: true,\n enumerable: true,\n value,\n writable: true\n })\n }\n\n toString () {\n return `${this.name} [${sym}]: ${this.message}`\n }\n }\n}\n\nE('ERR_BUFFER_OUT_OF_BOUNDS',\n function (name) {\n if (name) {\n return `${name} is outside of buffer bounds`\n }\n\n return 'Attempt to access memory outside buffer bounds'\n }, RangeError)\nE('ERR_INVALID_ARG_TYPE',\n function (name, actual) {\n return `The \"${name}\" argument must be of type number. Received type ${typeof actual}`\n }, TypeError)\nE('ERR_OUT_OF_RANGE',\n function (str, range, input) {\n let msg = `The value of \"${str}\" is out of range.`\n let received = input\n if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {\n received = addNumericalSeparator(String(input))\n } else if (typeof input === 'bigint') {\n received = String(input)\n if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {\n received = addNumericalSeparator(received)\n }\n received += 'n'\n }\n msg += ` It must be ${range}. Received ${received}`\n return msg\n }, RangeError)\n\nfunction addNumericalSeparator (val) {\n let res = ''\n let i = val.length\n const start = val[0] === '-' ? 1 : 0\n for (; i >= start + 4; i -= 3) {\n res = `_${val.slice(i - 3, i)}${res}`\n }\n return `${val.slice(0, i)}${res}`\n}\n\n// CHECK FUNCTIONS\n// ===============\n\nfunction checkBounds (buf, offset, byteLength) {\n validateNumber(offset, 'offset')\n if (buf[offset] === undefined || buf[offset + byteLength] === undefined) {\n boundsError(offset, buf.length - (byteLength + 1))\n }\n}\n\nfunction checkIntBI (value, min, max, buf, offset, byteLength) {\n if (value > max || value < min) {\n const n = typeof min === 'bigint' ? 'n' : ''\n let range\n if (byteLength > 3) {\n if (min === 0 || min === BigInt(0)) {\n range = `>= 0${n} and < 2${n} ** ${(byteLength + 1) * 8}${n}`\n } else {\n range = `>= -(2${n} ** ${(byteLength + 1) * 8 - 1}${n}) and < 2 ** ` +\n `${(byteLength + 1) * 8 - 1}${n}`\n }\n } else {\n range = `>= ${min}${n} and <= ${max}${n}`\n }\n throw new errors.ERR_OUT_OF_RANGE('value', range, value)\n }\n checkBounds(buf, offset, byteLength)\n}\n\nfunction validateNumber (value, name) {\n if (typeof value !== 'number') {\n throw new errors.ERR_INVALID_ARG_TYPE(name, 'number', value)\n }\n}\n\nfunction boundsError (value, length, type) {\n if (Math.floor(value) !== value) {\n validateNumber(value, type)\n throw new errors.ERR_OUT_OF_RANGE(type || 'offset', 'an integer', value)\n }\n\n if (length < 0) {\n throw new errors.ERR_BUFFER_OUT_OF_BOUNDS()\n }\n\n throw new errors.ERR_OUT_OF_RANGE(type || 'offset',\n `>= ${type ? 1 : 0} and <= ${length}`,\n value)\n}\n\n// HELPER FUNCTIONS\n// ================\n\nconst INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g\n\nfunction base64clean (str) {\n // Node takes equal signs as end of the Base64 encoding\n str = str.split('=')[0]\n // Node strips out invalid characters like \\n and \\t from the string, base64-js does not\n str = str.trim().replace(INVALID_BASE64_RE, '')\n // Node converts strings with length < 2 to ''\n if (str.length < 2) return ''\n // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not\n while (str.length % 4 !== 0) {\n str = str + '='\n }\n return str\n}\n\nfunction utf8ToBytes (string, units) {\n units = units || Infinity\n let codePoint\n const length = string.length\n let leadSurrogate = null\n const bytes = []\n\n for (let i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n\nfunction asciiToBytes (str) {\n const byteArray = []\n for (let i = 0; i < str.length; ++i) {\n // Node's code seems to be doing this and not & 0x7F..\n byteArray.push(str.charCodeAt(i) & 0xFF)\n }\n return byteArray\n}\n\nfunction utf16leToBytes (str, units) {\n let c, hi, lo\n const byteArray = []\n for (let i = 0; i < str.length; ++i) {\n if ((units -= 2) < 0) break\n\n c = str.charCodeAt(i)\n hi = c >> 8\n lo = c % 256\n byteArray.push(lo)\n byteArray.push(hi)\n }\n\n return byteArray\n}\n\nfunction base64ToBytes (str) {\n return base64.toByteArray(base64clean(str))\n}\n\nfunction blitBuffer (src, dst, offset, length) {\n let i\n for (i = 0; i < length; ++i) {\n if ((i + offset >= dst.length) || (i >= src.length)) break\n dst[i + offset] = src[i]\n }\n return i\n}\n\n// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass\n// the `instanceof` check but they should be treated as of that type.\n// See: https://github.com/feross/buffer/issues/166\nfunction isInstance (obj, type) {\n return obj instanceof type ||\n (obj != null && obj.constructor != null && obj.constructor.name != null &&\n obj.constructor.name === type.name)\n}\nfunction numberIsNaN (obj) {\n // For IE11 support\n return obj !== obj // eslint-disable-line no-self-compare\n}\n\n// Create lookup table for `toString('hex')`\n// See: https://github.com/feross/buffer/issues/219\nconst hexSliceLookupTable = (function () {\n const alphabet = '0123456789abcdef'\n const table = new Array(256)\n for (let i = 0; i < 16; ++i) {\n const i16 = i * 16\n for (let j = 0; j < 16; ++j) {\n table[i16 + j] = alphabet[i] + alphabet[j]\n }\n }\n return table\n})()\n\n// Return not function with Error if BigInt not supported\nfunction defineBigIntMethod (fn) {\n return typeof BigInt === 'undefined' ? BufferBigIntNotDefined : fn\n}\n\nfunction BufferBigIntNotDefined () {\n throw new Error('BigInt not supported')\n}\n","'use strict'\n\nexports.byteLength = byteLength\nexports.toByteArray = toByteArray\nexports.fromByteArray = fromByteArray\n\nvar lookup = []\nvar revLookup = []\nvar Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array\n\nvar code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\nfor (var i = 0, len = code.length; i < len; ++i) {\n lookup[i] = code[i]\n revLookup[code.charCodeAt(i)] = i\n}\n\n// Support decoding URL-safe base64 strings, as Node.js does.\n// See: https://en.wikipedia.org/wiki/Base64#URL_applications\nrevLookup['-'.charCodeAt(0)] = 62\nrevLookup['_'.charCodeAt(0)] = 63\n\nfunction getLens (b64) {\n var len = b64.length\n\n if (len % 4 > 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n var i\n for (i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","import { Buffer } from 'buffer';\nimport { ed25519 } from '@noble/curves/ed25519';\nimport BN from 'bn.js';\nimport bs58 from 'bs58';\nimport { sha256 } from '@noble/hashes/sha256';\nimport { serialize, deserialize, deserializeUnchecked } from 'borsh';\nimport * as BufferLayout from '@solana/buffer-layout';\nimport { blob } from '@solana/buffer-layout';\nimport { toBigIntLE, toBufferLE } from 'bigint-buffer';\nimport { coerce, instance, string, tuple, literal, unknown, type, number, array, nullable, optional, boolean, record, union, create, any, assert as assert$1 } from 'superstruct';\nimport RpcClient from 'jayson/lib/client/browser';\nimport { CommonClient, WebSocket } from 'rpc-websockets';\nimport { keccak_256 } from '@noble/hashes/sha3';\nimport { secp256k1 } from '@noble/curves/secp256k1';\n\n/**\n * A 64 byte secret key, the first 32 bytes of which is the\n * private scalar and the last 32 bytes is the public key.\n * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/\n */\n\n/**\n * Ed25519 Keypair\n */\n\nconst generatePrivateKey = ed25519.utils.randomPrivateKey;\nconst generateKeypair = () => {\n const privateScalar = ed25519.utils.randomPrivateKey();\n const publicKey = getPublicKey(privateScalar);\n const secretKey = new Uint8Array(64);\n secretKey.set(privateScalar);\n secretKey.set(publicKey, 32);\n return {\n publicKey,\n secretKey\n };\n};\nconst getPublicKey = ed25519.getPublicKey;\nfunction isOnCurve(publicKey) {\n try {\n ed25519.ExtendedPoint.fromHex(publicKey);\n return true;\n } catch {\n return false;\n }\n}\nconst sign = (message, secretKey) => ed25519.sign(message, secretKey.slice(0, 32));\nconst verify = ed25519.verify;\n\nconst toBuffer = arr => {\n if (Buffer.isBuffer(arr)) {\n return arr;\n } else if (arr instanceof Uint8Array) {\n return Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength);\n } else {\n return Buffer.from(arr);\n }\n};\n\n// Class wrapping a plain object\nclass Struct {\n constructor(properties) {\n Object.assign(this, properties);\n }\n encode() {\n return Buffer.from(serialize(SOLANA_SCHEMA, this));\n }\n static decode(data) {\n return deserialize(SOLANA_SCHEMA, this, data);\n }\n static decodeUnchecked(data) {\n return deserializeUnchecked(SOLANA_SCHEMA, this, data);\n }\n}\n\n// Class representing a Rust-compatible enum, since enums are only strings or\n// numbers in pure JS\nclass Enum extends Struct {\n constructor(properties) {\n super(properties);\n this.enum = '';\n if (Object.keys(properties).length !== 1) {\n throw new Error('Enum can only take single value');\n }\n Object.keys(properties).map(key => {\n this.enum = key;\n });\n }\n}\nconst SOLANA_SCHEMA = new Map();\n\nvar _PublicKey;\n\n/**\n * Maximum length of derived pubkey seed\n */\nconst MAX_SEED_LENGTH = 32;\n\n/**\n * Size of public key in bytes\n */\nconst PUBLIC_KEY_LENGTH = 32;\n\n/**\n * Value to be converted into public key\n */\n\n/**\n * JSON object representation of PublicKey class\n */\n\nfunction isPublicKeyData(value) {\n return value._bn !== undefined;\n}\n\n// local counter used by PublicKey.unique()\nlet uniquePublicKeyCounter = 1;\n\n/**\n * A public key\n */\nclass PublicKey extends Struct {\n /**\n * Create a new PublicKey object\n * @param value ed25519 public key as buffer or base-58 encoded string\n */\n constructor(value) {\n super({});\n /** @internal */\n this._bn = void 0;\n if (isPublicKeyData(value)) {\n this._bn = value._bn;\n } else {\n if (typeof value === 'string') {\n // assume base 58 encoding by default\n const decoded = bs58.decode(value);\n if (decoded.length != PUBLIC_KEY_LENGTH) {\n throw new Error(`Invalid public key input`);\n }\n this._bn = new BN(decoded);\n } else {\n this._bn = new BN(value);\n }\n if (this._bn.byteLength() > PUBLIC_KEY_LENGTH) {\n throw new Error(`Invalid public key input`);\n }\n }\n }\n\n /**\n * Returns a unique PublicKey for tests and benchmarks using a counter\n */\n static unique() {\n const key = new PublicKey(uniquePublicKeyCounter);\n uniquePublicKeyCounter += 1;\n return new PublicKey(key.toBuffer());\n }\n\n /**\n * Default public key value. The base58-encoded string representation is all ones (as seen below)\n * The underlying BN number is 32 bytes that are all zeros\n */\n\n /**\n * Checks if two publicKeys are equal\n */\n equals(publicKey) {\n return this._bn.eq(publicKey._bn);\n }\n\n /**\n * Return the base-58 representation of the public key\n */\n toBase58() {\n return bs58.encode(this.toBytes());\n }\n toJSON() {\n return this.toBase58();\n }\n\n /**\n * Return the byte array representation of the public key in big endian\n */\n toBytes() {\n const buf = this.toBuffer();\n return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);\n }\n\n /**\n * Return the Buffer representation of the public key in big endian\n */\n toBuffer() {\n const b = this._bn.toArrayLike(Buffer);\n if (b.length === PUBLIC_KEY_LENGTH) {\n return b;\n }\n const zeroPad = Buffer.alloc(32);\n b.copy(zeroPad, 32 - b.length);\n return zeroPad;\n }\n get [Symbol.toStringTag]() {\n return `PublicKey(${this.toString()})`;\n }\n\n /**\n * Return the base-58 representation of the public key\n */\n toString() {\n return this.toBase58();\n }\n\n /**\n * Derive a public key from another key, a seed, and a program ID.\n * The program ID will also serve as the owner of the public key, giving\n * it permission to write data to the account.\n */\n /* eslint-disable require-await */\n static async createWithSeed(fromPublicKey, seed, programId) {\n const buffer = Buffer.concat([fromPublicKey.toBuffer(), Buffer.from(seed), programId.toBuffer()]);\n const publicKeyBytes = sha256(buffer);\n return new PublicKey(publicKeyBytes);\n }\n\n /**\n * Derive a program address from seeds and a program ID.\n */\n /* eslint-disable require-await */\n static createProgramAddressSync(seeds, programId) {\n let buffer = Buffer.alloc(0);\n seeds.forEach(function (seed) {\n if (seed.length > MAX_SEED_LENGTH) {\n throw new TypeError(`Max seed length exceeded`);\n }\n buffer = Buffer.concat([buffer, toBuffer(seed)]);\n });\n buffer = Buffer.concat([buffer, programId.toBuffer(), Buffer.from('ProgramDerivedAddress')]);\n const publicKeyBytes = sha256(buffer);\n if (isOnCurve(publicKeyBytes)) {\n throw new Error(`Invalid seeds, address must fall off the curve`);\n }\n return new PublicKey(publicKeyBytes);\n }\n\n /**\n * Async version of createProgramAddressSync\n * For backwards compatibility\n *\n * @deprecated Use {@link createProgramAddressSync} instead\n */\n /* eslint-disable require-await */\n static async createProgramAddress(seeds, programId) {\n return this.createProgramAddressSync(seeds, programId);\n }\n\n /**\n * Find a valid program address\n *\n * Valid program addresses must fall off the ed25519 curve. This function\n * iterates a nonce until it finds one that when combined with the seeds\n * results in a valid program address.\n */\n static findProgramAddressSync(seeds, programId) {\n let nonce = 255;\n let address;\n while (nonce != 0) {\n try {\n const seedsWithNonce = seeds.concat(Buffer.from([nonce]));\n address = this.createProgramAddressSync(seedsWithNonce, programId);\n } catch (err) {\n if (err instanceof TypeError) {\n throw err;\n }\n nonce--;\n continue;\n }\n return [address, nonce];\n }\n throw new Error(`Unable to find a viable program address nonce`);\n }\n\n /**\n * Async version of findProgramAddressSync\n * For backwards compatibility\n *\n * @deprecated Use {@link findProgramAddressSync} instead\n */\n static async findProgramAddress(seeds, programId) {\n return this.findProgramAddressSync(seeds, programId);\n }\n\n /**\n * Check that a pubkey is on the ed25519 curve.\n */\n static isOnCurve(pubkeyData) {\n const pubkey = new PublicKey(pubkeyData);\n return isOnCurve(pubkey.toBytes());\n }\n}\n_PublicKey = PublicKey;\nPublicKey.default = new _PublicKey('11111111111111111111111111111111');\nSOLANA_SCHEMA.set(PublicKey, {\n kind: 'struct',\n fields: [['_bn', 'u256']]\n});\n\n/**\n * An account key pair (public and secret keys).\n *\n * @deprecated since v1.10.0, please use {@link Keypair} instead.\n */\nclass Account {\n /**\n * Create a new Account object\n *\n * If the secretKey parameter is not provided a new key pair is randomly\n * created for the account\n *\n * @param secretKey Secret key for the account\n */\n constructor(secretKey) {\n /** @internal */\n this._publicKey = void 0;\n /** @internal */\n this._secretKey = void 0;\n if (secretKey) {\n const secretKeyBuffer = toBuffer(secretKey);\n if (secretKey.length !== 64) {\n throw new Error('bad secret key size');\n }\n this._publicKey = secretKeyBuffer.slice(32, 64);\n this._secretKey = secretKeyBuffer.slice(0, 32);\n } else {\n this._secretKey = toBuffer(generatePrivateKey());\n this._publicKey = toBuffer(getPublicKey(this._secretKey));\n }\n }\n\n /**\n * The public key for this account\n */\n get publicKey() {\n return new PublicKey(this._publicKey);\n }\n\n /**\n * The **unencrypted** secret key for this account. The first 32 bytes\n * is the private scalar and the last 32 bytes is the public key.\n * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/\n */\n get secretKey() {\n return Buffer.concat([this._secretKey, this._publicKey], 64);\n }\n}\n\nconst BPF_LOADER_DEPRECATED_PROGRAM_ID = new PublicKey('BPFLoader1111111111111111111111111111111111');\n\n/**\n * Maximum over-the-wire size of a Transaction\n *\n * 1280 is IPv6 minimum MTU\n * 40 bytes is the size of the IPv6 header\n * 8 bytes is the size of the fragment header\n */\nconst PACKET_DATA_SIZE = 1280 - 40 - 8;\nconst VERSION_PREFIX_MASK = 0x7f;\nconst SIGNATURE_LENGTH_IN_BYTES = 64;\n\nclass TransactionExpiredBlockheightExceededError extends Error {\n constructor(signature) {\n super(`Signature ${signature} has expired: block height exceeded.`);\n this.signature = void 0;\n this.signature = signature;\n }\n}\nObject.defineProperty(TransactionExpiredBlockheightExceededError.prototype, 'name', {\n value: 'TransactionExpiredBlockheightExceededError'\n});\nclass TransactionExpiredTimeoutError extends Error {\n constructor(signature, timeoutSeconds) {\n super(`Transaction was not confirmed in ${timeoutSeconds.toFixed(2)} seconds. It is ` + 'unknown if it succeeded or failed. Check signature ' + `${signature} using the Solana Explorer or CLI tools.`);\n this.signature = void 0;\n this.signature = signature;\n }\n}\nObject.defineProperty(TransactionExpiredTimeoutError.prototype, 'name', {\n value: 'TransactionExpiredTimeoutError'\n});\nclass TransactionExpiredNonceInvalidError extends Error {\n constructor(signature) {\n super(`Signature ${signature} has expired: the nonce is no longer valid.`);\n this.signature = void 0;\n this.signature = signature;\n }\n}\nObject.defineProperty(TransactionExpiredNonceInvalidError.prototype, 'name', {\n value: 'TransactionExpiredNonceInvalidError'\n});\n\nclass MessageAccountKeys {\n constructor(staticAccountKeys, accountKeysFromLookups) {\n this.staticAccountKeys = void 0;\n this.accountKeysFromLookups = void 0;\n this.staticAccountKeys = staticAccountKeys;\n this.accountKeysFromLookups = accountKeysFromLookups;\n }\n keySegments() {\n const keySegments = [this.staticAccountKeys];\n if (this.accountKeysFromLookups) {\n keySegments.push(this.accountKeysFromLookups.writable);\n keySegments.push(this.accountKeysFromLookups.readonly);\n }\n return keySegments;\n }\n get(index) {\n for (const keySegment of this.keySegments()) {\n if (index < keySegment.length) {\n return keySegment[index];\n } else {\n index -= keySegment.length;\n }\n }\n return;\n }\n get length() {\n return this.keySegments().flat().length;\n }\n compileInstructions(instructions) {\n // Bail early if any account indexes would overflow a u8\n const U8_MAX = 255;\n if (this.length > U8_MAX + 1) {\n throw new Error('Account index overflow encountered during compilation');\n }\n const keyIndexMap = new Map();\n this.keySegments().flat().forEach((key, index) => {\n keyIndexMap.set(key.toBase58(), index);\n });\n const findKeyIndex = key => {\n const keyIndex = keyIndexMap.get(key.toBase58());\n if (keyIndex === undefined) throw new Error('Encountered an unknown instruction account key during compilation');\n return keyIndex;\n };\n return instructions.map(instruction => {\n return {\n programIdIndex: findKeyIndex(instruction.programId),\n accountKeyIndexes: instruction.keys.map(meta => findKeyIndex(meta.pubkey)),\n data: instruction.data\n };\n });\n }\n}\n\n/**\n * Layout for a public key\n */\nconst publicKey = (property = 'publicKey') => {\n return BufferLayout.blob(32, property);\n};\n\n/**\n * Layout for a signature\n */\nconst signature = (property = 'signature') => {\n return BufferLayout.blob(64, property);\n};\n/**\n * Layout for a Rust String type\n */\nconst rustString = (property = 'string') => {\n const rsl = BufferLayout.struct([BufferLayout.u32('length'), BufferLayout.u32('lengthPadding'), BufferLayout.blob(BufferLayout.offset(BufferLayout.u32(), -8), 'chars')], property);\n const _decode = rsl.decode.bind(rsl);\n const _encode = rsl.encode.bind(rsl);\n const rslShim = rsl;\n rslShim.decode = (b, offset) => {\n const data = _decode(b, offset);\n return data['chars'].toString();\n };\n rslShim.encode = (str, b, offset) => {\n const data = {\n chars: Buffer.from(str, 'utf8')\n };\n return _encode(data, b, offset);\n };\n rslShim.alloc = str => {\n return BufferLayout.u32().span + BufferLayout.u32().span + Buffer.from(str, 'utf8').length;\n };\n return rslShim;\n};\n\n/**\n * Layout for an Authorized object\n */\nconst authorized = (property = 'authorized') => {\n return BufferLayout.struct([publicKey('staker'), publicKey('withdrawer')], property);\n};\n\n/**\n * Layout for a Lockup object\n */\nconst lockup = (property = 'lockup') => {\n return BufferLayout.struct([BufferLayout.ns64('unixTimestamp'), BufferLayout.ns64('epoch'), publicKey('custodian')], property);\n};\n\n/**\n * Layout for a VoteInit object\n */\nconst voteInit = (property = 'voteInit') => {\n return BufferLayout.struct([publicKey('nodePubkey'), publicKey('authorizedVoter'), publicKey('authorizedWithdrawer'), BufferLayout.u8('commission')], property);\n};\n\n/**\n * Layout for a VoteAuthorizeWithSeedArgs object\n */\nconst voteAuthorizeWithSeedArgs = (property = 'voteAuthorizeWithSeedArgs') => {\n return BufferLayout.struct([BufferLayout.u32('voteAuthorizationType'), publicKey('currentAuthorityDerivedKeyOwnerPubkey'), rustString('currentAuthorityDerivedKeySeed'), publicKey('newAuthorized')], property);\n};\nfunction getAlloc(type, fields) {\n const getItemAlloc = item => {\n if (item.span >= 0) {\n return item.span;\n } else if (typeof item.alloc === 'function') {\n return item.alloc(fields[item.property]);\n } else if ('count' in item && 'elementLayout' in item) {\n const field = fields[item.property];\n if (Array.isArray(field)) {\n return field.length * getItemAlloc(item.elementLayout);\n }\n } else if ('fields' in item) {\n // This is a `Structure` whose size needs to be recursively measured.\n return getAlloc({\n layout: item\n }, fields[item.property]);\n }\n // Couldn't determine allocated size of layout\n return 0;\n };\n let alloc = 0;\n type.layout.fields.forEach(item => {\n alloc += getItemAlloc(item);\n });\n return alloc;\n}\n\nfunction decodeLength(bytes) {\n let len = 0;\n let size = 0;\n for (;;) {\n let elem = bytes.shift();\n len |= (elem & 0x7f) << size * 7;\n size += 1;\n if ((elem & 0x80) === 0) {\n break;\n }\n }\n return len;\n}\nfunction encodeLength(bytes, len) {\n let rem_len = len;\n for (;;) {\n let elem = rem_len & 0x7f;\n rem_len >>= 7;\n if (rem_len == 0) {\n bytes.push(elem);\n break;\n } else {\n elem |= 0x80;\n bytes.push(elem);\n }\n }\n}\n\nfunction assert (condition, message) {\n if (!condition) {\n throw new Error(message || 'Assertion failed');\n }\n}\n\nclass CompiledKeys {\n constructor(payer, keyMetaMap) {\n this.payer = void 0;\n this.keyMetaMap = void 0;\n this.payer = payer;\n this.keyMetaMap = keyMetaMap;\n }\n static compile(instructions, payer) {\n const keyMetaMap = new Map();\n const getOrInsertDefault = pubkey => {\n const address = pubkey.toBase58();\n let keyMeta = keyMetaMap.get(address);\n if (keyMeta === undefined) {\n keyMeta = {\n isSigner: false,\n isWritable: false,\n isInvoked: false\n };\n keyMetaMap.set(address, keyMeta);\n }\n return keyMeta;\n };\n const payerKeyMeta = getOrInsertDefault(payer);\n payerKeyMeta.isSigner = true;\n payerKeyMeta.isWritable = true;\n for (const ix of instructions) {\n getOrInsertDefault(ix.programId).isInvoked = true;\n for (const accountMeta of ix.keys) {\n const keyMeta = getOrInsertDefault(accountMeta.pubkey);\n keyMeta.isSigner ||= accountMeta.isSigner;\n keyMeta.isWritable ||= accountMeta.isWritable;\n }\n }\n return new CompiledKeys(payer, keyMetaMap);\n }\n getMessageComponents() {\n const mapEntries = [...this.keyMetaMap.entries()];\n assert(mapEntries.length <= 256, 'Max static account keys length exceeded');\n const writableSigners = mapEntries.filter(([, meta]) => meta.isSigner && meta.isWritable);\n const readonlySigners = mapEntries.filter(([, meta]) => meta.isSigner && !meta.isWritable);\n const writableNonSigners = mapEntries.filter(([, meta]) => !meta.isSigner && meta.isWritable);\n const readonlyNonSigners = mapEntries.filter(([, meta]) => !meta.isSigner && !meta.isWritable);\n const header = {\n numRequiredSignatures: writableSigners.length + readonlySigners.length,\n numReadonlySignedAccounts: readonlySigners.length,\n numReadonlyUnsignedAccounts: readonlyNonSigners.length\n };\n\n // sanity checks\n {\n assert(writableSigners.length > 0, 'Expected at least one writable signer key');\n const [payerAddress] = writableSigners[0];\n assert(payerAddress === this.payer.toBase58(), 'Expected first writable signer key to be the fee payer');\n }\n const staticAccountKeys = [...writableSigners.map(([address]) => new PublicKey(address)), ...readonlySigners.map(([address]) => new PublicKey(address)), ...writableNonSigners.map(([address]) => new PublicKey(address)), ...readonlyNonSigners.map(([address]) => new PublicKey(address))];\n return [header, staticAccountKeys];\n }\n extractTableLookup(lookupTable) {\n const [writableIndexes, drainedWritableKeys] = this.drainKeysFoundInLookupTable(lookupTable.state.addresses, keyMeta => !keyMeta.isSigner && !keyMeta.isInvoked && keyMeta.isWritable);\n const [readonlyIndexes, drainedReadonlyKeys] = this.drainKeysFoundInLookupTable(lookupTable.state.addresses, keyMeta => !keyMeta.isSigner && !keyMeta.isInvoked && !keyMeta.isWritable);\n\n // Don't extract lookup if no keys were found\n if (writableIndexes.length === 0 && readonlyIndexes.length === 0) {\n return;\n }\n return [{\n accountKey: lookupTable.key,\n writableIndexes,\n readonlyIndexes\n }, {\n writable: drainedWritableKeys,\n readonly: drainedReadonlyKeys\n }];\n }\n\n /** @internal */\n drainKeysFoundInLookupTable(lookupTableEntries, keyMetaFilter) {\n const lookupTableIndexes = new Array();\n const drainedKeys = new Array();\n for (const [address, keyMeta] of this.keyMetaMap.entries()) {\n if (keyMetaFilter(keyMeta)) {\n const key = new PublicKey(address);\n const lookupTableIndex = lookupTableEntries.findIndex(entry => entry.equals(key));\n if (lookupTableIndex >= 0) {\n assert(lookupTableIndex < 256, 'Max lookup table index exceeded');\n lookupTableIndexes.push(lookupTableIndex);\n drainedKeys.push(key);\n this.keyMetaMap.delete(address);\n }\n }\n }\n return [lookupTableIndexes, drainedKeys];\n }\n}\n\nconst END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';\n\n/**\n * Delegates to `Array#shift`, but throws if the array is zero-length.\n */\nfunction guardedShift(byteArray) {\n if (byteArray.length === 0) {\n throw new Error(END_OF_BUFFER_ERROR_MESSAGE);\n }\n return byteArray.shift();\n}\n\n/**\n * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of\n * the array.\n */\nfunction guardedSplice(byteArray, ...args) {\n const [start] = args;\n if (args.length === 2 // Implies that `deleteCount` was supplied\n ? start + (args[1] ?? 0) > byteArray.length : start >= byteArray.length) {\n throw new Error(END_OF_BUFFER_ERROR_MESSAGE);\n }\n return byteArray.splice(...args);\n}\n\n/**\n * An instruction to execute by a program\n *\n * @property {number} programIdIndex\n * @property {number[]} accounts\n * @property {string} data\n */\n\n/**\n * Message constructor arguments\n */\n\n/**\n * List of instructions to be processed atomically\n */\nclass Message {\n constructor(args) {\n this.header = void 0;\n this.accountKeys = void 0;\n this.recentBlockhash = void 0;\n this.instructions = void 0;\n this.indexToProgramIds = new Map();\n this.header = args.header;\n this.accountKeys = args.accountKeys.map(account => new PublicKey(account));\n this.recentBlockhash = args.recentBlockhash;\n this.instructions = args.instructions;\n this.instructions.forEach(ix => this.indexToProgramIds.set(ix.programIdIndex, this.accountKeys[ix.programIdIndex]));\n }\n get version() {\n return 'legacy';\n }\n get staticAccountKeys() {\n return this.accountKeys;\n }\n get compiledInstructions() {\n return this.instructions.map(ix => ({\n programIdIndex: ix.programIdIndex,\n accountKeyIndexes: ix.accounts,\n data: bs58.decode(ix.data)\n }));\n }\n get addressTableLookups() {\n return [];\n }\n getAccountKeys() {\n return new MessageAccountKeys(this.staticAccountKeys);\n }\n static compile(args) {\n const compiledKeys = CompiledKeys.compile(args.instructions, args.payerKey);\n const [header, staticAccountKeys] = compiledKeys.getMessageComponents();\n const accountKeys = new MessageAccountKeys(staticAccountKeys);\n const instructions = accountKeys.compileInstructions(args.instructions).map(ix => ({\n programIdIndex: ix.programIdIndex,\n accounts: ix.accountKeyIndexes,\n data: bs58.encode(ix.data)\n }));\n return new Message({\n header,\n accountKeys: staticAccountKeys,\n recentBlockhash: args.recentBlockhash,\n instructions\n });\n }\n isAccountSigner(index) {\n return index < this.header.numRequiredSignatures;\n }\n isAccountWritable(index) {\n const numSignedAccounts = this.header.numRequiredSignatures;\n if (index >= this.header.numRequiredSignatures) {\n const unsignedAccountIndex = index - numSignedAccounts;\n const numUnsignedAccounts = this.accountKeys.length - numSignedAccounts;\n const numWritableUnsignedAccounts = numUnsignedAccounts - this.header.numReadonlyUnsignedAccounts;\n return unsignedAccountIndex < numWritableUnsignedAccounts;\n } else {\n const numWritableSignedAccounts = numSignedAccounts - this.header.numReadonlySignedAccounts;\n return index < numWritableSignedAccounts;\n }\n }\n isProgramId(index) {\n return this.indexToProgramIds.has(index);\n }\n programIds() {\n return [...this.indexToProgramIds.values()];\n }\n nonProgramIds() {\n return this.accountKeys.filter((_, index) => !this.isProgramId(index));\n }\n serialize() {\n const numKeys = this.accountKeys.length;\n let keyCount = [];\n encodeLength(keyCount, numKeys);\n const instructions = this.instructions.map(instruction => {\n const {\n accounts,\n programIdIndex\n } = instruction;\n const data = Array.from(bs58.decode(instruction.data));\n let keyIndicesCount = [];\n encodeLength(keyIndicesCount, accounts.length);\n let dataCount = [];\n encodeLength(dataCount, data.length);\n return {\n programIdIndex,\n keyIndicesCount: Buffer.from(keyIndicesCount),\n keyIndices: accounts,\n dataLength: Buffer.from(dataCount),\n data\n };\n });\n let instructionCount = [];\n encodeLength(instructionCount, instructions.length);\n let instructionBuffer = Buffer.alloc(PACKET_DATA_SIZE);\n Buffer.from(instructionCount).copy(instructionBuffer);\n let instructionBufferLength = instructionCount.length;\n instructions.forEach(instruction => {\n const instructionLayout = BufferLayout.struct([BufferLayout.u8('programIdIndex'), BufferLayout.blob(instruction.keyIndicesCount.length, 'keyIndicesCount'), BufferLayout.seq(BufferLayout.u8('keyIndex'), instruction.keyIndices.length, 'keyIndices'), BufferLayout.blob(instruction.dataLength.length, 'dataLength'), BufferLayout.seq(BufferLayout.u8('userdatum'), instruction.data.length, 'data')]);\n const length = instructionLayout.encode(instruction, instructionBuffer, instructionBufferLength);\n instructionBufferLength += length;\n });\n instructionBuffer = instructionBuffer.slice(0, instructionBufferLength);\n const signDataLayout = BufferLayout.struct([BufferLayout.blob(1, 'numRequiredSignatures'), BufferLayout.blob(1, 'numReadonlySignedAccounts'), BufferLayout.blob(1, 'numReadonlyUnsignedAccounts'), BufferLayout.blob(keyCount.length, 'keyCount'), BufferLayout.seq(publicKey('key'), numKeys, 'keys'), publicKey('recentBlockhash')]);\n const transaction = {\n numRequiredSignatures: Buffer.from([this.header.numRequiredSignatures]),\n numReadonlySignedAccounts: Buffer.from([this.header.numReadonlySignedAccounts]),\n numReadonlyUnsignedAccounts: Buffer.from([this.header.numReadonlyUnsignedAccounts]),\n keyCount: Buffer.from(keyCount),\n keys: this.accountKeys.map(key => toBuffer(key.toBytes())),\n recentBlockhash: bs58.decode(this.recentBlockhash)\n };\n let signData = Buffer.alloc(2048);\n const length = signDataLayout.encode(transaction, signData);\n instructionBuffer.copy(signData, length);\n return signData.slice(0, length + instructionBuffer.length);\n }\n\n /**\n * Decode a compiled message into a Message object.\n */\n static from(buffer) {\n // Slice up wire data\n let byteArray = [...buffer];\n const numRequiredSignatures = guardedShift(byteArray);\n if (numRequiredSignatures !== (numRequiredSignatures & VERSION_PREFIX_MASK)) {\n throw new Error('Versioned messages must be deserialized with VersionedMessage.deserialize()');\n }\n const numReadonlySignedAccounts = guardedShift(byteArray);\n const numReadonlyUnsignedAccounts = guardedShift(byteArray);\n const accountCount = decodeLength(byteArray);\n let accountKeys = [];\n for (let i = 0; i < accountCount; i++) {\n const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);\n accountKeys.push(new PublicKey(Buffer.from(account)));\n }\n const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);\n const instructionCount = decodeLength(byteArray);\n let instructions = [];\n for (let i = 0; i < instructionCount; i++) {\n const programIdIndex = guardedShift(byteArray);\n const accountCount = decodeLength(byteArray);\n const accounts = guardedSplice(byteArray, 0, accountCount);\n const dataLength = decodeLength(byteArray);\n const dataSlice = guardedSplice(byteArray, 0, dataLength);\n const data = bs58.encode(Buffer.from(dataSlice));\n instructions.push({\n programIdIndex,\n accounts,\n data\n });\n }\n const messageArgs = {\n header: {\n numRequiredSignatures,\n numReadonlySignedAccounts,\n numReadonlyUnsignedAccounts\n },\n recentBlockhash: bs58.encode(Buffer.from(recentBlockhash)),\n accountKeys,\n instructions\n };\n return new Message(messageArgs);\n }\n}\n\n/**\n * Message constructor arguments\n */\n\nclass MessageV0 {\n constructor(args) {\n this.header = void 0;\n this.staticAccountKeys = void 0;\n this.recentBlockhash = void 0;\n this.compiledInstructions = void 0;\n this.addressTableLookups = void 0;\n this.header = args.header;\n this.staticAccountKeys = args.staticAccountKeys;\n this.recentBlockhash = args.recentBlockhash;\n this.compiledInstructions = args.compiledInstructions;\n this.addressTableLookups = args.addressTableLookups;\n }\n get version() {\n return 0;\n }\n get numAccountKeysFromLookups() {\n let count = 0;\n for (const lookup of this.addressTableLookups) {\n count += lookup.readonlyIndexes.length + lookup.writableIndexes.length;\n }\n return count;\n }\n getAccountKeys(args) {\n let accountKeysFromLookups;\n if (args && 'accountKeysFromLookups' in args && args.accountKeysFromLookups) {\n if (this.numAccountKeysFromLookups != args.accountKeysFromLookups.writable.length + args.accountKeysFromLookups.readonly.length) {\n throw new Error('Failed to get account keys because of a mismatch in the number of account keys from lookups');\n }\n accountKeysFromLookups = args.accountKeysFromLookups;\n } else if (args && 'addressLookupTableAccounts' in args && args.addressLookupTableAccounts) {\n accountKeysFromLookups = this.resolveAddressTableLookups(args.addressLookupTableAccounts);\n } else if (this.addressTableLookups.length > 0) {\n throw new Error('Failed to get account keys because address table lookups were not resolved');\n }\n return new MessageAccountKeys(this.staticAccountKeys, accountKeysFromLookups);\n }\n isAccountSigner(index) {\n return index < this.header.numRequiredSignatures;\n }\n isAccountWritable(index) {\n const numSignedAccounts = this.header.numRequiredSignatures;\n const numStaticAccountKeys = this.staticAccountKeys.length;\n if (index >= numStaticAccountKeys) {\n const lookupAccountKeysIndex = index - numStaticAccountKeys;\n const numWritableLookupAccountKeys = this.addressTableLookups.reduce((count, lookup) => count + lookup.writableIndexes.length, 0);\n return lookupAccountKeysIndex < numWritableLookupAccountKeys;\n } else if (index >= this.header.numRequiredSignatures) {\n const unsignedAccountIndex = index - numSignedAccounts;\n const numUnsignedAccounts = numStaticAccountKeys - numSignedAccounts;\n const numWritableUnsignedAccounts = numUnsignedAccounts - this.header.numReadonlyUnsignedAccounts;\n return unsignedAccountIndex < numWritableUnsignedAccounts;\n } else {\n const numWritableSignedAccounts = numSignedAccounts - this.header.numReadonlySignedAccounts;\n return index < numWritableSignedAccounts;\n }\n }\n resolveAddressTableLookups(addressLookupTableAccounts) {\n const accountKeysFromLookups = {\n writable: [],\n readonly: []\n };\n for (const tableLookup of this.addressTableLookups) {\n const tableAccount = addressLookupTableAccounts.find(account => account.key.equals(tableLookup.accountKey));\n if (!tableAccount) {\n throw new Error(`Failed to find address lookup table account for table key ${tableLookup.accountKey.toBase58()}`);\n }\n for (const index of tableLookup.writableIndexes) {\n if (index < tableAccount.state.addresses.length) {\n accountKeysFromLookups.writable.push(tableAccount.state.addresses[index]);\n } else {\n throw new Error(`Failed to find address for index ${index} in address lookup table ${tableLookup.accountKey.toBase58()}`);\n }\n }\n for (const index of tableLookup.readonlyIndexes) {\n if (index < tableAccount.state.addresses.length) {\n accountKeysFromLookups.readonly.push(tableAccount.state.addresses[index]);\n } else {\n throw new Error(`Failed to find address for index ${index} in address lookup table ${tableLookup.accountKey.toBase58()}`);\n }\n }\n }\n return accountKeysFromLookups;\n }\n static compile(args) {\n const compiledKeys = CompiledKeys.compile(args.instructions, args.payerKey);\n const addressTableLookups = new Array();\n const accountKeysFromLookups = {\n writable: new Array(),\n readonly: new Array()\n };\n const lookupTableAccounts = args.addressLookupTableAccounts || [];\n for (const lookupTable of lookupTableAccounts) {\n const extractResult = compiledKeys.extractTableLookup(lookupTable);\n if (extractResult !== undefined) {\n const [addressTableLookup, {\n writable,\n readonly\n }] = extractResult;\n addressTableLookups.push(addressTableLookup);\n accountKeysFromLookups.writable.push(...writable);\n accountKeysFromLookups.readonly.push(...readonly);\n }\n }\n const [header, staticAccountKeys] = compiledKeys.getMessageComponents();\n const accountKeys = new MessageAccountKeys(staticAccountKeys, accountKeysFromLookups);\n const compiledInstructions = accountKeys.compileInstructions(args.instructions);\n return new MessageV0({\n header,\n staticAccountKeys,\n recentBlockhash: args.recentBlockhash,\n compiledInstructions,\n addressTableLookups\n });\n }\n serialize() {\n const encodedStaticAccountKeysLength = Array();\n encodeLength(encodedStaticAccountKeysLength, this.staticAccountKeys.length);\n const serializedInstructions = this.serializeInstructions();\n const encodedInstructionsLength = Array();\n encodeLength(encodedInstructionsLength, this.compiledInstructions.length);\n const serializedAddressTableLookups = this.serializeAddressTableLookups();\n const encodedAddressTableLookupsLength = Array();\n encodeLength(encodedAddressTableLookupsLength, this.addressTableLookups.length);\n const messageLayout = BufferLayout.struct([BufferLayout.u8('prefix'), BufferLayout.struct([BufferLayout.u8('numRequiredSignatures'), BufferLayout.u8('numReadonlySignedAccounts'), BufferLayout.u8('numReadonlyUnsignedAccounts')], 'header'), BufferLayout.blob(encodedStaticAccountKeysLength.length, 'staticAccountKeysLength'), BufferLayout.seq(publicKey(), this.staticAccountKeys.length, 'staticAccountKeys'), publicKey('recentBlockhash'), BufferLayout.blob(encodedInstructionsLength.length, 'instructionsLength'), BufferLayout.blob(serializedInstructions.length, 'serializedInstructions'), BufferLayout.blob(encodedAddressTableLookupsLength.length, 'addressTableLookupsLength'), BufferLayout.blob(serializedAddressTableLookups.length, 'serializedAddressTableLookups')]);\n const serializedMessage = new Uint8Array(PACKET_DATA_SIZE);\n const MESSAGE_VERSION_0_PREFIX = 1 << 7;\n const serializedMessageLength = messageLayout.encode({\n prefix: MESSAGE_VERSION_0_PREFIX,\n header: this.header,\n staticAccountKeysLength: new Uint8Array(encodedStaticAccountKeysLength),\n staticAccountKeys: this.staticAccountKeys.map(key => key.toBytes()),\n recentBlockhash: bs58.decode(this.recentBlockhash),\n instructionsLength: new Uint8Array(encodedInstructionsLength),\n serializedInstructions,\n addressTableLookupsLength: new Uint8Array(encodedAddressTableLookupsLength),\n serializedAddressTableLookups\n }, serializedMessage);\n return serializedMessage.slice(0, serializedMessageLength);\n }\n serializeInstructions() {\n let serializedLength = 0;\n const serializedInstructions = new Uint8Array(PACKET_DATA_SIZE);\n for (const instruction of this.compiledInstructions) {\n const encodedAccountKeyIndexesLength = Array();\n encodeLength(encodedAccountKeyIndexesLength, instruction.accountKeyIndexes.length);\n const encodedDataLength = Array();\n encodeLength(encodedDataLength, instruction.data.length);\n const instructionLayout = BufferLayout.struct([BufferLayout.u8('programIdIndex'), BufferLayout.blob(encodedAccountKeyIndexesLength.length, 'encodedAccountKeyIndexesLength'), BufferLayout.seq(BufferLayout.u8(), instruction.accountKeyIndexes.length, 'accountKeyIndexes'), BufferLayout.blob(encodedDataLength.length, 'encodedDataLength'), BufferLayout.blob(instruction.data.length, 'data')]);\n serializedLength += instructionLayout.encode({\n programIdIndex: instruction.programIdIndex,\n encodedAccountKeyIndexesLength: new Uint8Array(encodedAccountKeyIndexesLength),\n accountKeyIndexes: instruction.accountKeyIndexes,\n encodedDataLength: new Uint8Array(encodedDataLength),\n data: instruction.data\n }, serializedInstructions, serializedLength);\n }\n return serializedInstructions.slice(0, serializedLength);\n }\n serializeAddressTableLookups() {\n let serializedLength = 0;\n const serializedAddressTableLookups = new Uint8Array(PACKET_DATA_SIZE);\n for (const lookup of this.addressTableLookups) {\n const encodedWritableIndexesLength = Array();\n encodeLength(encodedWritableIndexesLength, lookup.writableIndexes.length);\n const encodedReadonlyIndexesLength = Array();\n encodeLength(encodedReadonlyIndexesLength, lookup.readonlyIndexes.length);\n const addressTableLookupLayout = BufferLayout.struct([publicKey('accountKey'), BufferLayout.blob(encodedWritableIndexesLength.length, 'encodedWritableIndexesLength'), BufferLayout.seq(BufferLayout.u8(), lookup.writableIndexes.length, 'writableIndexes'), BufferLayout.blob(encodedReadonlyIndexesLength.length, 'encodedReadonlyIndexesLength'), BufferLayout.seq(BufferLayout.u8(), lookup.readonlyIndexes.length, 'readonlyIndexes')]);\n serializedLength += addressTableLookupLayout.encode({\n accountKey: lookup.accountKey.toBytes(),\n encodedWritableIndexesLength: new Uint8Array(encodedWritableIndexesLength),\n writableIndexes: lookup.writableIndexes,\n encodedReadonlyIndexesLength: new Uint8Array(encodedReadonlyIndexesLength),\n readonlyIndexes: lookup.readonlyIndexes\n }, serializedAddressTableLookups, serializedLength);\n }\n return serializedAddressTableLookups.slice(0, serializedLength);\n }\n static deserialize(serializedMessage) {\n let byteArray = [...serializedMessage];\n const prefix = guardedShift(byteArray);\n const maskedPrefix = prefix & VERSION_PREFIX_MASK;\n assert(prefix !== maskedPrefix, `Expected versioned message but received legacy message`);\n const version = maskedPrefix;\n assert(version === 0, `Expected versioned message with version 0 but found version ${version}`);\n const header = {\n numRequiredSignatures: guardedShift(byteArray),\n numReadonlySignedAccounts: guardedShift(byteArray),\n numReadonlyUnsignedAccounts: guardedShift(byteArray)\n };\n const staticAccountKeys = [];\n const staticAccountKeysLength = decodeLength(byteArray);\n for (let i = 0; i < staticAccountKeysLength; i++) {\n staticAccountKeys.push(new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)));\n }\n const recentBlockhash = bs58.encode(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));\n const instructionCount = decodeLength(byteArray);\n const compiledInstructions = [];\n for (let i = 0; i < instructionCount; i++) {\n const programIdIndex = guardedShift(byteArray);\n const accountKeyIndexesLength = decodeLength(byteArray);\n const accountKeyIndexes = guardedSplice(byteArray, 0, accountKeyIndexesLength);\n const dataLength = decodeLength(byteArray);\n const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));\n compiledInstructions.push({\n programIdIndex,\n accountKeyIndexes,\n data\n });\n }\n const addressTableLookupsCount = decodeLength(byteArray);\n const addressTableLookups = [];\n for (let i = 0; i < addressTableLookupsCount; i++) {\n const accountKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));\n const writableIndexesLength = decodeLength(byteArray);\n const writableIndexes = guardedSplice(byteArray, 0, writableIndexesLength);\n const readonlyIndexesLength = decodeLength(byteArray);\n const readonlyIndexes = guardedSplice(byteArray, 0, readonlyIndexesLength);\n addressTableLookups.push({\n accountKey,\n writableIndexes,\n readonlyIndexes\n });\n }\n return new MessageV0({\n header,\n staticAccountKeys,\n recentBlockhash,\n compiledInstructions,\n addressTableLookups\n });\n }\n}\n\n// eslint-disable-next-line no-redeclare\nconst VersionedMessage = {\n deserializeMessageVersion(serializedMessage) {\n const prefix = serializedMessage[0];\n const maskedPrefix = prefix & VERSION_PREFIX_MASK;\n\n // if the highest bit of the prefix is not set, the message is not versioned\n if (maskedPrefix === prefix) {\n return 'legacy';\n }\n\n // the lower 7 bits of the prefix indicate the message version\n return maskedPrefix;\n },\n deserialize: serializedMessage => {\n const version = VersionedMessage.deserializeMessageVersion(serializedMessage);\n if (version === 'legacy') {\n return Message.from(serializedMessage);\n }\n if (version === 0) {\n return MessageV0.deserialize(serializedMessage);\n } else {\n throw new Error(`Transaction message version ${version} deserialization is not supported`);\n }\n }\n};\n\n/** @internal */\n\n/**\n * Transaction signature as base-58 encoded string\n */\n\nlet TransactionStatus = /*#__PURE__*/function (TransactionStatus) {\n TransactionStatus[TransactionStatus[\"BLOCKHEIGHT_EXCEEDED\"] = 0] = \"BLOCKHEIGHT_EXCEEDED\";\n TransactionStatus[TransactionStatus[\"PROCESSED\"] = 1] = \"PROCESSED\";\n TransactionStatus[TransactionStatus[\"TIMED_OUT\"] = 2] = \"TIMED_OUT\";\n TransactionStatus[TransactionStatus[\"NONCE_INVALID\"] = 3] = \"NONCE_INVALID\";\n return TransactionStatus;\n}({});\n\n/**\n * Default (empty) signature\n */\nconst DEFAULT_SIGNATURE = Buffer.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);\n\n/**\n * Account metadata used to define instructions\n */\n\n/**\n * List of TransactionInstruction object fields that may be initialized at construction\n */\n\n/**\n * Configuration object for Transaction.serialize()\n */\n\n/**\n * @internal\n */\n\n/**\n * Transaction Instruction class\n */\nclass TransactionInstruction {\n constructor(opts) {\n /**\n * Public keys to include in this transaction\n * Boolean represents whether this pubkey needs to sign the transaction\n */\n this.keys = void 0;\n /**\n * Program Id to execute\n */\n this.programId = void 0;\n /**\n * Program input\n */\n this.data = Buffer.alloc(0);\n this.programId = opts.programId;\n this.keys = opts.keys;\n if (opts.data) {\n this.data = opts.data;\n }\n }\n\n /**\n * @internal\n */\n toJSON() {\n return {\n keys: this.keys.map(({\n pubkey,\n isSigner,\n isWritable\n }) => ({\n pubkey: pubkey.toJSON(),\n isSigner,\n isWritable\n })),\n programId: this.programId.toJSON(),\n data: [...this.data]\n };\n }\n}\n\n/**\n * Pair of signature and corresponding public key\n */\n\n/**\n * List of Transaction object fields that may be initialized at construction\n */\n\n// For backward compatibility; an unfortunate consequence of being\n// forced to over-export types by the documentation generator.\n// See https://github.com/solana-labs/solana/pull/25820\n\n/**\n * Blockhash-based transactions have a lifetime that are defined by\n * the blockhash they include. Any transaction whose blockhash is\n * too old will be rejected.\n */\n\n/**\n * Use these options to construct a durable nonce transaction.\n */\n\n/**\n * Nonce information to be used to build an offline Transaction.\n */\n\n/**\n * @internal\n */\n\n/**\n * Transaction class\n */\nclass Transaction {\n /**\n * The first (payer) Transaction signature\n *\n * @returns {Buffer | null} Buffer of payer's signature\n */\n get signature() {\n if (this.signatures.length > 0) {\n return this.signatures[0].signature;\n }\n return null;\n }\n\n /**\n * The transaction fee payer\n */\n\n // Construct a transaction with a blockhash and lastValidBlockHeight\n\n // Construct a transaction using a durable nonce\n\n /**\n * @deprecated `TransactionCtorFields` has been deprecated and will be removed in a future version.\n * Please supply a `TransactionBlockhashCtor` instead.\n */\n\n /**\n * Construct an empty Transaction\n */\n constructor(opts) {\n /**\n * Signatures for the transaction. Typically created by invoking the\n * `sign()` method\n */\n this.signatures = [];\n this.feePayer = void 0;\n /**\n * The instructions to atomically execute\n */\n this.instructions = [];\n /**\n * A recent transaction id. Must be populated by the caller\n */\n this.recentBlockhash = void 0;\n /**\n * the last block chain can advance to before tx is declared expired\n * */\n this.lastValidBlockHeight = void 0;\n /**\n * Optional Nonce information. If populated, transaction will use a durable\n * Nonce hash instead of a recentBlockhash. Must be populated by the caller\n */\n this.nonceInfo = void 0;\n /**\n * If this is a nonce transaction this represents the minimum slot from which\n * to evaluate if the nonce has advanced when attempting to confirm the\n * transaction. This protects against a case where the transaction confirmation\n * logic loads the nonce account from an old slot and assumes the mismatch in\n * nonce value implies that the nonce has been advanced.\n */\n this.minNonceContextSlot = void 0;\n /**\n * @internal\n */\n this._message = void 0;\n /**\n * @internal\n */\n this._json = void 0;\n if (!opts) {\n return;\n }\n if (opts.feePayer) {\n this.feePayer = opts.feePayer;\n }\n if (opts.signatures) {\n this.signatures = opts.signatures;\n }\n if (Object.prototype.hasOwnProperty.call(opts, 'nonceInfo')) {\n const {\n minContextSlot,\n nonceInfo\n } = opts;\n this.minNonceContextSlot = minContextSlot;\n this.nonceInfo = nonceInfo;\n } else if (Object.prototype.hasOwnProperty.call(opts, 'lastValidBlockHeight')) {\n const {\n blockhash,\n lastValidBlockHeight\n } = opts;\n this.recentBlockhash = blockhash;\n this.lastValidBlockHeight = lastValidBlockHeight;\n } else {\n const {\n recentBlockhash,\n nonceInfo\n } = opts;\n if (nonceInfo) {\n this.nonceInfo = nonceInfo;\n }\n this.recentBlockhash = recentBlockhash;\n }\n }\n\n /**\n * @internal\n */\n toJSON() {\n return {\n recentBlockhash: this.recentBlockhash || null,\n feePayer: this.feePayer ? this.feePayer.toJSON() : null,\n nonceInfo: this.nonceInfo ? {\n nonce: this.nonceInfo.nonce,\n nonceInstruction: this.nonceInfo.nonceInstruction.toJSON()\n } : null,\n instructions: this.instructions.map(instruction => instruction.toJSON()),\n signers: this.signatures.map(({\n publicKey\n }) => {\n return publicKey.toJSON();\n })\n };\n }\n\n /**\n * Add one or more instructions to this Transaction\n *\n * @param {Array< Transaction | TransactionInstruction | TransactionInstructionCtorFields >} items - Instructions to add to the Transaction\n */\n add(...items) {\n if (items.length === 0) {\n throw new Error('No instructions');\n }\n items.forEach(item => {\n if ('instructions' in item) {\n this.instructions = this.instructions.concat(item.instructions);\n } else if ('data' in item && 'programId' in item && 'keys' in item) {\n this.instructions.push(item);\n } else {\n this.instructions.push(new TransactionInstruction(item));\n }\n });\n return this;\n }\n\n /**\n * Compile transaction data\n */\n compileMessage() {\n if (this._message && JSON.stringify(this.toJSON()) === JSON.stringify(this._json)) {\n return this._message;\n }\n let recentBlockhash;\n let instructions;\n if (this.nonceInfo) {\n recentBlockhash = this.nonceInfo.nonce;\n if (this.instructions[0] != this.nonceInfo.nonceInstruction) {\n instructions = [this.nonceInfo.nonceInstruction, ...this.instructions];\n } else {\n instructions = this.instructions;\n }\n } else {\n recentBlockhash = this.recentBlockhash;\n instructions = this.instructions;\n }\n if (!recentBlockhash) {\n throw new Error('Transaction recentBlockhash required');\n }\n if (instructions.length < 1) {\n console.warn('No instructions provided');\n }\n let feePayer;\n if (this.feePayer) {\n feePayer = this.feePayer;\n } else if (this.signatures.length > 0 && this.signatures[0].publicKey) {\n // Use implicit fee payer\n feePayer = this.signatures[0].publicKey;\n } else {\n throw new Error('Transaction fee payer required');\n }\n for (let i = 0; i < instructions.length; i++) {\n if (instructions[i].programId === undefined) {\n throw new Error(`Transaction instruction index ${i} has undefined program id`);\n }\n }\n const programIds = [];\n const accountMetas = [];\n instructions.forEach(instruction => {\n instruction.keys.forEach(accountMeta => {\n accountMetas.push({\n ...accountMeta\n });\n });\n const programId = instruction.programId.toString();\n if (!programIds.includes(programId)) {\n programIds.push(programId);\n }\n });\n\n // Append programID account metas\n programIds.forEach(programId => {\n accountMetas.push({\n pubkey: new PublicKey(programId),\n isSigner: false,\n isWritable: false\n });\n });\n\n // Cull duplicate account metas\n const uniqueMetas = [];\n accountMetas.forEach(accountMeta => {\n const pubkeyString = accountMeta.pubkey.toString();\n const uniqueIndex = uniqueMetas.findIndex(x => {\n return x.pubkey.toString() === pubkeyString;\n });\n if (uniqueIndex > -1) {\n uniqueMetas[uniqueIndex].isWritable = uniqueMetas[uniqueIndex].isWritable || accountMeta.isWritable;\n uniqueMetas[uniqueIndex].isSigner = uniqueMetas[uniqueIndex].isSigner || accountMeta.isSigner;\n } else {\n uniqueMetas.push(accountMeta);\n }\n });\n\n // Sort. Prioritizing first by signer, then by writable\n uniqueMetas.sort(function (x, y) {\n if (x.isSigner !== y.isSigner) {\n // Signers always come before non-signers\n return x.isSigner ? -1 : 1;\n }\n if (x.isWritable !== y.isWritable) {\n // Writable accounts always come before read-only accounts\n return x.isWritable ? -1 : 1;\n }\n // Otherwise, sort by pubkey, stringwise.\n const options = {\n localeMatcher: 'best fit',\n usage: 'sort',\n sensitivity: 'variant',\n ignorePunctuation: false,\n numeric: false,\n caseFirst: 'lower'\n };\n return x.pubkey.toBase58().localeCompare(y.pubkey.toBase58(), 'en', options);\n });\n\n // Move fee payer to the front\n const feePayerIndex = uniqueMetas.findIndex(x => {\n return x.pubkey.equals(feePayer);\n });\n if (feePayerIndex > -1) {\n const [payerMeta] = uniqueMetas.splice(feePayerIndex, 1);\n payerMeta.isSigner = true;\n payerMeta.isWritable = true;\n uniqueMetas.unshift(payerMeta);\n } else {\n uniqueMetas.unshift({\n pubkey: feePayer,\n isSigner: true,\n isWritable: true\n });\n }\n\n // Disallow unknown signers\n for (const signature of this.signatures) {\n const uniqueIndex = uniqueMetas.findIndex(x => {\n return x.pubkey.equals(signature.publicKey);\n });\n if (uniqueIndex > -1) {\n if (!uniqueMetas[uniqueIndex].isSigner) {\n uniqueMetas[uniqueIndex].isSigner = true;\n console.warn('Transaction references a signature that is unnecessary, ' + 'only the fee payer and instruction signer accounts should sign a transaction. ' + 'This behavior is deprecated and will throw an error in the next major version release.');\n }\n } else {\n throw new Error(`unknown signer: ${signature.publicKey.toString()}`);\n }\n }\n let numRequiredSignatures = 0;\n let numReadonlySignedAccounts = 0;\n let numReadonlyUnsignedAccounts = 0;\n\n // Split out signing from non-signing keys and count header values\n const signedKeys = [];\n const unsignedKeys = [];\n uniqueMetas.forEach(({\n pubkey,\n isSigner,\n isWritable\n }) => {\n if (isSigner) {\n signedKeys.push(pubkey.toString());\n numRequiredSignatures += 1;\n if (!isWritable) {\n numReadonlySignedAccounts += 1;\n }\n } else {\n unsignedKeys.push(pubkey.toString());\n if (!isWritable) {\n numReadonlyUnsignedAccounts += 1;\n }\n }\n });\n const accountKeys = signedKeys.concat(unsignedKeys);\n const compiledInstructions = instructions.map(instruction => {\n const {\n data,\n programId\n } = instruction;\n return {\n programIdIndex: accountKeys.indexOf(programId.toString()),\n accounts: instruction.keys.map(meta => accountKeys.indexOf(meta.pubkey.toString())),\n data: bs58.encode(data)\n };\n });\n compiledInstructions.forEach(instruction => {\n assert(instruction.programIdIndex >= 0);\n instruction.accounts.forEach(keyIndex => assert(keyIndex >= 0));\n });\n return new Message({\n header: {\n numRequiredSignatures,\n numReadonlySignedAccounts,\n numReadonlyUnsignedAccounts\n },\n accountKeys,\n recentBlockhash,\n instructions: compiledInstructions\n });\n }\n\n /**\n * @internal\n */\n _compile() {\n const message = this.compileMessage();\n const signedKeys = message.accountKeys.slice(0, message.header.numRequiredSignatures);\n if (this.signatures.length === signedKeys.length) {\n const valid = this.signatures.every((pair, index) => {\n return signedKeys[index].equals(pair.publicKey);\n });\n if (valid) return message;\n }\n this.signatures = signedKeys.map(publicKey => ({\n signature: null,\n publicKey\n }));\n return message;\n }\n\n /**\n * Get a buffer of the Transaction data that need to be covered by signatures\n */\n serializeMessage() {\n return this._compile().serialize();\n }\n\n /**\n * Get the estimated fee associated with a transaction\n *\n * @param {Connection} connection Connection to RPC Endpoint.\n *\n * @returns {Promise} The estimated fee for the transaction\n */\n async getEstimatedFee(connection) {\n return (await connection.getFeeForMessage(this.compileMessage())).value;\n }\n\n /**\n * Specify the public keys which will be used to sign the Transaction.\n * The first signer will be used as the transaction fee payer account.\n *\n * Signatures can be added with either `partialSign` or `addSignature`\n *\n * @deprecated Deprecated since v0.84.0. Only the fee payer needs to be\n * specified and it can be set in the Transaction constructor or with the\n * `feePayer` property.\n */\n setSigners(...signers) {\n if (signers.length === 0) {\n throw new Error('No signers');\n }\n const seen = new Set();\n this.signatures = signers.filter(publicKey => {\n const key = publicKey.toString();\n if (seen.has(key)) {\n return false;\n } else {\n seen.add(key);\n return true;\n }\n }).map(publicKey => ({\n signature: null,\n publicKey\n }));\n }\n\n /**\n * Sign the Transaction with the specified signers. Multiple signatures may\n * be applied to a Transaction. The first signature is considered \"primary\"\n * and is used identify and confirm transactions.\n *\n * If the Transaction `feePayer` is not set, the first signer will be used\n * as the transaction fee payer account.\n *\n * Transaction fields should not be modified after the first call to `sign`,\n * as doing so may invalidate the signature and cause the Transaction to be\n * rejected.\n *\n * The Transaction must be assigned a valid `recentBlockhash` before invoking this method\n *\n * @param {Array} signers Array of signers that will sign the transaction\n */\n sign(...signers) {\n if (signers.length === 0) {\n throw new Error('No signers');\n }\n\n // Dedupe signers\n const seen = new Set();\n const uniqueSigners = [];\n for (const signer of signers) {\n const key = signer.publicKey.toString();\n if (seen.has(key)) {\n continue;\n } else {\n seen.add(key);\n uniqueSigners.push(signer);\n }\n }\n this.signatures = uniqueSigners.map(signer => ({\n signature: null,\n publicKey: signer.publicKey\n }));\n const message = this._compile();\n this._partialSign(message, ...uniqueSigners);\n }\n\n /**\n * Partially sign a transaction with the specified accounts. All accounts must\n * correspond to either the fee payer or a signer account in the transaction\n * instructions.\n *\n * All the caveats from the `sign` method apply to `partialSign`\n *\n * @param {Array} signers Array of signers that will sign the transaction\n */\n partialSign(...signers) {\n if (signers.length === 0) {\n throw new Error('No signers');\n }\n\n // Dedupe signers\n const seen = new Set();\n const uniqueSigners = [];\n for (const signer of signers) {\n const key = signer.publicKey.toString();\n if (seen.has(key)) {\n continue;\n } else {\n seen.add(key);\n uniqueSigners.push(signer);\n }\n }\n const message = this._compile();\n this._partialSign(message, ...uniqueSigners);\n }\n\n /**\n * @internal\n */\n _partialSign(message, ...signers) {\n const signData = message.serialize();\n signers.forEach(signer => {\n const signature = sign(signData, signer.secretKey);\n this._addSignature(signer.publicKey, toBuffer(signature));\n });\n }\n\n /**\n * Add an externally created signature to a transaction. The public key\n * must correspond to either the fee payer or a signer account in the transaction\n * instructions.\n *\n * @param {PublicKey} pubkey Public key that will be added to the transaction.\n * @param {Buffer} signature An externally created signature to add to the transaction.\n */\n addSignature(pubkey, signature) {\n this._compile(); // Ensure signatures array is populated\n this._addSignature(pubkey, signature);\n }\n\n /**\n * @internal\n */\n _addSignature(pubkey, signature) {\n assert(signature.length === 64);\n const index = this.signatures.findIndex(sigpair => pubkey.equals(sigpair.publicKey));\n if (index < 0) {\n throw new Error(`unknown signer: ${pubkey.toString()}`);\n }\n this.signatures[index].signature = Buffer.from(signature);\n }\n\n /**\n * Verify signatures of a Transaction\n * Optional parameter specifies if we're expecting a fully signed Transaction or a partially signed one.\n * If no boolean is provided, we expect a fully signed Transaction by default.\n *\n * @param {boolean} [requireAllSignatures=true] Require a fully signed Transaction\n */\n verifySignatures(requireAllSignatures = true) {\n const signatureErrors = this._getMessageSignednessErrors(this.serializeMessage(), requireAllSignatures);\n return !signatureErrors;\n }\n\n /**\n * @internal\n */\n _getMessageSignednessErrors(message, requireAllSignatures) {\n const errors = {};\n for (const {\n signature,\n publicKey\n } of this.signatures) {\n if (signature === null) {\n if (requireAllSignatures) {\n (errors.missing ||= []).push(publicKey);\n }\n } else {\n if (!verify(signature, message, publicKey.toBytes())) {\n (errors.invalid ||= []).push(publicKey);\n }\n }\n }\n return errors.invalid || errors.missing ? errors : undefined;\n }\n\n /**\n * Serialize the Transaction in the wire format.\n *\n * @param {Buffer} [config] Config of transaction.\n *\n * @returns {Buffer} Signature of transaction in wire format.\n */\n serialize(config) {\n const {\n requireAllSignatures,\n verifySignatures\n } = Object.assign({\n requireAllSignatures: true,\n verifySignatures: true\n }, config);\n const signData = this.serializeMessage();\n if (verifySignatures) {\n const sigErrors = this._getMessageSignednessErrors(signData, requireAllSignatures);\n if (sigErrors) {\n let errorMessage = 'Signature verification failed.';\n if (sigErrors.invalid) {\n errorMessage += `\\nInvalid signature for public key${sigErrors.invalid.length === 1 ? '' : '(s)'} [\\`${sigErrors.invalid.map(p => p.toBase58()).join('`, `')}\\`].`;\n }\n if (sigErrors.missing) {\n errorMessage += `\\nMissing signature for public key${sigErrors.missing.length === 1 ? '' : '(s)'} [\\`${sigErrors.missing.map(p => p.toBase58()).join('`, `')}\\`].`;\n }\n throw new Error(errorMessage);\n }\n }\n return this._serialize(signData);\n }\n\n /**\n * @internal\n */\n _serialize(signData) {\n const {\n signatures\n } = this;\n const signatureCount = [];\n encodeLength(signatureCount, signatures.length);\n const transactionLength = signatureCount.length + signatures.length * 64 + signData.length;\n const wireTransaction = Buffer.alloc(transactionLength);\n assert(signatures.length < 256);\n Buffer.from(signatureCount).copy(wireTransaction, 0);\n signatures.forEach(({\n signature\n }, index) => {\n if (signature !== null) {\n assert(signature.length === 64, `signature has invalid length`);\n Buffer.from(signature).copy(wireTransaction, signatureCount.length + index * 64);\n }\n });\n signData.copy(wireTransaction, signatureCount.length + signatures.length * 64);\n assert(wireTransaction.length <= PACKET_DATA_SIZE, `Transaction too large: ${wireTransaction.length} > ${PACKET_DATA_SIZE}`);\n return wireTransaction;\n }\n\n /**\n * Deprecated method\n * @internal\n */\n get keys() {\n assert(this.instructions.length === 1);\n return this.instructions[0].keys.map(keyObj => keyObj.pubkey);\n }\n\n /**\n * Deprecated method\n * @internal\n */\n get programId() {\n assert(this.instructions.length === 1);\n return this.instructions[0].programId;\n }\n\n /**\n * Deprecated method\n * @internal\n */\n get data() {\n assert(this.instructions.length === 1);\n return this.instructions[0].data;\n }\n\n /**\n * Parse a wire transaction into a Transaction object.\n *\n * @param {Buffer | Uint8Array | Array} buffer Signature of wire Transaction\n *\n * @returns {Transaction} Transaction associated with the signature\n */\n static from(buffer) {\n // Slice up wire data\n let byteArray = [...buffer];\n const signatureCount = decodeLength(byteArray);\n let signatures = [];\n for (let i = 0; i < signatureCount; i++) {\n const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);\n signatures.push(bs58.encode(Buffer.from(signature)));\n }\n return Transaction.populate(Message.from(byteArray), signatures);\n }\n\n /**\n * Populate Transaction object from message and signatures\n *\n * @param {Message} message Message of transaction\n * @param {Array} signatures List of signatures to assign to the transaction\n *\n * @returns {Transaction} The populated Transaction\n */\n static populate(message, signatures = []) {\n const transaction = new Transaction();\n transaction.recentBlockhash = message.recentBlockhash;\n if (message.header.numRequiredSignatures > 0) {\n transaction.feePayer = message.accountKeys[0];\n }\n signatures.forEach((signature, index) => {\n const sigPubkeyPair = {\n signature: signature == bs58.encode(DEFAULT_SIGNATURE) ? null : bs58.decode(signature),\n publicKey: message.accountKeys[index]\n };\n transaction.signatures.push(sigPubkeyPair);\n });\n message.instructions.forEach(instruction => {\n const keys = instruction.accounts.map(account => {\n const pubkey = message.accountKeys[account];\n return {\n pubkey,\n isSigner: transaction.signatures.some(keyObj => keyObj.publicKey.toString() === pubkey.toString()) || message.isAccountSigner(account),\n isWritable: message.isAccountWritable(account)\n };\n });\n transaction.instructions.push(new TransactionInstruction({\n keys,\n programId: message.accountKeys[instruction.programIdIndex],\n data: bs58.decode(instruction.data)\n }));\n });\n transaction._message = message;\n transaction._json = transaction.toJSON();\n return transaction;\n }\n}\n\nclass TransactionMessage {\n constructor(args) {\n this.payerKey = void 0;\n this.instructions = void 0;\n this.recentBlockhash = void 0;\n this.payerKey = args.payerKey;\n this.instructions = args.instructions;\n this.recentBlockhash = args.recentBlockhash;\n }\n static decompile(message, args) {\n const {\n header,\n compiledInstructions,\n recentBlockhash\n } = message;\n const {\n numRequiredSignatures,\n numReadonlySignedAccounts,\n numReadonlyUnsignedAccounts\n } = header;\n const numWritableSignedAccounts = numRequiredSignatures - numReadonlySignedAccounts;\n assert(numWritableSignedAccounts > 0, 'Message header is invalid');\n const numWritableUnsignedAccounts = message.staticAccountKeys.length - numRequiredSignatures - numReadonlyUnsignedAccounts;\n assert(numWritableUnsignedAccounts >= 0, 'Message header is invalid');\n const accountKeys = message.getAccountKeys(args);\n const payerKey = accountKeys.get(0);\n if (payerKey === undefined) {\n throw new Error('Failed to decompile message because no account keys were found');\n }\n const instructions = [];\n for (const compiledIx of compiledInstructions) {\n const keys = [];\n for (const keyIndex of compiledIx.accountKeyIndexes) {\n const pubkey = accountKeys.get(keyIndex);\n if (pubkey === undefined) {\n throw new Error(`Failed to find key for account key index ${keyIndex}`);\n }\n const isSigner = keyIndex < numRequiredSignatures;\n let isWritable;\n if (isSigner) {\n isWritable = keyIndex < numWritableSignedAccounts;\n } else if (keyIndex < accountKeys.staticAccountKeys.length) {\n isWritable = keyIndex - numRequiredSignatures < numWritableUnsignedAccounts;\n } else {\n isWritable = keyIndex - accountKeys.staticAccountKeys.length <\n // accountKeysFromLookups cannot be undefined because we already found a pubkey for this index above\n accountKeys.accountKeysFromLookups.writable.length;\n }\n keys.push({\n pubkey,\n isSigner: keyIndex < header.numRequiredSignatures,\n isWritable\n });\n }\n const programId = accountKeys.get(compiledIx.programIdIndex);\n if (programId === undefined) {\n throw new Error(`Failed to find program id for program id index ${compiledIx.programIdIndex}`);\n }\n instructions.push(new TransactionInstruction({\n programId,\n data: toBuffer(compiledIx.data),\n keys\n }));\n }\n return new TransactionMessage({\n payerKey,\n instructions,\n recentBlockhash\n });\n }\n compileToLegacyMessage() {\n return Message.compile({\n payerKey: this.payerKey,\n recentBlockhash: this.recentBlockhash,\n instructions: this.instructions\n });\n }\n compileToV0Message(addressLookupTableAccounts) {\n return MessageV0.compile({\n payerKey: this.payerKey,\n recentBlockhash: this.recentBlockhash,\n instructions: this.instructions,\n addressLookupTableAccounts\n });\n }\n}\n\n/**\n * Versioned transaction class\n */\nclass VersionedTransaction {\n get version() {\n return this.message.version;\n }\n constructor(message, signatures) {\n this.signatures = void 0;\n this.message = void 0;\n if (signatures !== undefined) {\n assert(signatures.length === message.header.numRequiredSignatures, 'Expected signatures length to be equal to the number of required signatures');\n this.signatures = signatures;\n } else {\n const defaultSignatures = [];\n for (let i = 0; i < message.header.numRequiredSignatures; i++) {\n defaultSignatures.push(new Uint8Array(SIGNATURE_LENGTH_IN_BYTES));\n }\n this.signatures = defaultSignatures;\n }\n this.message = message;\n }\n serialize() {\n const serializedMessage = this.message.serialize();\n const encodedSignaturesLength = Array();\n encodeLength(encodedSignaturesLength, this.signatures.length);\n const transactionLayout = BufferLayout.struct([BufferLayout.blob(encodedSignaturesLength.length, 'encodedSignaturesLength'), BufferLayout.seq(signature(), this.signatures.length, 'signatures'), BufferLayout.blob(serializedMessage.length, 'serializedMessage')]);\n const serializedTransaction = new Uint8Array(2048);\n const serializedTransactionLength = transactionLayout.encode({\n encodedSignaturesLength: new Uint8Array(encodedSignaturesLength),\n signatures: this.signatures,\n serializedMessage\n }, serializedTransaction);\n return serializedTransaction.slice(0, serializedTransactionLength);\n }\n static deserialize(serializedTransaction) {\n let byteArray = [...serializedTransaction];\n const signatures = [];\n const signaturesLength = decodeLength(byteArray);\n for (let i = 0; i < signaturesLength; i++) {\n signatures.push(new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)));\n }\n const message = VersionedMessage.deserialize(new Uint8Array(byteArray));\n return new VersionedTransaction(message, signatures);\n }\n sign(signers) {\n const messageData = this.message.serialize();\n const signerPubkeys = this.message.staticAccountKeys.slice(0, this.message.header.numRequiredSignatures);\n for (const signer of signers) {\n const signerIndex = signerPubkeys.findIndex(pubkey => pubkey.equals(signer.publicKey));\n assert(signerIndex >= 0, `Cannot sign with non signer key ${signer.publicKey.toBase58()}`);\n this.signatures[signerIndex] = sign(messageData, signer.secretKey);\n }\n }\n addSignature(publicKey, signature) {\n assert(signature.byteLength === 64, 'Signature must be 64 bytes long');\n const signerPubkeys = this.message.staticAccountKeys.slice(0, this.message.header.numRequiredSignatures);\n const signerIndex = signerPubkeys.findIndex(pubkey => pubkey.equals(publicKey));\n assert(signerIndex >= 0, `Can not add signature; \\`${publicKey.toBase58()}\\` is not required to sign this transaction`);\n this.signatures[signerIndex] = signature;\n }\n}\n\n// TODO: These constants should be removed in favor of reading them out of a\n// Syscall account\n\n/**\n * @internal\n */\nconst NUM_TICKS_PER_SECOND = 160;\n\n/**\n * @internal\n */\nconst DEFAULT_TICKS_PER_SLOT = 64;\n\n/**\n * @internal\n */\nconst NUM_SLOTS_PER_SECOND = NUM_TICKS_PER_SECOND / DEFAULT_TICKS_PER_SLOT;\n\n/**\n * @internal\n */\nconst MS_PER_SLOT = 1000 / NUM_SLOTS_PER_SECOND;\n\nconst SYSVAR_CLOCK_PUBKEY = new PublicKey('SysvarC1ock11111111111111111111111111111111');\nconst SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey('SysvarEpochSchedu1e111111111111111111111111');\nconst SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey('Sysvar1nstructions1111111111111111111111111');\nconst SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey('SysvarRecentB1ockHashes11111111111111111111');\nconst SYSVAR_RENT_PUBKEY = new PublicKey('SysvarRent111111111111111111111111111111111');\nconst SYSVAR_REWARDS_PUBKEY = new PublicKey('SysvarRewards111111111111111111111111111111');\nconst SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey('SysvarS1otHashes111111111111111111111111111');\nconst SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey('SysvarS1otHistory11111111111111111111111111');\nconst SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey('SysvarStakeHistory1111111111111111111111111');\n\nclass SendTransactionError extends Error {\n constructor({\n action,\n signature,\n transactionMessage,\n logs\n }) {\n const maybeLogsOutput = logs ? `Logs: \\n${JSON.stringify(logs.slice(-10), null, 2)}. ` : '';\n const guideText = '\\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.';\n let message;\n switch (action) {\n case 'send':\n message = `Transaction ${signature} resulted in an error. \\n` + `${transactionMessage}. ` + maybeLogsOutput + guideText;\n break;\n case 'simulate':\n message = `Simulation failed. \\nMessage: ${transactionMessage}. \\n` + maybeLogsOutput + guideText;\n break;\n default:\n {\n message = `Unknown action '${(a => a)(action)}'`;\n }\n }\n super(message);\n this.signature = void 0;\n this.transactionMessage = void 0;\n this.transactionLogs = void 0;\n this.signature = signature;\n this.transactionMessage = transactionMessage;\n this.transactionLogs = logs ? logs : undefined;\n }\n get transactionError() {\n return {\n message: this.transactionMessage,\n logs: Array.isArray(this.transactionLogs) ? this.transactionLogs : undefined\n };\n }\n\n /* @deprecated Use `await getLogs()` instead */\n get logs() {\n const cachedLogs = this.transactionLogs;\n if (cachedLogs != null && typeof cachedLogs === 'object' && 'then' in cachedLogs) {\n return undefined;\n }\n return cachedLogs;\n }\n async getLogs(connection) {\n if (!Array.isArray(this.transactionLogs)) {\n this.transactionLogs = new Promise((resolve, reject) => {\n connection.getTransaction(this.signature).then(tx => {\n if (tx && tx.meta && tx.meta.logMessages) {\n const logs = tx.meta.logMessages;\n this.transactionLogs = logs;\n resolve(logs);\n } else {\n reject(new Error('Log messages not found'));\n }\n }).catch(reject);\n });\n }\n return await this.transactionLogs;\n }\n}\n\n// Keep in sync with client/src/rpc_custom_errors.rs\n// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/\nconst SolanaJSONRPCErrorCode = {\n JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001,\n JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002,\n JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003,\n JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004,\n JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005,\n JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006,\n JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007,\n JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008,\n JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009,\n JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010,\n JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011,\n JSON_RPC_SCAN_ERROR: -32012,\n JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013,\n JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014,\n JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015,\n JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016\n};\nclass SolanaJSONRPCError extends Error {\n constructor({\n code,\n message,\n data\n }, customMessage) {\n super(customMessage != null ? `${customMessage}: ${message}` : message);\n this.code = void 0;\n this.data = void 0;\n this.code = code;\n this.data = data;\n this.name = 'SolanaJSONRPCError';\n }\n}\n\n/**\n * Sign, send and confirm a transaction.\n *\n * If `commitment` option is not specified, defaults to 'max' commitment.\n *\n * @param {Connection} connection\n * @param {Transaction} transaction\n * @param {Array} signers\n * @param {ConfirmOptions} [options]\n * @returns {Promise}\n */\nasync function sendAndConfirmTransaction(connection, transaction, signers, options) {\n const sendOptions = options && {\n skipPreflight: options.skipPreflight,\n preflightCommitment: options.preflightCommitment || options.commitment,\n maxRetries: options.maxRetries,\n minContextSlot: options.minContextSlot\n };\n const signature = await connection.sendTransaction(transaction, signers, sendOptions);\n let status;\n if (transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null) {\n status = (await connection.confirmTransaction({\n abortSignal: options?.abortSignal,\n signature: signature,\n blockhash: transaction.recentBlockhash,\n lastValidBlockHeight: transaction.lastValidBlockHeight\n }, options && options.commitment)).value;\n } else if (transaction.minNonceContextSlot != null && transaction.nonceInfo != null) {\n const {\n nonceInstruction\n } = transaction.nonceInfo;\n const nonceAccountPubkey = nonceInstruction.keys[0].pubkey;\n status = (await connection.confirmTransaction({\n abortSignal: options?.abortSignal,\n minContextSlot: transaction.minNonceContextSlot,\n nonceAccountPubkey,\n nonceValue: transaction.nonceInfo.nonce,\n signature\n }, options && options.commitment)).value;\n } else {\n if (options?.abortSignal != null) {\n console.warn('sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was ' + 'supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` ' + 'or a combination of `nonceInfo` and `minNonceContextSlot` are abortable.');\n }\n status = (await connection.confirmTransaction(signature, options && options.commitment)).value;\n }\n if (status.err) {\n if (signature != null) {\n throw new SendTransactionError({\n action: 'send',\n signature: signature,\n transactionMessage: `Status: (${JSON.stringify(status)})`\n });\n }\n throw new Error(`Transaction ${signature} failed (${JSON.stringify(status)})`);\n }\n return signature;\n}\n\n// zzz\nfunction sleep(ms) {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n\n/**\n * @internal\n */\n\n/**\n * Populate a buffer of instruction data using an InstructionType\n * @internal\n */\nfunction encodeData(type, fields) {\n const allocLength = type.layout.span >= 0 ? type.layout.span : getAlloc(type, fields);\n const data = Buffer.alloc(allocLength);\n const layoutFields = Object.assign({\n instruction: type.index\n }, fields);\n type.layout.encode(layoutFields, data);\n return data;\n}\n\n/**\n * Decode instruction data buffer using an InstructionType\n * @internal\n */\nfunction decodeData$1(type, buffer) {\n let data;\n try {\n data = type.layout.decode(buffer);\n } catch (err) {\n throw new Error('invalid instruction; ' + err);\n }\n if (data.instruction !== type.index) {\n throw new Error(`invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`);\n }\n return data;\n}\n\n/**\n * https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11\n *\n * @internal\n */\nconst FeeCalculatorLayout = BufferLayout.nu64('lamportsPerSignature');\n\n/**\n * Calculator for transaction fees.\n *\n * @deprecated Deprecated since Solana v1.8.0.\n */\n\n/**\n * See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32\n *\n * @internal\n */\nconst NonceAccountLayout = BufferLayout.struct([BufferLayout.u32('version'), BufferLayout.u32('state'), publicKey('authorizedPubkey'), publicKey('nonce'), BufferLayout.struct([FeeCalculatorLayout], 'feeCalculator')]);\nconst NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;\n\n/**\n * A durable nonce is a 32 byte value encoded as a base58 string.\n */\n\n/**\n * NonceAccount class\n */\nclass NonceAccount {\n /**\n * @internal\n */\n constructor(args) {\n this.authorizedPubkey = void 0;\n this.nonce = void 0;\n this.feeCalculator = void 0;\n this.authorizedPubkey = args.authorizedPubkey;\n this.nonce = args.nonce;\n this.feeCalculator = args.feeCalculator;\n }\n\n /**\n * Deserialize NonceAccount from the account data.\n *\n * @param buffer account data\n * @return NonceAccount\n */\n static fromAccountData(buffer) {\n const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);\n return new NonceAccount({\n authorizedPubkey: new PublicKey(nonceAccount.authorizedPubkey),\n nonce: new PublicKey(nonceAccount.nonce).toString(),\n feeCalculator: nonceAccount.feeCalculator\n });\n }\n}\n\nconst encodeDecode = layout => {\n const decode = layout.decode.bind(layout);\n const encode = layout.encode.bind(layout);\n return {\n decode,\n encode\n };\n};\nconst bigInt = length => property => {\n const layout = blob(length, property);\n const {\n encode,\n decode\n } = encodeDecode(layout);\n const bigIntLayout = layout;\n bigIntLayout.decode = (buffer, offset) => {\n const src = decode(buffer, offset);\n return toBigIntLE(Buffer.from(src));\n };\n bigIntLayout.encode = (bigInt, buffer, offset) => {\n const src = toBufferLE(bigInt, length);\n return encode(src, buffer, offset);\n };\n return bigIntLayout;\n};\nconst u64 = bigInt(8);\n\n/**\n * Create account system transaction params\n */\n\n/**\n * Transfer system transaction params\n */\n\n/**\n * Assign system transaction params\n */\n\n/**\n * Create account with seed system transaction params\n */\n\n/**\n * Create nonce account system transaction params\n */\n\n/**\n * Create nonce account with seed system transaction params\n */\n\n/**\n * Initialize nonce account system instruction params\n */\n\n/**\n * Advance nonce account system instruction params\n */\n\n/**\n * Withdraw nonce account system transaction params\n */\n\n/**\n * Authorize nonce account system transaction params\n */\n\n/**\n * Allocate account system transaction params\n */\n\n/**\n * Allocate account with seed system transaction params\n */\n\n/**\n * Assign account with seed system transaction params\n */\n\n/**\n * Transfer with seed system transaction params\n */\n\n/** Decoded transfer system transaction instruction */\n\n/** Decoded transferWithSeed system transaction instruction */\n\n/**\n * System Instruction class\n */\nclass SystemInstruction {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Decode a system instruction and retrieve the instruction type.\n */\n static decodeInstructionType(instruction) {\n this.checkProgramId(instruction.programId);\n const instructionTypeLayout = BufferLayout.u32('instruction');\n const typeIndex = instructionTypeLayout.decode(instruction.data);\n let type;\n for (const [ixType, layout] of Object.entries(SYSTEM_INSTRUCTION_LAYOUTS)) {\n if (layout.index == typeIndex) {\n type = ixType;\n break;\n }\n }\n if (!type) {\n throw new Error('Instruction type incorrect; not a SystemInstruction');\n }\n return type;\n }\n\n /**\n * Decode a create account system instruction and retrieve the instruction params.\n */\n static decodeCreateAccount(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n const {\n lamports,\n space,\n programId\n } = decodeData$1(SYSTEM_INSTRUCTION_LAYOUTS.Create, instruction.data);\n return {\n fromPubkey: instruction.keys[0].pubkey,\n newAccountPubkey: instruction.keys[1].pubkey,\n lamports,\n space,\n programId: new PublicKey(programId)\n };\n }\n\n /**\n * Decode a transfer system instruction and retrieve the instruction params.\n */\n static decodeTransfer(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n const {\n lamports\n } = decodeData$1(SYSTEM_INSTRUCTION_LAYOUTS.Transfer, instruction.data);\n return {\n fromPubkey: instruction.keys[0].pubkey,\n toPubkey: instruction.keys[1].pubkey,\n lamports\n };\n }\n\n /**\n * Decode a transfer with seed system instruction and retrieve the instruction params.\n */\n static decodeTransferWithSeed(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const {\n lamports,\n seed,\n programId\n } = decodeData$1(SYSTEM_INSTRUCTION_LAYOUTS.TransferWithSeed, instruction.data);\n return {\n fromPubkey: instruction.keys[0].pubkey,\n basePubkey: instruction.keys[1].pubkey,\n toPubkey: instruction.keys[2].pubkey,\n lamports,\n seed,\n programId: new PublicKey(programId)\n };\n }\n\n /**\n * Decode an allocate system instruction and retrieve the instruction params.\n */\n static decodeAllocate(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 1);\n const {\n space\n } = decodeData$1(SYSTEM_INSTRUCTION_LAYOUTS.Allocate, instruction.data);\n return {\n accountPubkey: instruction.keys[0].pubkey,\n space\n };\n }\n\n /**\n * Decode an allocate with seed system instruction and retrieve the instruction params.\n */\n static decodeAllocateWithSeed(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 1);\n const {\n base,\n seed,\n space,\n programId\n } = decodeData$1(SYSTEM_INSTRUCTION_LAYOUTS.AllocateWithSeed, instruction.data);\n return {\n accountPubkey: instruction.keys[0].pubkey,\n basePubkey: new PublicKey(base),\n seed,\n space,\n programId: new PublicKey(programId)\n };\n }\n\n /**\n * Decode an assign system instruction and retrieve the instruction params.\n */\n static decodeAssign(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 1);\n const {\n programId\n } = decodeData$1(SYSTEM_INSTRUCTION_LAYOUTS.Assign, instruction.data);\n return {\n accountPubkey: instruction.keys[0].pubkey,\n programId: new PublicKey(programId)\n };\n }\n\n /**\n * Decode an assign with seed system instruction and retrieve the instruction params.\n */\n static decodeAssignWithSeed(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 1);\n const {\n base,\n seed,\n programId\n } = decodeData$1(SYSTEM_INSTRUCTION_LAYOUTS.AssignWithSeed, instruction.data);\n return {\n accountPubkey: instruction.keys[0].pubkey,\n basePubkey: new PublicKey(base),\n seed,\n programId: new PublicKey(programId)\n };\n }\n\n /**\n * Decode a create account with seed system instruction and retrieve the instruction params.\n */\n static decodeCreateWithSeed(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n const {\n base,\n seed,\n lamports,\n space,\n programId\n } = decodeData$1(SYSTEM_INSTRUCTION_LAYOUTS.CreateWithSeed, instruction.data);\n return {\n fromPubkey: instruction.keys[0].pubkey,\n newAccountPubkey: instruction.keys[1].pubkey,\n basePubkey: new PublicKey(base),\n seed,\n lamports,\n space,\n programId: new PublicKey(programId)\n };\n }\n\n /**\n * Decode a nonce initialize system instruction and retrieve the instruction params.\n */\n static decodeNonceInitialize(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const {\n authorized\n } = decodeData$1(SYSTEM_INSTRUCTION_LAYOUTS.InitializeNonceAccount, instruction.data);\n return {\n noncePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: new PublicKey(authorized)\n };\n }\n\n /**\n * Decode a nonce advance system instruction and retrieve the instruction params.\n */\n static decodeNonceAdvance(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n decodeData$1(SYSTEM_INSTRUCTION_LAYOUTS.AdvanceNonceAccount, instruction.data);\n return {\n noncePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: instruction.keys[2].pubkey\n };\n }\n\n /**\n * Decode a nonce withdraw system instruction and retrieve the instruction params.\n */\n static decodeNonceWithdraw(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 5);\n const {\n lamports\n } = decodeData$1(SYSTEM_INSTRUCTION_LAYOUTS.WithdrawNonceAccount, instruction.data);\n return {\n noncePubkey: instruction.keys[0].pubkey,\n toPubkey: instruction.keys[1].pubkey,\n authorizedPubkey: instruction.keys[4].pubkey,\n lamports\n };\n }\n\n /**\n * Decode a nonce authorize system instruction and retrieve the instruction params.\n */\n static decodeNonceAuthorize(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n const {\n authorized\n } = decodeData$1(SYSTEM_INSTRUCTION_LAYOUTS.AuthorizeNonceAccount, instruction.data);\n return {\n noncePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: instruction.keys[1].pubkey,\n newAuthorizedPubkey: new PublicKey(authorized)\n };\n }\n\n /**\n * @internal\n */\n static checkProgramId(programId) {\n if (!programId.equals(SystemProgram.programId)) {\n throw new Error('invalid instruction; programId is not SystemProgram');\n }\n }\n\n /**\n * @internal\n */\n static checkKeyLength(keys, expectedLength) {\n if (keys.length < expectedLength) {\n throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);\n }\n }\n}\n\n/**\n * An enumeration of valid SystemInstructionType's\n */\n\n/**\n * An enumeration of valid system InstructionType's\n * @internal\n */\nconst SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze({\n Create: {\n index: 0,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports'), BufferLayout.ns64('space'), publicKey('programId')])\n },\n Assign: {\n index: 1,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('programId')])\n },\n Transfer: {\n index: 2,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), u64('lamports')])\n },\n CreateWithSeed: {\n index: 3,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('base'), rustString('seed'), BufferLayout.ns64('lamports'), BufferLayout.ns64('space'), publicKey('programId')])\n },\n AdvanceNonceAccount: {\n index: 4,\n layout: BufferLayout.struct([BufferLayout.u32('instruction')])\n },\n WithdrawNonceAccount: {\n index: 5,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports')])\n },\n InitializeNonceAccount: {\n index: 6,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('authorized')])\n },\n AuthorizeNonceAccount: {\n index: 7,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('authorized')])\n },\n Allocate: {\n index: 8,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('space')])\n },\n AllocateWithSeed: {\n index: 9,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('base'), rustString('seed'), BufferLayout.ns64('space'), publicKey('programId')])\n },\n AssignWithSeed: {\n index: 10,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('base'), rustString('seed'), publicKey('programId')])\n },\n TransferWithSeed: {\n index: 11,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), u64('lamports'), rustString('seed'), publicKey('programId')])\n },\n UpgradeNonceAccount: {\n index: 12,\n layout: BufferLayout.struct([BufferLayout.u32('instruction')])\n }\n});\n\n/**\n * Factory class for transactions to interact with the System program\n */\nclass SystemProgram {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Public key that identifies the System program\n */\n\n /**\n * Generate a transaction instruction that creates a new account\n */\n static createAccount(params) {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.Create;\n const data = encodeData(type, {\n lamports: params.lamports,\n space: params.space,\n programId: toBuffer(params.programId.toBuffer())\n });\n return new TransactionInstruction({\n keys: [{\n pubkey: params.fromPubkey,\n isSigner: true,\n isWritable: true\n }, {\n pubkey: params.newAccountPubkey,\n isSigner: true,\n isWritable: true\n }],\n programId: this.programId,\n data\n });\n }\n\n /**\n * Generate a transaction instruction that transfers lamports from one account to another\n */\n static transfer(params) {\n let data;\n let keys;\n if ('basePubkey' in params) {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.TransferWithSeed;\n data = encodeData(type, {\n lamports: BigInt(params.lamports),\n seed: params.seed,\n programId: toBuffer(params.programId.toBuffer())\n });\n keys = [{\n pubkey: params.fromPubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: params.basePubkey,\n isSigner: true,\n isWritable: false\n }, {\n pubkey: params.toPubkey,\n isSigner: false,\n isWritable: true\n }];\n } else {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.Transfer;\n data = encodeData(type, {\n lamports: BigInt(params.lamports)\n });\n keys = [{\n pubkey: params.fromPubkey,\n isSigner: true,\n isWritable: true\n }, {\n pubkey: params.toPubkey,\n isSigner: false,\n isWritable: true\n }];\n }\n return new TransactionInstruction({\n keys,\n programId: this.programId,\n data\n });\n }\n\n /**\n * Generate a transaction instruction that assigns an account to a program\n */\n static assign(params) {\n let data;\n let keys;\n if ('basePubkey' in params) {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.AssignWithSeed;\n data = encodeData(type, {\n base: toBuffer(params.basePubkey.toBuffer()),\n seed: params.seed,\n programId: toBuffer(params.programId.toBuffer())\n });\n keys = [{\n pubkey: params.accountPubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: params.basePubkey,\n isSigner: true,\n isWritable: false\n }];\n } else {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.Assign;\n data = encodeData(type, {\n programId: toBuffer(params.programId.toBuffer())\n });\n keys = [{\n pubkey: params.accountPubkey,\n isSigner: true,\n isWritable: true\n }];\n }\n return new TransactionInstruction({\n keys,\n programId: this.programId,\n data\n });\n }\n\n /**\n * Generate a transaction instruction that creates a new account at\n * an address generated with `from`, a seed, and programId\n */\n static createAccountWithSeed(params) {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.CreateWithSeed;\n const data = encodeData(type, {\n base: toBuffer(params.basePubkey.toBuffer()),\n seed: params.seed,\n lamports: params.lamports,\n space: params.space,\n programId: toBuffer(params.programId.toBuffer())\n });\n let keys = [{\n pubkey: params.fromPubkey,\n isSigner: true,\n isWritable: true\n }, {\n pubkey: params.newAccountPubkey,\n isSigner: false,\n isWritable: true\n }];\n if (!params.basePubkey.equals(params.fromPubkey)) {\n keys.push({\n pubkey: params.basePubkey,\n isSigner: true,\n isWritable: false\n });\n }\n return new TransactionInstruction({\n keys,\n programId: this.programId,\n data\n });\n }\n\n /**\n * Generate a transaction that creates a new Nonce account\n */\n static createNonceAccount(params) {\n const transaction = new Transaction();\n if ('basePubkey' in params && 'seed' in params) {\n transaction.add(SystemProgram.createAccountWithSeed({\n fromPubkey: params.fromPubkey,\n newAccountPubkey: params.noncePubkey,\n basePubkey: params.basePubkey,\n seed: params.seed,\n lamports: params.lamports,\n space: NONCE_ACCOUNT_LENGTH,\n programId: this.programId\n }));\n } else {\n transaction.add(SystemProgram.createAccount({\n fromPubkey: params.fromPubkey,\n newAccountPubkey: params.noncePubkey,\n lamports: params.lamports,\n space: NONCE_ACCOUNT_LENGTH,\n programId: this.programId\n }));\n }\n const initParams = {\n noncePubkey: params.noncePubkey,\n authorizedPubkey: params.authorizedPubkey\n };\n transaction.add(this.nonceInitialize(initParams));\n return transaction;\n }\n\n /**\n * Generate an instruction to initialize a Nonce account\n */\n static nonceInitialize(params) {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.InitializeNonceAccount;\n const data = encodeData(type, {\n authorized: toBuffer(params.authorizedPubkey.toBuffer())\n });\n const instructionData = {\n keys: [{\n pubkey: params.noncePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: SYSVAR_RECENT_BLOCKHASHES_PUBKEY,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: SYSVAR_RENT_PUBKEY,\n isSigner: false,\n isWritable: false\n }],\n programId: this.programId,\n data\n };\n return new TransactionInstruction(instructionData);\n }\n\n /**\n * Generate an instruction to advance the nonce in a Nonce account\n */\n static nonceAdvance(params) {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.AdvanceNonceAccount;\n const data = encodeData(type);\n const instructionData = {\n keys: [{\n pubkey: params.noncePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: SYSVAR_RECENT_BLOCKHASHES_PUBKEY,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: params.authorizedPubkey,\n isSigner: true,\n isWritable: false\n }],\n programId: this.programId,\n data\n };\n return new TransactionInstruction(instructionData);\n }\n\n /**\n * Generate a transaction instruction that withdraws lamports from a Nonce account\n */\n static nonceWithdraw(params) {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.WithdrawNonceAccount;\n const data = encodeData(type, {\n lamports: params.lamports\n });\n return new TransactionInstruction({\n keys: [{\n pubkey: params.noncePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: params.toPubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: SYSVAR_RECENT_BLOCKHASHES_PUBKEY,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: SYSVAR_RENT_PUBKEY,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: params.authorizedPubkey,\n isSigner: true,\n isWritable: false\n }],\n programId: this.programId,\n data\n });\n }\n\n /**\n * Generate a transaction instruction that authorizes a new PublicKey as the authority\n * on a Nonce account.\n */\n static nonceAuthorize(params) {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.AuthorizeNonceAccount;\n const data = encodeData(type, {\n authorized: toBuffer(params.newAuthorizedPubkey.toBuffer())\n });\n return new TransactionInstruction({\n keys: [{\n pubkey: params.noncePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: params.authorizedPubkey,\n isSigner: true,\n isWritable: false\n }],\n programId: this.programId,\n data\n });\n }\n\n /**\n * Generate a transaction instruction that allocates space in an account without funding\n */\n static allocate(params) {\n let data;\n let keys;\n if ('basePubkey' in params) {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.AllocateWithSeed;\n data = encodeData(type, {\n base: toBuffer(params.basePubkey.toBuffer()),\n seed: params.seed,\n space: params.space,\n programId: toBuffer(params.programId.toBuffer())\n });\n keys = [{\n pubkey: params.accountPubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: params.basePubkey,\n isSigner: true,\n isWritable: false\n }];\n } else {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.Allocate;\n data = encodeData(type, {\n space: params.space\n });\n keys = [{\n pubkey: params.accountPubkey,\n isSigner: true,\n isWritable: true\n }];\n }\n return new TransactionInstruction({\n keys,\n programId: this.programId,\n data\n });\n }\n}\nSystemProgram.programId = new PublicKey('11111111111111111111111111111111');\n\n// Keep program chunks under PACKET_DATA_SIZE, leaving enough room for the\n// rest of the Transaction fields\n//\n// TODO: replace 300 with a proper constant for the size of the other\n// Transaction fields\nconst CHUNK_SIZE = PACKET_DATA_SIZE - 300;\n\n/**\n * Program loader interface\n */\nclass Loader {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Amount of program data placed in each load Transaction\n */\n\n /**\n * Minimum number of signatures required to load a program not including\n * retries\n *\n * Can be used to calculate transaction fees\n */\n static getMinNumSignatures(dataLength) {\n return 2 * (\n // Every transaction requires two signatures (payer + program)\n Math.ceil(dataLength / Loader.chunkSize) + 1 +\n // Add one for Create transaction\n 1) // Add one for Finalize transaction\n ;\n }\n\n /**\n * Loads a generic program\n *\n * @param connection The connection to use\n * @param payer System account that pays to load the program\n * @param program Account to load the program into\n * @param programId Public key that identifies the loader\n * @param data Program octets\n * @return true if program was loaded successfully, false if program was already loaded\n */\n static async load(connection, payer, program, programId, data) {\n {\n const balanceNeeded = await connection.getMinimumBalanceForRentExemption(data.length);\n\n // Fetch program account info to check if it has already been created\n const programInfo = await connection.getAccountInfo(program.publicKey, 'confirmed');\n let transaction = null;\n if (programInfo !== null) {\n if (programInfo.executable) {\n console.error('Program load failed, account is already executable');\n return false;\n }\n if (programInfo.data.length !== data.length) {\n transaction = transaction || new Transaction();\n transaction.add(SystemProgram.allocate({\n accountPubkey: program.publicKey,\n space: data.length\n }));\n }\n if (!programInfo.owner.equals(programId)) {\n transaction = transaction || new Transaction();\n transaction.add(SystemProgram.assign({\n accountPubkey: program.publicKey,\n programId\n }));\n }\n if (programInfo.lamports < balanceNeeded) {\n transaction = transaction || new Transaction();\n transaction.add(SystemProgram.transfer({\n fromPubkey: payer.publicKey,\n toPubkey: program.publicKey,\n lamports: balanceNeeded - programInfo.lamports\n }));\n }\n } else {\n transaction = new Transaction().add(SystemProgram.createAccount({\n fromPubkey: payer.publicKey,\n newAccountPubkey: program.publicKey,\n lamports: balanceNeeded > 0 ? balanceNeeded : 1,\n space: data.length,\n programId\n }));\n }\n\n // If the account is already created correctly, skip this step\n // and proceed directly to loading instructions\n if (transaction !== null) {\n await sendAndConfirmTransaction(connection, transaction, [payer, program], {\n commitment: 'confirmed'\n });\n }\n }\n const dataLayout = BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.u32('offset'), BufferLayout.u32('bytesLength'), BufferLayout.u32('bytesLengthPadding'), BufferLayout.seq(BufferLayout.u8('byte'), BufferLayout.offset(BufferLayout.u32(), -8), 'bytes')]);\n const chunkSize = Loader.chunkSize;\n let offset = 0;\n let array = data;\n let transactions = [];\n while (array.length > 0) {\n const bytes = array.slice(0, chunkSize);\n const data = Buffer.alloc(chunkSize + 16);\n dataLayout.encode({\n instruction: 0,\n // Load instruction\n offset,\n bytes: bytes,\n bytesLength: 0,\n bytesLengthPadding: 0\n }, data);\n const transaction = new Transaction().add({\n keys: [{\n pubkey: program.publicKey,\n isSigner: true,\n isWritable: true\n }],\n programId,\n data\n });\n transactions.push(sendAndConfirmTransaction(connection, transaction, [payer, program], {\n commitment: 'confirmed'\n }));\n\n // Delay between sends in an attempt to reduce rate limit errors\n if (connection._rpcEndpoint.includes('solana.com')) {\n const REQUESTS_PER_SECOND = 4;\n await sleep(1000 / REQUESTS_PER_SECOND);\n }\n offset += chunkSize;\n array = array.slice(chunkSize);\n }\n await Promise.all(transactions);\n\n // Finalize the account loaded with program data for execution\n {\n const dataLayout = BufferLayout.struct([BufferLayout.u32('instruction')]);\n const data = Buffer.alloc(dataLayout.span);\n dataLayout.encode({\n instruction: 1 // Finalize instruction\n }, data);\n const transaction = new Transaction().add({\n keys: [{\n pubkey: program.publicKey,\n isSigner: true,\n isWritable: true\n }, {\n pubkey: SYSVAR_RENT_PUBKEY,\n isSigner: false,\n isWritable: false\n }],\n programId,\n data\n });\n const deployCommitment = 'processed';\n const finalizeSignature = await connection.sendTransaction(transaction, [payer, program], {\n preflightCommitment: deployCommitment\n });\n const {\n context,\n value\n } = await connection.confirmTransaction({\n signature: finalizeSignature,\n lastValidBlockHeight: transaction.lastValidBlockHeight,\n blockhash: transaction.recentBlockhash\n }, deployCommitment);\n if (value.err) {\n throw new Error(`Transaction ${finalizeSignature} failed (${JSON.stringify(value)})`);\n }\n // We prevent programs from being usable until the slot after their deployment.\n // See https://github.com/solana-labs/solana/pull/29654\n while (true // eslint-disable-line no-constant-condition\n ) {\n try {\n const currentSlot = await connection.getSlot({\n commitment: deployCommitment\n });\n if (currentSlot > context.slot) {\n break;\n }\n } catch {\n /* empty */\n }\n await new Promise(resolve => setTimeout(resolve, Math.round(MS_PER_SLOT / 2)));\n }\n }\n\n // success\n return true;\n }\n}\nLoader.chunkSize = CHUNK_SIZE;\n\n/**\n * @deprecated Deprecated since Solana v1.17.20.\n */\nconst BPF_LOADER_PROGRAM_ID = new PublicKey('BPFLoader2111111111111111111111111111111111');\n\n/**\n * Factory class for transactions to interact with a program loader\n *\n * @deprecated Deprecated since Solana v1.17.20.\n */\nclass BpfLoader {\n /**\n * Minimum number of signatures required to load a program not including\n * retries\n *\n * Can be used to calculate transaction fees\n */\n static getMinNumSignatures(dataLength) {\n return Loader.getMinNumSignatures(dataLength);\n }\n\n /**\n * Load a SBF program\n *\n * @param connection The connection to use\n * @param payer Account that will pay program loading fees\n * @param program Account to load the program into\n * @param elf The entire ELF containing the SBF program\n * @param loaderProgramId The program id of the BPF loader to use\n * @return true if program was loaded successfully, false if program was already loaded\n */\n static load(connection, payer, program, elf, loaderProgramId) {\n return Loader.load(connection, payer, program, loaderProgramId, elf);\n }\n}\n\nfunction getDefaultExportFromCjs (x) {\n\treturn x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;\n}\n\nvar fastStableStringify$1;\nvar hasRequiredFastStableStringify;\n\nfunction requireFastStableStringify () {\n\tif (hasRequiredFastStableStringify) return fastStableStringify$1;\n\thasRequiredFastStableStringify = 1;\n\tvar objToString = Object.prototype.toString;\n\tvar objKeys = Object.keys || function(obj) {\n\t\t\tvar keys = [];\n\t\t\tfor (var name in obj) {\n\t\t\t\tkeys.push(name);\n\t\t\t}\n\t\t\treturn keys;\n\t\t};\n\n\tfunction stringify(val, isArrayProp) {\n\t\tvar i, max, str, keys, key, propVal, toStr;\n\t\tif (val === true) {\n\t\t\treturn \"true\";\n\t\t}\n\t\tif (val === false) {\n\t\t\treturn \"false\";\n\t\t}\n\t\tswitch (typeof val) {\n\t\t\tcase \"object\":\n\t\t\t\tif (val === null) {\n\t\t\t\t\treturn null;\n\t\t\t\t} else if (val.toJSON && typeof val.toJSON === \"function\") {\n\t\t\t\t\treturn stringify(val.toJSON(), isArrayProp);\n\t\t\t\t} else {\n\t\t\t\t\ttoStr = objToString.call(val);\n\t\t\t\t\tif (toStr === \"[object Array]\") {\n\t\t\t\t\t\tstr = '[';\n\t\t\t\t\t\tmax = val.length - 1;\n\t\t\t\t\t\tfor(i = 0; i < max; i++) {\n\t\t\t\t\t\t\tstr += stringify(val[i], true) + ',';\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (max > -1) {\n\t\t\t\t\t\t\tstr += stringify(val[i], true);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn str + ']';\n\t\t\t\t\t} else if (toStr === \"[object Object]\") {\n\t\t\t\t\t\t// only object is left\n\t\t\t\t\t\tkeys = objKeys(val).sort();\n\t\t\t\t\t\tmax = keys.length;\n\t\t\t\t\t\tstr = \"\";\n\t\t\t\t\t\ti = 0;\n\t\t\t\t\t\twhile (i < max) {\n\t\t\t\t\t\t\tkey = keys[i];\n\t\t\t\t\t\t\tpropVal = stringify(val[key], false);\n\t\t\t\t\t\t\tif (propVal !== undefined) {\n\t\t\t\t\t\t\t\tif (str) {\n\t\t\t\t\t\t\t\t\tstr += ',';\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tstr += JSON.stringify(key) + ':' + propVal;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn '{' + str + '}';\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn JSON.stringify(val);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tcase \"function\":\n\t\t\tcase \"undefined\":\n\t\t\t\treturn isArrayProp ? null : undefined;\n\t\t\tcase \"string\":\n\t\t\t\treturn JSON.stringify(val);\n\t\t\tdefault:\n\t\t\t\treturn isFinite(val) ? val : null;\n\t\t}\n\t}\n\n\tfastStableStringify$1 = function(val) {\n\t\tvar returnVal = stringify(val, false);\n\t\tif (returnVal !== undefined) {\n\t\t\treturn ''+ returnVal;\n\t\t}\n\t};\n\treturn fastStableStringify$1;\n}\n\nvar fastStableStringifyExports = /*@__PURE__*/ requireFastStableStringify();\nvar fastStableStringify = /*@__PURE__*/getDefaultExportFromCjs(fastStableStringifyExports);\n\nconst MINIMUM_SLOT_PER_EPOCH = 32;\n\n// Returns the number of trailing zeros in the binary representation of self.\nfunction trailingZeros(n) {\n let trailingZeros = 0;\n while (n > 1) {\n n /= 2;\n trailingZeros++;\n }\n return trailingZeros;\n}\n\n// Returns the smallest power of two greater than or equal to n\nfunction nextPowerOfTwo(n) {\n if (n === 0) return 1;\n n--;\n n |= n >> 1;\n n |= n >> 2;\n n |= n >> 4;\n n |= n >> 8;\n n |= n >> 16;\n n |= n >> 32;\n return n + 1;\n}\n\n/**\n * Epoch schedule\n * (see https://docs.solana.com/terminology#epoch)\n * Can be retrieved with the {@link Connection.getEpochSchedule} method\n */\nclass EpochSchedule {\n constructor(slotsPerEpoch, leaderScheduleSlotOffset, warmup, firstNormalEpoch, firstNormalSlot) {\n /** The maximum number of slots in each epoch */\n this.slotsPerEpoch = void 0;\n /** The number of slots before beginning of an epoch to calculate a leader schedule for that epoch */\n this.leaderScheduleSlotOffset = void 0;\n /** Indicates whether epochs start short and grow */\n this.warmup = void 0;\n /** The first epoch with `slotsPerEpoch` slots */\n this.firstNormalEpoch = void 0;\n /** The first slot of `firstNormalEpoch` */\n this.firstNormalSlot = void 0;\n this.slotsPerEpoch = slotsPerEpoch;\n this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;\n this.warmup = warmup;\n this.firstNormalEpoch = firstNormalEpoch;\n this.firstNormalSlot = firstNormalSlot;\n }\n getEpoch(slot) {\n return this.getEpochAndSlotIndex(slot)[0];\n }\n getEpochAndSlotIndex(slot) {\n if (slot < this.firstNormalSlot) {\n const epoch = trailingZeros(nextPowerOfTwo(slot + MINIMUM_SLOT_PER_EPOCH + 1)) - trailingZeros(MINIMUM_SLOT_PER_EPOCH) - 1;\n const epochLen = this.getSlotsInEpoch(epoch);\n const slotIndex = slot - (epochLen - MINIMUM_SLOT_PER_EPOCH);\n return [epoch, slotIndex];\n } else {\n const normalSlotIndex = slot - this.firstNormalSlot;\n const normalEpochIndex = Math.floor(normalSlotIndex / this.slotsPerEpoch);\n const epoch = this.firstNormalEpoch + normalEpochIndex;\n const slotIndex = normalSlotIndex % this.slotsPerEpoch;\n return [epoch, slotIndex];\n }\n }\n getFirstSlotInEpoch(epoch) {\n if (epoch <= this.firstNormalEpoch) {\n return (Math.pow(2, epoch) - 1) * MINIMUM_SLOT_PER_EPOCH;\n } else {\n return (epoch - this.firstNormalEpoch) * this.slotsPerEpoch + this.firstNormalSlot;\n }\n }\n getLastSlotInEpoch(epoch) {\n return this.getFirstSlotInEpoch(epoch) + this.getSlotsInEpoch(epoch) - 1;\n }\n getSlotsInEpoch(epoch) {\n if (epoch < this.firstNormalEpoch) {\n return Math.pow(2, epoch + trailingZeros(MINIMUM_SLOT_PER_EPOCH));\n } else {\n return this.slotsPerEpoch;\n }\n }\n}\n\nvar fetchImpl = globalThis.fetch;\n\nclass RpcWebSocketClient extends CommonClient {\n constructor(address, options, generate_request_id) {\n const webSocketFactory = url => {\n const rpc = WebSocket(url, {\n autoconnect: true,\n max_reconnects: 5,\n reconnect: true,\n reconnect_interval: 1000,\n ...options\n });\n if ('socket' in rpc) {\n this.underlyingSocket = rpc.socket;\n } else {\n this.underlyingSocket = rpc;\n }\n return rpc;\n };\n super(webSocketFactory, address, options, generate_request_id);\n this.underlyingSocket = void 0;\n }\n call(...args) {\n const readyState = this.underlyingSocket?.readyState;\n if (readyState === 1 /* WebSocket.OPEN */) {\n return super.call(...args);\n }\n return Promise.reject(new Error('Tried to call a JSON-RPC method `' + args[0] + '` but the socket was not `CONNECTING` or `OPEN` (`readyState` was ' + readyState + ')'));\n }\n notify(...args) {\n const readyState = this.underlyingSocket?.readyState;\n if (readyState === 1 /* WebSocket.OPEN */) {\n return super.notify(...args);\n }\n return Promise.reject(new Error('Tried to send a JSON-RPC notification `' + args[0] + '` but the socket was not `CONNECTING` or `OPEN` (`readyState` was ' + readyState + ')'));\n }\n}\n\n/**\n * @internal\n */\n\n/**\n * Decode account data buffer using an AccountType\n * @internal\n */\nfunction decodeData(type, data) {\n let decoded;\n try {\n decoded = type.layout.decode(data);\n } catch (err) {\n throw new Error('invalid instruction; ' + err);\n }\n if (decoded.typeIndex !== type.index) {\n throw new Error(`invalid account data; account type mismatch ${decoded.typeIndex} != ${type.index}`);\n }\n return decoded;\n}\n\n/// The serialized size of lookup table metadata\nconst LOOKUP_TABLE_META_SIZE = 56;\nclass AddressLookupTableAccount {\n constructor(args) {\n this.key = void 0;\n this.state = void 0;\n this.key = args.key;\n this.state = args.state;\n }\n isActive() {\n const U64_MAX = BigInt('0xffffffffffffffff');\n return this.state.deactivationSlot === U64_MAX;\n }\n static deserialize(accountData) {\n const meta = decodeData(LookupTableMetaLayout, accountData);\n const serializedAddressesLen = accountData.length - LOOKUP_TABLE_META_SIZE;\n assert(serializedAddressesLen >= 0, 'lookup table is invalid');\n assert(serializedAddressesLen % 32 === 0, 'lookup table is invalid');\n const numSerializedAddresses = serializedAddressesLen / 32;\n const {\n addresses\n } = BufferLayout.struct([BufferLayout.seq(publicKey(), numSerializedAddresses, 'addresses')]).decode(accountData.slice(LOOKUP_TABLE_META_SIZE));\n return {\n deactivationSlot: meta.deactivationSlot,\n lastExtendedSlot: meta.lastExtendedSlot,\n lastExtendedSlotStartIndex: meta.lastExtendedStartIndex,\n authority: meta.authority.length !== 0 ? new PublicKey(meta.authority[0]) : undefined,\n addresses: addresses.map(address => new PublicKey(address))\n };\n }\n}\nconst LookupTableMetaLayout = {\n index: 1,\n layout: BufferLayout.struct([BufferLayout.u32('typeIndex'), u64('deactivationSlot'), BufferLayout.nu64('lastExtendedSlot'), BufferLayout.u8('lastExtendedStartIndex'), BufferLayout.u8(),\n // option\n BufferLayout.seq(publicKey(), BufferLayout.offset(BufferLayout.u8(), -1), 'authority')])\n};\n\nconst URL_RE = /^[^:]+:\\/\\/([^:[]+|\\[[^\\]]+\\])(:\\d+)?(.*)/i;\nfunction makeWebsocketUrl(endpoint) {\n const matches = endpoint.match(URL_RE);\n if (matches == null) {\n throw TypeError(`Failed to validate endpoint URL \\`${endpoint}\\``);\n }\n const [_,\n // eslint-disable-line @typescript-eslint/no-unused-vars\n hostish, portWithColon, rest] = matches;\n const protocol = endpoint.startsWith('https:') ? 'wss:' : 'ws:';\n const startPort = portWithColon == null ? null : parseInt(portWithColon.slice(1), 10);\n const websocketPort =\n // Only shift the port by +1 as a convention for ws(s) only if given endpoint\n // is explicitly specifying the endpoint port (HTTP-based RPC), assuming\n // we're directly trying to connect to agave-validator's ws listening port.\n // When the endpoint omits the port, we're connecting to the protocol\n // default ports: http(80) or https(443) and it's assumed we're behind a reverse\n // proxy which manages WebSocket upgrade and backend port redirection.\n startPort == null ? '' : `:${startPort + 1}`;\n return `${protocol}//${hostish}${websocketPort}${rest}`;\n}\n\nconst PublicKeyFromString = coerce(instance(PublicKey), string(), value => new PublicKey(value));\nconst RawAccountDataResult = tuple([string(), literal('base64')]);\nconst BufferFromRawAccountData = coerce(instance(Buffer), RawAccountDataResult, value => Buffer.from(value[0], 'base64'));\n\n/**\n * Attempt to use a recent blockhash for up to 30 seconds\n * @internal\n */\nconst BLOCKHASH_CACHE_TIMEOUT_MS = 30 * 1000;\n\n/**\n * HACK.\n * Copied from rpc-websockets/dist/lib/client.\n * Otherwise, `yarn build` fails with:\n * https://gist.github.com/steveluscher/c057eca81d479ef705cdb53162f9971d\n */\n\n/** @internal */\n/** @internal */\n/** @internal */\n/** @internal */\n\n/** @internal */\n/**\n * @internal\n * Every subscription contains the args used to open the subscription with\n * the server, and a list of callers interested in notifications.\n */\n\n/**\n * @internal\n * A subscription may be in various states of connectedness. Only when it is\n * fully connected will it have a server subscription id associated with it.\n * This id can be returned to the server to unsubscribe the client entirely.\n */\n\n/**\n * A type that encapsulates a subscription's RPC method\n * names and notification (callback) signature.\n */\n\n/**\n * @internal\n * Utility type that keeps tagged unions intact while omitting properties.\n */\n\n/**\n * @internal\n * This type represents a single subscribable 'topic.' It's made up of:\n *\n * - The args used to open the subscription with the server,\n * - The state of the subscription, in terms of its connectedness, and\n * - The set of callbacks to call when the server publishes notifications\n *\n * This record gets indexed by `SubscriptionConfigHash` and is used to\n * set up subscriptions, fan out notifications, and track subscription state.\n */\n\n/**\n * @internal\n */\n\n/**\n * Extra contextual information for RPC responses\n */\n\n/**\n * Options for sending transactions\n */\n\n/**\n * Options for confirming transactions\n */\n\n/**\n * Options for getConfirmedSignaturesForAddress2\n */\n\n/**\n * Options for getSignaturesForAddress\n */\n\n/**\n * RPC Response with extra contextual information\n */\n\n/**\n * A strategy for confirming transactions that uses the last valid\n * block height for a given blockhash to check for transaction expiration.\n */\n\n/**\n * A strategy for confirming durable nonce transactions.\n */\n\n/**\n * Properties shared by all transaction confirmation strategies\n */\n\n/**\n * This type represents all transaction confirmation strategies\n */\n\n/* @internal */\nfunction assertEndpointUrl(putativeUrl) {\n if (/^https?:/.test(putativeUrl) === false) {\n throw new TypeError('Endpoint URL must start with `http:` or `https:`.');\n }\n return putativeUrl;\n}\n\n/** @internal */\nfunction extractCommitmentFromConfig(commitmentOrConfig) {\n let commitment;\n let config;\n if (typeof commitmentOrConfig === 'string') {\n commitment = commitmentOrConfig;\n } else if (commitmentOrConfig) {\n const {\n commitment: specifiedCommitment,\n ...specifiedConfig\n } = commitmentOrConfig;\n commitment = specifiedCommitment;\n config = specifiedConfig;\n }\n return {\n commitment,\n config\n };\n}\n\n/**\n * @internal\n */\nfunction applyDefaultMemcmpEncodingToFilters(filters) {\n return filters.map(filter => 'memcmp' in filter ? {\n ...filter,\n memcmp: {\n ...filter.memcmp,\n encoding: filter.memcmp.encoding ?? 'base58'\n }\n } : filter);\n}\n\n/**\n * @internal\n */\nfunction createRpcResult(result) {\n return union([type({\n jsonrpc: literal('2.0'),\n id: string(),\n result\n }), type({\n jsonrpc: literal('2.0'),\n id: string(),\n error: type({\n code: unknown(),\n message: string(),\n data: optional(any())\n })\n })]);\n}\nconst UnknownRpcResult = createRpcResult(unknown());\n\n/**\n * @internal\n */\nfunction jsonRpcResult(schema) {\n return coerce(createRpcResult(schema), UnknownRpcResult, value => {\n if ('error' in value) {\n return value;\n } else {\n return {\n ...value,\n result: create(value.result, schema)\n };\n }\n });\n}\n\n/**\n * @internal\n */\nfunction jsonRpcResultAndContext(value) {\n return jsonRpcResult(type({\n context: type({\n slot: number()\n }),\n value\n }));\n}\n\n/**\n * @internal\n */\nfunction notificationResultAndContext(value) {\n return type({\n context: type({\n slot: number()\n }),\n value\n });\n}\n\n/**\n * @internal\n */\nfunction versionedMessageFromResponse(version, response) {\n if (version === 0) {\n return new MessageV0({\n header: response.header,\n staticAccountKeys: response.accountKeys.map(accountKey => new PublicKey(accountKey)),\n recentBlockhash: response.recentBlockhash,\n compiledInstructions: response.instructions.map(ix => ({\n programIdIndex: ix.programIdIndex,\n accountKeyIndexes: ix.accounts,\n data: bs58.decode(ix.data)\n })),\n addressTableLookups: response.addressTableLookups\n });\n } else {\n return new Message(response);\n }\n}\n\n/**\n * The level of commitment desired when querying state\n *
\n *   'processed': Query the most recent block which has reached 1 confirmation by the connected node\n *   'confirmed': Query the most recent block which has reached 1 confirmation by the cluster\n *   'finalized': Query the most recent block which has been finalized by the cluster\n * 
\n */\n\n// Deprecated as of v1.5.5\n\n/**\n * A subset of Commitment levels, which are at least optimistically confirmed\n *
\n *   'confirmed': Query the most recent block which has reached 1 confirmation by the cluster\n *   'finalized': Query the most recent block which has been finalized by the cluster\n * 
\n */\n\n/**\n * Filter for largest accounts query\n *
\n *   'circulating':    Return the largest accounts that are part of the circulating supply\n *   'nonCirculating': Return the largest accounts that are not part of the circulating supply\n * 
\n */\n\n/**\n * Configuration object for changing `getAccountInfo` query behavior\n */\n\n/**\n * Configuration object for changing `getBalance` query behavior\n */\n\n/**\n * Configuration object for changing `getBlock` query behavior\n */\n\n/**\n * Configuration object for changing `getBlock` query behavior\n */\n\n/**\n * Configuration object for changing `getStakeMinimumDelegation` query behavior\n */\n\n/**\n * Configuration object for changing `getBlockHeight` query behavior\n */\n\n/**\n * Configuration object for changing `getEpochInfo` query behavior\n */\n\n/**\n * Configuration object for changing `getInflationReward` query behavior\n */\n\n/**\n * Configuration object for changing `getLatestBlockhash` query behavior\n */\n\n/**\n * Configuration object for changing `isBlockhashValid` query behavior\n */\n\n/**\n * Configuration object for changing `getSlot` query behavior\n */\n\n/**\n * Configuration object for changing `getSlotLeader` query behavior\n */\n\n/**\n * Configuration object for changing `getTransaction` query behavior\n */\n\n/**\n * Configuration object for changing `getTransaction` query behavior\n */\n\n/**\n * Configuration object for changing `getLargestAccounts` query behavior\n */\n\n/**\n * Configuration object for changing `getSupply` request behavior\n */\n\n/**\n * Configuration object for changing query behavior\n */\n\n/**\n * Information describing a cluster node\n */\n\n/**\n * Information describing a vote account\n */\n\n/**\n * A collection of cluster vote accounts\n */\n\n/**\n * Network Inflation\n * (see https://docs.solana.com/implemented-proposals/ed_overview)\n */\n\nconst GetInflationGovernorResult = type({\n foundation: number(),\n foundationTerm: number(),\n initial: number(),\n taper: number(),\n terminal: number()\n});\n\n/**\n * The inflation reward for an epoch\n */\n\n/**\n * Expected JSON RPC response for the \"getInflationReward\" message\n */\nconst GetInflationRewardResult = jsonRpcResult(array(nullable(type({\n epoch: number(),\n effectiveSlot: number(),\n amount: number(),\n postBalance: number(),\n commission: optional(nullable(number()))\n}))));\n\n/**\n * Configuration object for changing `getRecentPrioritizationFees` query behavior\n */\n\n/**\n * Expected JSON RPC response for the \"getRecentPrioritizationFees\" message\n */\nconst GetRecentPrioritizationFeesResult = array(type({\n slot: number(),\n prioritizationFee: number()\n}));\n/**\n * Expected JSON RPC response for the \"getInflationRate\" message\n */\nconst GetInflationRateResult = type({\n total: number(),\n validator: number(),\n foundation: number(),\n epoch: number()\n});\n\n/**\n * Information about the current epoch\n */\n\nconst GetEpochInfoResult = type({\n epoch: number(),\n slotIndex: number(),\n slotsInEpoch: number(),\n absoluteSlot: number(),\n blockHeight: optional(number()),\n transactionCount: optional(number())\n});\nconst GetEpochScheduleResult = type({\n slotsPerEpoch: number(),\n leaderScheduleSlotOffset: number(),\n warmup: boolean(),\n firstNormalEpoch: number(),\n firstNormalSlot: number()\n});\n\n/**\n * Leader schedule\n * (see https://docs.solana.com/terminology#leader-schedule)\n */\n\nconst GetLeaderScheduleResult = record(string(), array(number()));\n\n/**\n * Transaction error or null\n */\nconst TransactionErrorResult = nullable(union([type({}), string()]));\n\n/**\n * Signature status for a transaction\n */\nconst SignatureStatusResult = type({\n err: TransactionErrorResult\n});\n\n/**\n * Transaction signature received notification\n */\nconst SignatureReceivedResult = literal('receivedSignature');\n\n/**\n * Version info for a node\n */\n\nconst VersionResult = type({\n 'solana-core': string(),\n 'feature-set': optional(number())\n});\nconst ParsedInstructionStruct = type({\n program: string(),\n programId: PublicKeyFromString,\n parsed: unknown()\n});\nconst PartiallyDecodedInstructionStruct = type({\n programId: PublicKeyFromString,\n accounts: array(PublicKeyFromString),\n data: string()\n});\nconst SimulatedTransactionResponseStruct = jsonRpcResultAndContext(type({\n err: nullable(union([type({}), string()])),\n logs: nullable(array(string())),\n accounts: optional(nullable(array(nullable(type({\n executable: boolean(),\n owner: string(),\n lamports: number(),\n data: array(string()),\n rentEpoch: optional(number())\n }))))),\n unitsConsumed: optional(number()),\n returnData: optional(nullable(type({\n programId: string(),\n data: tuple([string(), literal('base64')])\n }))),\n innerInstructions: optional(nullable(array(type({\n index: number(),\n instructions: array(union([ParsedInstructionStruct, PartiallyDecodedInstructionStruct]))\n }))))\n}));\n\n/**\n * Metadata for a parsed confirmed transaction on the ledger\n *\n * @deprecated Deprecated since RPC v1.8.0. Please use {@link ParsedTransactionMeta} instead.\n */\n\n/**\n * Collection of addresses loaded by a transaction using address table lookups\n */\n\n/**\n * Metadata for a parsed transaction on the ledger\n */\n\n/**\n * Metadata for a confirmed transaction on the ledger\n */\n\n/**\n * A processed transaction from the RPC API\n */\n\n/**\n * A processed transaction from the RPC API\n */\n\n/**\n * A processed transaction message from the RPC API\n */\n\n/**\n * A confirmed transaction on the ledger\n *\n * @deprecated Deprecated since RPC v1.8.0.\n */\n\n/**\n * A partially decoded transaction instruction\n */\n\n/**\n * A parsed transaction message account\n */\n\n/**\n * A parsed transaction instruction\n */\n\n/**\n * A parsed address table lookup\n */\n\n/**\n * A parsed transaction message\n */\n\n/**\n * A parsed transaction\n */\n\n/**\n * A parsed and confirmed transaction on the ledger\n *\n * @deprecated Deprecated since RPC v1.8.0. Please use {@link ParsedTransactionWithMeta} instead.\n */\n\n/**\n * A parsed transaction on the ledger with meta\n */\n\n/**\n * A processed block fetched from the RPC API\n */\n\n/**\n * A processed block fetched from the RPC API where the `transactionDetails` mode is `accounts`\n */\n\n/**\n * A processed block fetched from the RPC API where the `transactionDetails` mode is `none`\n */\n\n/**\n * A block with parsed transactions\n */\n\n/**\n * A block with parsed transactions where the `transactionDetails` mode is `accounts`\n */\n\n/**\n * A block with parsed transactions where the `transactionDetails` mode is `none`\n */\n\n/**\n * A processed block fetched from the RPC API\n */\n\n/**\n * A processed block fetched from the RPC API where the `transactionDetails` mode is `accounts`\n */\n\n/**\n * A processed block fetched from the RPC API where the `transactionDetails` mode is `none`\n */\n\n/**\n * A confirmed block on the ledger\n *\n * @deprecated Deprecated since RPC v1.8.0.\n */\n\n/**\n * A Block on the ledger with signatures only\n */\n\n/**\n * recent block production information\n */\n\n/**\n * Expected JSON RPC response for the \"getBlockProduction\" message\n */\nconst BlockProductionResponseStruct = jsonRpcResultAndContext(type({\n byIdentity: record(string(), array(number())),\n range: type({\n firstSlot: number(),\n lastSlot: number()\n })\n}));\n\n/**\n * A performance sample\n */\n\nfunction createRpcClient(url, httpHeaders, customFetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent) {\n const fetch = customFetch ? customFetch : fetchImpl;\n let agent;\n {\n if (httpAgent != null) {\n console.warn('You have supplied an `httpAgent` when creating a `Connection` in a browser environment.' + 'It has been ignored; `httpAgent` is only used in Node environments.');\n }\n }\n let fetchWithMiddleware;\n if (fetchMiddleware) {\n fetchWithMiddleware = async (info, init) => {\n const modifiedFetchArgs = await new Promise((resolve, reject) => {\n try {\n fetchMiddleware(info, init, (modifiedInfo, modifiedInit) => resolve([modifiedInfo, modifiedInit]));\n } catch (error) {\n reject(error);\n }\n });\n return await fetch(...modifiedFetchArgs);\n };\n }\n const clientBrowser = new RpcClient(async (request, callback) => {\n const options = {\n method: 'POST',\n body: request,\n agent,\n headers: Object.assign({\n 'Content-Type': 'application/json'\n }, httpHeaders || {}, COMMON_HTTP_HEADERS)\n };\n try {\n let too_many_requests_retries = 5;\n let res;\n let waitTime = 500;\n for (;;) {\n if (fetchWithMiddleware) {\n res = await fetchWithMiddleware(url, options);\n } else {\n res = await fetch(url, options);\n }\n if (res.status !== 429 /* Too many requests */) {\n break;\n }\n if (disableRetryOnRateLimit === true) {\n break;\n }\n too_many_requests_retries -= 1;\n if (too_many_requests_retries === 0) {\n break;\n }\n console.error(`Server responded with ${res.status} ${res.statusText}. Retrying after ${waitTime}ms delay...`);\n await sleep(waitTime);\n waitTime *= 2;\n }\n const text = await res.text();\n if (res.ok) {\n callback(null, text);\n } else {\n callback(new Error(`${res.status} ${res.statusText}: ${text}`));\n }\n } catch (err) {\n if (err instanceof Error) callback(err);\n }\n }, {});\n return clientBrowser;\n}\nfunction createRpcRequest(client) {\n return (method, args) => {\n return new Promise((resolve, reject) => {\n client.request(method, args, (err, response) => {\n if (err) {\n reject(err);\n return;\n }\n resolve(response);\n });\n });\n };\n}\nfunction createRpcBatchRequest(client) {\n return requests => {\n return new Promise((resolve, reject) => {\n // Do nothing if requests is empty\n if (requests.length === 0) resolve([]);\n const batch = requests.map(params => {\n return client.request(params.methodName, params.args);\n });\n client.request(batch, (err, response) => {\n if (err) {\n reject(err);\n return;\n }\n resolve(response);\n });\n });\n };\n}\n\n/**\n * Expected JSON RPC response for the \"getInflationGovernor\" message\n */\nconst GetInflationGovernorRpcResult = jsonRpcResult(GetInflationGovernorResult);\n\n/**\n * Expected JSON RPC response for the \"getInflationRate\" message\n */\nconst GetInflationRateRpcResult = jsonRpcResult(GetInflationRateResult);\n\n/**\n * Expected JSON RPC response for the \"getRecentPrioritizationFees\" message\n */\nconst GetRecentPrioritizationFeesRpcResult = jsonRpcResult(GetRecentPrioritizationFeesResult);\n\n/**\n * Expected JSON RPC response for the \"getEpochInfo\" message\n */\nconst GetEpochInfoRpcResult = jsonRpcResult(GetEpochInfoResult);\n\n/**\n * Expected JSON RPC response for the \"getEpochSchedule\" message\n */\nconst GetEpochScheduleRpcResult = jsonRpcResult(GetEpochScheduleResult);\n\n/**\n * Expected JSON RPC response for the \"getLeaderSchedule\" message\n */\nconst GetLeaderScheduleRpcResult = jsonRpcResult(GetLeaderScheduleResult);\n\n/**\n * Expected JSON RPC response for the \"minimumLedgerSlot\" and \"getFirstAvailableBlock\" messages\n */\nconst SlotRpcResult = jsonRpcResult(number());\n\n/**\n * Supply\n */\n\n/**\n * Expected JSON RPC response for the \"getSupply\" message\n */\nconst GetSupplyRpcResult = jsonRpcResultAndContext(type({\n total: number(),\n circulating: number(),\n nonCirculating: number(),\n nonCirculatingAccounts: array(PublicKeyFromString)\n}));\n\n/**\n * Token amount object which returns a token amount in different formats\n * for various client use cases.\n */\n\n/**\n * Expected JSON RPC structure for token amounts\n */\nconst TokenAmountResult = type({\n amount: string(),\n uiAmount: nullable(number()),\n decimals: number(),\n uiAmountString: optional(string())\n});\n\n/**\n * Token address and balance.\n */\n\n/**\n * Expected JSON RPC response for the \"getTokenLargestAccounts\" message\n */\nconst GetTokenLargestAccountsResult = jsonRpcResultAndContext(array(type({\n address: PublicKeyFromString,\n amount: string(),\n uiAmount: nullable(number()),\n decimals: number(),\n uiAmountString: optional(string())\n})));\n\n/**\n * Expected JSON RPC response for the \"getTokenAccountsByOwner\" message\n */\nconst GetTokenAccountsByOwner = jsonRpcResultAndContext(array(type({\n pubkey: PublicKeyFromString,\n account: type({\n executable: boolean(),\n owner: PublicKeyFromString,\n lamports: number(),\n data: BufferFromRawAccountData,\n rentEpoch: number()\n })\n})));\nconst ParsedAccountDataResult = type({\n program: string(),\n parsed: unknown(),\n space: number()\n});\n\n/**\n * Expected JSON RPC response for the \"getTokenAccountsByOwner\" message with parsed data\n */\nconst GetParsedTokenAccountsByOwner = jsonRpcResultAndContext(array(type({\n pubkey: PublicKeyFromString,\n account: type({\n executable: boolean(),\n owner: PublicKeyFromString,\n lamports: number(),\n data: ParsedAccountDataResult,\n rentEpoch: number()\n })\n})));\n\n/**\n * Pair of an account address and its balance\n */\n\n/**\n * Expected JSON RPC response for the \"getLargestAccounts\" message\n */\nconst GetLargestAccountsRpcResult = jsonRpcResultAndContext(array(type({\n lamports: number(),\n address: PublicKeyFromString\n})));\n\n/**\n * @internal\n */\nconst AccountInfoResult = type({\n executable: boolean(),\n owner: PublicKeyFromString,\n lamports: number(),\n data: BufferFromRawAccountData,\n rentEpoch: number()\n});\n\n/**\n * @internal\n */\nconst KeyedAccountInfoResult = type({\n pubkey: PublicKeyFromString,\n account: AccountInfoResult\n});\nconst ParsedOrRawAccountData = coerce(union([instance(Buffer), ParsedAccountDataResult]), union([RawAccountDataResult, ParsedAccountDataResult]), value => {\n if (Array.isArray(value)) {\n return create(value, BufferFromRawAccountData);\n } else {\n return value;\n }\n});\n\n/**\n * @internal\n */\nconst ParsedAccountInfoResult = type({\n executable: boolean(),\n owner: PublicKeyFromString,\n lamports: number(),\n data: ParsedOrRawAccountData,\n rentEpoch: number()\n});\nconst KeyedParsedAccountInfoResult = type({\n pubkey: PublicKeyFromString,\n account: ParsedAccountInfoResult\n});\n\n/**\n * @internal\n */\nconst StakeActivationResult = type({\n state: union([literal('active'), literal('inactive'), literal('activating'), literal('deactivating')]),\n active: number(),\n inactive: number()\n});\n\n/**\n * Expected JSON RPC response for the \"getConfirmedSignaturesForAddress2\" message\n */\n\nconst GetConfirmedSignaturesForAddress2RpcResult = jsonRpcResult(array(type({\n signature: string(),\n slot: number(),\n err: TransactionErrorResult,\n memo: nullable(string()),\n blockTime: optional(nullable(number()))\n})));\n\n/**\n * Expected JSON RPC response for the \"getSignaturesForAddress\" message\n */\nconst GetSignaturesForAddressRpcResult = jsonRpcResult(array(type({\n signature: string(),\n slot: number(),\n err: TransactionErrorResult,\n memo: nullable(string()),\n blockTime: optional(nullable(number()))\n})));\n\n/***\n * Expected JSON RPC response for the \"accountNotification\" message\n */\nconst AccountNotificationResult = type({\n subscription: number(),\n result: notificationResultAndContext(AccountInfoResult)\n});\n\n/**\n * @internal\n */\nconst ProgramAccountInfoResult = type({\n pubkey: PublicKeyFromString,\n account: AccountInfoResult\n});\n\n/***\n * Expected JSON RPC response for the \"programNotification\" message\n */\nconst ProgramAccountNotificationResult = type({\n subscription: number(),\n result: notificationResultAndContext(ProgramAccountInfoResult)\n});\n\n/**\n * @internal\n */\nconst SlotInfoResult = type({\n parent: number(),\n slot: number(),\n root: number()\n});\n\n/**\n * Expected JSON RPC response for the \"slotNotification\" message\n */\nconst SlotNotificationResult = type({\n subscription: number(),\n result: SlotInfoResult\n});\n\n/**\n * Slot updates which can be used for tracking the live progress of a cluster.\n * - `\"firstShredReceived\"`: connected node received the first shred of a block.\n * Indicates that a new block that is being produced.\n * - `\"completed\"`: connected node has received all shreds of a block. Indicates\n * a block was recently produced.\n * - `\"optimisticConfirmation\"`: block was optimistically confirmed by the\n * cluster. It is not guaranteed that an optimistic confirmation notification\n * will be sent for every finalized blocks.\n * - `\"root\"`: the connected node rooted this block.\n * - `\"createdBank\"`: the connected node has started validating this block.\n * - `\"frozen\"`: the connected node has validated this block.\n * - `\"dead\"`: the connected node failed to validate this block.\n */\n\n/**\n * @internal\n */\nconst SlotUpdateResult = union([type({\n type: union([literal('firstShredReceived'), literal('completed'), literal('optimisticConfirmation'), literal('root')]),\n slot: number(),\n timestamp: number()\n}), type({\n type: literal('createdBank'),\n parent: number(),\n slot: number(),\n timestamp: number()\n}), type({\n type: literal('frozen'),\n slot: number(),\n timestamp: number(),\n stats: type({\n numTransactionEntries: number(),\n numSuccessfulTransactions: number(),\n numFailedTransactions: number(),\n maxTransactionsPerEntry: number()\n })\n}), type({\n type: literal('dead'),\n slot: number(),\n timestamp: number(),\n err: string()\n})]);\n\n/**\n * Expected JSON RPC response for the \"slotsUpdatesNotification\" message\n */\nconst SlotUpdateNotificationResult = type({\n subscription: number(),\n result: SlotUpdateResult\n});\n\n/**\n * Expected JSON RPC response for the \"signatureNotification\" message\n */\nconst SignatureNotificationResult = type({\n subscription: number(),\n result: notificationResultAndContext(union([SignatureStatusResult, SignatureReceivedResult]))\n});\n\n/**\n * Expected JSON RPC response for the \"rootNotification\" message\n */\nconst RootNotificationResult = type({\n subscription: number(),\n result: number()\n});\nconst ContactInfoResult = type({\n pubkey: string(),\n gossip: nullable(string()),\n tpu: nullable(string()),\n rpc: nullable(string()),\n version: nullable(string())\n});\nconst VoteAccountInfoResult = type({\n votePubkey: string(),\n nodePubkey: string(),\n activatedStake: number(),\n epochVoteAccount: boolean(),\n epochCredits: array(tuple([number(), number(), number()])),\n commission: number(),\n lastVote: number(),\n rootSlot: nullable(number())\n});\n\n/**\n * Expected JSON RPC response for the \"getVoteAccounts\" message\n */\nconst GetVoteAccounts = jsonRpcResult(type({\n current: array(VoteAccountInfoResult),\n delinquent: array(VoteAccountInfoResult)\n}));\nconst ConfirmationStatus = union([literal('processed'), literal('confirmed'), literal('finalized')]);\nconst SignatureStatusResponse = type({\n slot: number(),\n confirmations: nullable(number()),\n err: TransactionErrorResult,\n confirmationStatus: optional(ConfirmationStatus)\n});\n\n/**\n * Expected JSON RPC response for the \"getSignatureStatuses\" message\n */\nconst GetSignatureStatusesRpcResult = jsonRpcResultAndContext(array(nullable(SignatureStatusResponse)));\n\n/**\n * Expected JSON RPC response for the \"getMinimumBalanceForRentExemption\" message\n */\nconst GetMinimumBalanceForRentExemptionRpcResult = jsonRpcResult(number());\nconst AddressTableLookupStruct = type({\n accountKey: PublicKeyFromString,\n writableIndexes: array(number()),\n readonlyIndexes: array(number())\n});\nconst ConfirmedTransactionResult = type({\n signatures: array(string()),\n message: type({\n accountKeys: array(string()),\n header: type({\n numRequiredSignatures: number(),\n numReadonlySignedAccounts: number(),\n numReadonlyUnsignedAccounts: number()\n }),\n instructions: array(type({\n accounts: array(number()),\n data: string(),\n programIdIndex: number()\n })),\n recentBlockhash: string(),\n addressTableLookups: optional(array(AddressTableLookupStruct))\n })\n});\nconst AnnotatedAccountKey = type({\n pubkey: PublicKeyFromString,\n signer: boolean(),\n writable: boolean(),\n source: optional(union([literal('transaction'), literal('lookupTable')]))\n});\nconst ConfirmedTransactionAccountsModeResult = type({\n accountKeys: array(AnnotatedAccountKey),\n signatures: array(string())\n});\nconst ParsedInstructionResult = type({\n parsed: unknown(),\n program: string(),\n programId: PublicKeyFromString\n});\nconst RawInstructionResult = type({\n accounts: array(PublicKeyFromString),\n data: string(),\n programId: PublicKeyFromString\n});\nconst InstructionResult = union([RawInstructionResult, ParsedInstructionResult]);\nconst UnknownInstructionResult = union([type({\n parsed: unknown(),\n program: string(),\n programId: string()\n}), type({\n accounts: array(string()),\n data: string(),\n programId: string()\n})]);\nconst ParsedOrRawInstruction = coerce(InstructionResult, UnknownInstructionResult, value => {\n if ('accounts' in value) {\n return create(value, RawInstructionResult);\n } else {\n return create(value, ParsedInstructionResult);\n }\n});\n\n/**\n * @internal\n */\nconst ParsedConfirmedTransactionResult = type({\n signatures: array(string()),\n message: type({\n accountKeys: array(AnnotatedAccountKey),\n instructions: array(ParsedOrRawInstruction),\n recentBlockhash: string(),\n addressTableLookups: optional(nullable(array(AddressTableLookupStruct)))\n })\n});\nconst TokenBalanceResult = type({\n accountIndex: number(),\n mint: string(),\n owner: optional(string()),\n programId: optional(string()),\n uiTokenAmount: TokenAmountResult\n});\nconst LoadedAddressesResult = type({\n writable: array(PublicKeyFromString),\n readonly: array(PublicKeyFromString)\n});\n\n/**\n * @internal\n */\nconst ConfirmedTransactionMetaResult = type({\n err: TransactionErrorResult,\n fee: number(),\n innerInstructions: optional(nullable(array(type({\n index: number(),\n instructions: array(type({\n accounts: array(number()),\n data: string(),\n programIdIndex: number()\n }))\n })))),\n preBalances: array(number()),\n postBalances: array(number()),\n logMessages: optional(nullable(array(string()))),\n preTokenBalances: optional(nullable(array(TokenBalanceResult))),\n postTokenBalances: optional(nullable(array(TokenBalanceResult))),\n loadedAddresses: optional(LoadedAddressesResult),\n computeUnitsConsumed: optional(number())\n});\n\n/**\n * @internal\n */\nconst ParsedConfirmedTransactionMetaResult = type({\n err: TransactionErrorResult,\n fee: number(),\n innerInstructions: optional(nullable(array(type({\n index: number(),\n instructions: array(ParsedOrRawInstruction)\n })))),\n preBalances: array(number()),\n postBalances: array(number()),\n logMessages: optional(nullable(array(string()))),\n preTokenBalances: optional(nullable(array(TokenBalanceResult))),\n postTokenBalances: optional(nullable(array(TokenBalanceResult))),\n loadedAddresses: optional(LoadedAddressesResult),\n computeUnitsConsumed: optional(number())\n});\nconst TransactionVersionStruct = union([literal(0), literal('legacy')]);\n\n/** @internal */\nconst RewardsResult = type({\n pubkey: string(),\n lamports: number(),\n postBalance: nullable(number()),\n rewardType: nullable(string()),\n commission: optional(nullable(number()))\n});\n\n/**\n * Expected JSON RPC response for the \"getBlock\" message\n */\nconst GetBlockRpcResult = jsonRpcResult(nullable(type({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n transactions: array(type({\n transaction: ConfirmedTransactionResult,\n meta: nullable(ConfirmedTransactionMetaResult),\n version: optional(TransactionVersionStruct)\n })),\n rewards: optional(array(RewardsResult)),\n blockTime: nullable(number()),\n blockHeight: nullable(number())\n})));\n\n/**\n * Expected JSON RPC response for the \"getBlock\" message when `transactionDetails` is `none`\n */\nconst GetNoneModeBlockRpcResult = jsonRpcResult(nullable(type({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n rewards: optional(array(RewardsResult)),\n blockTime: nullable(number()),\n blockHeight: nullable(number())\n})));\n\n/**\n * Expected JSON RPC response for the \"getBlock\" message when `transactionDetails` is `accounts`\n */\nconst GetAccountsModeBlockRpcResult = jsonRpcResult(nullable(type({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n transactions: array(type({\n transaction: ConfirmedTransactionAccountsModeResult,\n meta: nullable(ConfirmedTransactionMetaResult),\n version: optional(TransactionVersionStruct)\n })),\n rewards: optional(array(RewardsResult)),\n blockTime: nullable(number()),\n blockHeight: nullable(number())\n})));\n\n/**\n * Expected parsed JSON RPC response for the \"getBlock\" message\n */\nconst GetParsedBlockRpcResult = jsonRpcResult(nullable(type({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n transactions: array(type({\n transaction: ParsedConfirmedTransactionResult,\n meta: nullable(ParsedConfirmedTransactionMetaResult),\n version: optional(TransactionVersionStruct)\n })),\n rewards: optional(array(RewardsResult)),\n blockTime: nullable(number()),\n blockHeight: nullable(number())\n})));\n\n/**\n * Expected parsed JSON RPC response for the \"getBlock\" message when `transactionDetails` is `accounts`\n */\nconst GetParsedAccountsModeBlockRpcResult = jsonRpcResult(nullable(type({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n transactions: array(type({\n transaction: ConfirmedTransactionAccountsModeResult,\n meta: nullable(ParsedConfirmedTransactionMetaResult),\n version: optional(TransactionVersionStruct)\n })),\n rewards: optional(array(RewardsResult)),\n blockTime: nullable(number()),\n blockHeight: nullable(number())\n})));\n\n/**\n * Expected parsed JSON RPC response for the \"getBlock\" message when `transactionDetails` is `none`\n */\nconst GetParsedNoneModeBlockRpcResult = jsonRpcResult(nullable(type({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n rewards: optional(array(RewardsResult)),\n blockTime: nullable(number()),\n blockHeight: nullable(number())\n})));\n\n/**\n * Expected JSON RPC response for the \"getConfirmedBlock\" message\n *\n * @deprecated Deprecated since RPC v1.8.0. Please use {@link GetBlockRpcResult} instead.\n */\nconst GetConfirmedBlockRpcResult = jsonRpcResult(nullable(type({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n transactions: array(type({\n transaction: ConfirmedTransactionResult,\n meta: nullable(ConfirmedTransactionMetaResult)\n })),\n rewards: optional(array(RewardsResult)),\n blockTime: nullable(number())\n})));\n\n/**\n * Expected JSON RPC response for the \"getBlock\" message\n */\nconst GetBlockSignaturesRpcResult = jsonRpcResult(nullable(type({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n signatures: array(string()),\n blockTime: nullable(number())\n})));\n\n/**\n * Expected JSON RPC response for the \"getTransaction\" message\n */\nconst GetTransactionRpcResult = jsonRpcResult(nullable(type({\n slot: number(),\n meta: nullable(ConfirmedTransactionMetaResult),\n blockTime: optional(nullable(number())),\n transaction: ConfirmedTransactionResult,\n version: optional(TransactionVersionStruct)\n})));\n\n/**\n * Expected parsed JSON RPC response for the \"getTransaction\" message\n */\nconst GetParsedTransactionRpcResult = jsonRpcResult(nullable(type({\n slot: number(),\n transaction: ParsedConfirmedTransactionResult,\n meta: nullable(ParsedConfirmedTransactionMetaResult),\n blockTime: optional(nullable(number())),\n version: optional(TransactionVersionStruct)\n})));\n\n/**\n * Expected JSON RPC response for the \"getLatestBlockhash\" message\n */\nconst GetLatestBlockhashRpcResult = jsonRpcResultAndContext(type({\n blockhash: string(),\n lastValidBlockHeight: number()\n}));\n\n/**\n * Expected JSON RPC response for the \"isBlockhashValid\" message\n */\nconst IsBlockhashValidRpcResult = jsonRpcResultAndContext(boolean());\nconst PerfSampleResult = type({\n slot: number(),\n numTransactions: number(),\n numSlots: number(),\n samplePeriodSecs: number()\n});\n\n/*\n * Expected JSON RPC response for \"getRecentPerformanceSamples\" message\n */\nconst GetRecentPerformanceSamplesRpcResult = jsonRpcResult(array(PerfSampleResult));\n\n/**\n * Expected JSON RPC response for the \"getFeeCalculatorForBlockhash\" message\n */\nconst GetFeeCalculatorRpcResult = jsonRpcResultAndContext(nullable(type({\n feeCalculator: type({\n lamportsPerSignature: number()\n })\n})));\n\n/**\n * Expected JSON RPC response for the \"requestAirdrop\" message\n */\nconst RequestAirdropRpcResult = jsonRpcResult(string());\n\n/**\n * Expected JSON RPC response for the \"sendTransaction\" message\n */\nconst SendTransactionRpcResult = jsonRpcResult(string());\n\n/**\n * Information about the latest slot being processed by a node\n */\n\n/**\n * Parsed account data\n */\n\n/**\n * Stake Activation data\n */\n\n/**\n * Data slice argument for getProgramAccounts\n */\n\n/**\n * Memory comparison filter for getProgramAccounts\n */\n\n/**\n * Data size comparison filter for getProgramAccounts\n */\n\n/**\n * A filter object for getProgramAccounts\n */\n\n/**\n * Configuration object for getProgramAccounts requests\n */\n\n/**\n * Configuration object for getParsedProgramAccounts\n */\n\n/**\n * Configuration object for getMultipleAccounts\n */\n\n/**\n * Configuration object for `getStakeActivation`\n */\n\n/**\n * Configuration object for `getStakeActivation`\n */\n\n/**\n * Configuration object for `getStakeActivation`\n */\n\n/**\n * Configuration object for `getNonce`\n */\n\n/**\n * Configuration object for `getNonceAndContext`\n */\n\n/**\n * Information describing an account\n */\n\n/**\n * Account information identified by pubkey\n */\n\n/**\n * Callback function for account change notifications\n */\n\n/**\n * Callback function for program account change notifications\n */\n\n/**\n * Callback function for slot change notifications\n */\n\n/**\n * Callback function for slot update notifications\n */\n\n/**\n * Callback function for signature status notifications\n */\n\n/**\n * Signature status notification with transaction result\n */\n\n/**\n * Signature received notification\n */\n\n/**\n * Callback function for signature notifications\n */\n\n/**\n * Signature subscription options\n */\n\n/**\n * Callback function for root change notifications\n */\n\n/**\n * @internal\n */\nconst LogsResult = type({\n err: TransactionErrorResult,\n logs: array(string()),\n signature: string()\n});\n\n/**\n * Logs result.\n */\n\n/**\n * Expected JSON RPC response for the \"logsNotification\" message.\n */\nconst LogsNotificationResult = type({\n result: notificationResultAndContext(LogsResult),\n subscription: number()\n});\n\n/**\n * Filter for log subscriptions.\n */\n\n/**\n * Callback function for log notifications.\n */\n\n/**\n * Signature result\n */\n\n/**\n * Transaction error\n */\n\n/**\n * Transaction confirmation status\n *
\n *   'processed': Transaction landed in a block which has reached 1 confirmation by the connected node\n *   'confirmed': Transaction landed in a block which has reached 1 confirmation by the cluster\n *   'finalized': Transaction landed in a block which has been finalized by the cluster\n * 
\n */\n\n/**\n * Signature status\n */\n\n/**\n * A confirmed signature with its status\n */\n\n/**\n * An object defining headers to be passed to the RPC server\n */\n\n/**\n * The type of the JavaScript `fetch()` API\n */\n\n/**\n * A callback used to augment the outgoing HTTP request\n */\n\n/**\n * Configuration for instantiating a Connection\n */\n\n/** @internal */\nconst COMMON_HTTP_HEADERS = {\n 'solana-client': `js/${\"1.0.0-maintenance\"}`\n};\n\n/**\n * A connection to a fullnode JSON RPC endpoint\n */\nclass Connection {\n /**\n * Establish a JSON RPC connection\n *\n * @param endpoint URL to the fullnode JSON RPC endpoint\n * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object\n */\n constructor(endpoint, _commitmentOrConfig) {\n /** @internal */\n this._commitment = void 0;\n /** @internal */\n this._confirmTransactionInitialTimeout = void 0;\n /** @internal */\n this._rpcEndpoint = void 0;\n /** @internal */\n this._rpcWsEndpoint = void 0;\n /** @internal */\n this._rpcClient = void 0;\n /** @internal */\n this._rpcRequest = void 0;\n /** @internal */\n this._rpcBatchRequest = void 0;\n /** @internal */\n this._rpcWebSocket = void 0;\n /** @internal */\n this._rpcWebSocketConnected = false;\n /** @internal */\n this._rpcWebSocketHeartbeat = null;\n /** @internal */\n this._rpcWebSocketIdleTimeout = null;\n /** @internal\n * A number that we increment every time an active connection closes.\n * Used to determine whether the same socket connection that was open\n * when an async operation started is the same one that's active when\n * its continuation fires.\n *\n */\n this._rpcWebSocketGeneration = 0;\n /** @internal */\n this._disableBlockhashCaching = false;\n /** @internal */\n this._pollingBlockhash = false;\n /** @internal */\n this._blockhashInfo = {\n latestBlockhash: null,\n lastFetch: 0,\n transactionSignatures: [],\n simulatedSignatures: []\n };\n /** @internal */\n this._nextClientSubscriptionId = 0;\n /** @internal */\n this._subscriptionDisposeFunctionsByClientSubscriptionId = {};\n /** @internal */\n this._subscriptionHashByClientSubscriptionId = {};\n /** @internal */\n this._subscriptionStateChangeCallbacksByHash = {};\n /** @internal */\n this._subscriptionCallbacksByServerSubscriptionId = {};\n /** @internal */\n this._subscriptionsByHash = {};\n /**\n * Special case.\n * After a signature is processed, RPCs automatically dispose of the\n * subscription on the server side. We need to track which of these\n * subscriptions have been disposed in such a way, so that we know\n * whether the client is dealing with a not-yet-processed signature\n * (in which case we must tear down the server subscription) or an\n * already-processed signature (in which case the client can simply\n * clear out the subscription locally without telling the server).\n *\n * NOTE: There is a proposal to eliminate this special case, here:\n * https://github.com/solana-labs/solana/issues/18892\n */\n /** @internal */\n this._subscriptionsAutoDisposedByRpc = new Set();\n /*\n * Returns the current block height of the node\n */\n this.getBlockHeight = (() => {\n const requestPromises = {};\n return async commitmentOrConfig => {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([], commitment, undefined /* encoding */, config);\n const requestHash = fastStableStringify(args);\n requestPromises[requestHash] = requestPromises[requestHash] ?? (async () => {\n try {\n const unsafeRes = await this._rpcRequest('getBlockHeight', args);\n const res = create(unsafeRes, jsonRpcResult(number()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get block height information');\n }\n return res.result;\n } finally {\n delete requestPromises[requestHash];\n }\n })();\n return await requestPromises[requestHash];\n };\n })();\n let wsEndpoint;\n let httpHeaders;\n let fetch;\n let fetchMiddleware;\n let disableRetryOnRateLimit;\n let httpAgent;\n if (_commitmentOrConfig && typeof _commitmentOrConfig === 'string') {\n this._commitment = _commitmentOrConfig;\n } else if (_commitmentOrConfig) {\n this._commitment = _commitmentOrConfig.commitment;\n this._confirmTransactionInitialTimeout = _commitmentOrConfig.confirmTransactionInitialTimeout;\n wsEndpoint = _commitmentOrConfig.wsEndpoint;\n httpHeaders = _commitmentOrConfig.httpHeaders;\n fetch = _commitmentOrConfig.fetch;\n fetchMiddleware = _commitmentOrConfig.fetchMiddleware;\n disableRetryOnRateLimit = _commitmentOrConfig.disableRetryOnRateLimit;\n httpAgent = _commitmentOrConfig.httpAgent;\n }\n this._rpcEndpoint = assertEndpointUrl(endpoint);\n this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);\n this._rpcClient = createRpcClient(endpoint, httpHeaders, fetch, fetchMiddleware, disableRetryOnRateLimit, httpAgent);\n this._rpcRequest = createRpcRequest(this._rpcClient);\n this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);\n this._rpcWebSocket = new RpcWebSocketClient(this._rpcWsEndpoint, {\n autoconnect: false,\n max_reconnects: Infinity\n });\n this._rpcWebSocket.on('open', this._wsOnOpen.bind(this));\n this._rpcWebSocket.on('error', this._wsOnError.bind(this));\n this._rpcWebSocket.on('close', this._wsOnClose.bind(this));\n this._rpcWebSocket.on('accountNotification', this._wsOnAccountNotification.bind(this));\n this._rpcWebSocket.on('programNotification', this._wsOnProgramAccountNotification.bind(this));\n this._rpcWebSocket.on('slotNotification', this._wsOnSlotNotification.bind(this));\n this._rpcWebSocket.on('slotsUpdatesNotification', this._wsOnSlotUpdatesNotification.bind(this));\n this._rpcWebSocket.on('signatureNotification', this._wsOnSignatureNotification.bind(this));\n this._rpcWebSocket.on('rootNotification', this._wsOnRootNotification.bind(this));\n this._rpcWebSocket.on('logsNotification', this._wsOnLogsNotification.bind(this));\n }\n\n /**\n * The default commitment used for requests\n */\n get commitment() {\n return this._commitment;\n }\n\n /**\n * The RPC endpoint\n */\n get rpcEndpoint() {\n return this._rpcEndpoint;\n }\n\n /**\n * Fetch the balance for the specified public key, return with context\n */\n async getBalanceAndContext(publicKey, commitmentOrConfig) {\n /** @internal */\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([publicKey.toBase58()], commitment, undefined /* encoding */, config);\n const unsafeRes = await this._rpcRequest('getBalance', args);\n const res = create(unsafeRes, jsonRpcResultAndContext(number()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, `failed to get balance for ${publicKey.toBase58()}`);\n }\n return res.result;\n }\n\n /**\n * Fetch the balance for the specified public key\n */\n async getBalance(publicKey, commitmentOrConfig) {\n return await this.getBalanceAndContext(publicKey, commitmentOrConfig).then(x => x.value).catch(e => {\n throw new Error('failed to get balance of account ' + publicKey.toBase58() + ': ' + e);\n });\n }\n\n /**\n * Fetch the estimated production time of a block\n */\n async getBlockTime(slot) {\n const unsafeRes = await this._rpcRequest('getBlockTime', [slot]);\n const res = create(unsafeRes, jsonRpcResult(nullable(number())));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, `failed to get block time for slot ${slot}`);\n }\n return res.result;\n }\n\n /**\n * Fetch the lowest slot that the node has information about in its ledger.\n * This value may increase over time if the node is configured to purge older ledger data\n */\n async getMinimumLedgerSlot() {\n const unsafeRes = await this._rpcRequest('minimumLedgerSlot', []);\n const res = create(unsafeRes, jsonRpcResult(number()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get minimum ledger slot');\n }\n return res.result;\n }\n\n /**\n * Fetch the slot of the lowest confirmed block that has not been purged from the ledger\n */\n async getFirstAvailableBlock() {\n const unsafeRes = await this._rpcRequest('getFirstAvailableBlock', []);\n const res = create(unsafeRes, SlotRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get first available block');\n }\n return res.result;\n }\n\n /**\n * Fetch information about the current supply\n */\n async getSupply(config) {\n let configArg = {};\n if (typeof config === 'string') {\n configArg = {\n commitment: config\n };\n } else if (config) {\n configArg = {\n ...config,\n commitment: config && config.commitment || this.commitment\n };\n } else {\n configArg = {\n commitment: this.commitment\n };\n }\n const unsafeRes = await this._rpcRequest('getSupply', [configArg]);\n const res = create(unsafeRes, GetSupplyRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get supply');\n }\n return res.result;\n }\n\n /**\n * Fetch the current supply of a token mint\n */\n async getTokenSupply(tokenMintAddress, commitment) {\n const args = this._buildArgs([tokenMintAddress.toBase58()], commitment);\n const unsafeRes = await this._rpcRequest('getTokenSupply', args);\n const res = create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get token supply');\n }\n return res.result;\n }\n\n /**\n * Fetch the current balance of a token account\n */\n async getTokenAccountBalance(tokenAddress, commitment) {\n const args = this._buildArgs([tokenAddress.toBase58()], commitment);\n const unsafeRes = await this._rpcRequest('getTokenAccountBalance', args);\n const res = create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get token account balance');\n }\n return res.result;\n }\n\n /**\n * Fetch all the token accounts owned by the specified account\n *\n * @return {Promise}\n */\n async getTokenAccountsByOwner(ownerAddress, filter, commitmentOrConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n let _args = [ownerAddress.toBase58()];\n if ('mint' in filter) {\n _args.push({\n mint: filter.mint.toBase58()\n });\n } else {\n _args.push({\n programId: filter.programId.toBase58()\n });\n }\n const args = this._buildArgs(_args, commitment, 'base64', config);\n const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);\n const res = create(unsafeRes, GetTokenAccountsByOwner);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);\n }\n return res.result;\n }\n\n /**\n * Fetch parsed token accounts owned by the specified account\n *\n * @return {Promise}>>>}\n */\n async getParsedTokenAccountsByOwner(ownerAddress, filter, commitment) {\n let _args = [ownerAddress.toBase58()];\n if ('mint' in filter) {\n _args.push({\n mint: filter.mint.toBase58()\n });\n } else {\n _args.push({\n programId: filter.programId.toBase58()\n });\n }\n const args = this._buildArgs(_args, commitment, 'jsonParsed');\n const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);\n const res = create(unsafeRes, GetParsedTokenAccountsByOwner);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, `failed to get token accounts owned by account ${ownerAddress.toBase58()}`);\n }\n return res.result;\n }\n\n /**\n * Fetch the 20 largest accounts with their current balances\n */\n async getLargestAccounts(config) {\n const arg = {\n ...config,\n commitment: config && config.commitment || this.commitment\n };\n const args = arg.filter || arg.commitment ? [arg] : [];\n const unsafeRes = await this._rpcRequest('getLargestAccounts', args);\n const res = create(unsafeRes, GetLargestAccountsRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get largest accounts');\n }\n return res.result;\n }\n\n /**\n * Fetch the 20 largest token accounts with their current balances\n * for a given mint.\n */\n async getTokenLargestAccounts(mintAddress, commitment) {\n const args = this._buildArgs([mintAddress.toBase58()], commitment);\n const unsafeRes = await this._rpcRequest('getTokenLargestAccounts', args);\n const res = create(unsafeRes, GetTokenLargestAccountsResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get token largest accounts');\n }\n return res.result;\n }\n\n /**\n * Fetch all the account info for the specified public key, return with context\n */\n async getAccountInfoAndContext(publicKey, commitmentOrConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([publicKey.toBase58()], commitment, 'base64', config);\n const unsafeRes = await this._rpcRequest('getAccountInfo', args);\n const res = create(unsafeRes, jsonRpcResultAndContext(nullable(AccountInfoResult)));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);\n }\n return res.result;\n }\n\n /**\n * Fetch parsed account info for the specified public key\n */\n async getParsedAccountInfo(publicKey, commitmentOrConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([publicKey.toBase58()], commitment, 'jsonParsed', config);\n const unsafeRes = await this._rpcRequest('getAccountInfo', args);\n const res = create(unsafeRes, jsonRpcResultAndContext(nullable(ParsedAccountInfoResult)));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, `failed to get info about account ${publicKey.toBase58()}`);\n }\n return res.result;\n }\n\n /**\n * Fetch all the account info for the specified public key\n */\n async getAccountInfo(publicKey, commitmentOrConfig) {\n try {\n const res = await this.getAccountInfoAndContext(publicKey, commitmentOrConfig);\n return res.value;\n } catch (e) {\n throw new Error('failed to get info about account ' + publicKey.toBase58() + ': ' + e);\n }\n }\n\n /**\n * Fetch all the account info for multiple accounts specified by an array of public keys, return with context\n */\n async getMultipleParsedAccounts(publicKeys, rawConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(rawConfig);\n const keys = publicKeys.map(key => key.toBase58());\n const args = this._buildArgs([keys], commitment, 'jsonParsed', config);\n const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);\n const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(ParsedAccountInfoResult))));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, `failed to get info for accounts ${keys}`);\n }\n return res.result;\n }\n\n /**\n * Fetch all the account info for multiple accounts specified by an array of public keys, return with context\n */\n async getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const keys = publicKeys.map(key => key.toBase58());\n const args = this._buildArgs([keys], commitment, 'base64', config);\n const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);\n const res = create(unsafeRes, jsonRpcResultAndContext(array(nullable(AccountInfoResult))));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, `failed to get info for accounts ${keys}`);\n }\n return res.result;\n }\n\n /**\n * Fetch all the account info for multiple accounts specified by an array of public keys\n */\n async getMultipleAccountsInfo(publicKeys, commitmentOrConfig) {\n const res = await this.getMultipleAccountsInfoAndContext(publicKeys, commitmentOrConfig);\n return res.value;\n }\n\n /**\n * Returns epoch activation information for a stake account that has been delegated\n *\n * @deprecated Deprecated since RPC v1.18; will be removed in a future version.\n */\n async getStakeActivation(publicKey, commitmentOrConfig, epoch) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([publicKey.toBase58()], commitment, undefined /* encoding */, {\n ...config,\n epoch: epoch != null ? epoch : config?.epoch\n });\n const unsafeRes = await this._rpcRequest('getStakeActivation', args);\n const res = create(unsafeRes, jsonRpcResult(StakeActivationResult));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, `failed to get Stake Activation ${publicKey.toBase58()}`);\n }\n return res.result;\n }\n\n /**\n * Fetch all the accounts owned by the specified program id\n *\n * @return {Promise}>>}\n */\n\n // eslint-disable-next-line no-dupe-class-members\n\n // eslint-disable-next-line no-dupe-class-members\n async getProgramAccounts(programId, configOrCommitment) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(configOrCommitment);\n const {\n encoding,\n ...configWithoutEncoding\n } = config || {};\n const args = this._buildArgs([programId.toBase58()], commitment, encoding || 'base64', {\n ...configWithoutEncoding,\n ...(configWithoutEncoding.filters ? {\n filters: applyDefaultMemcmpEncodingToFilters(configWithoutEncoding.filters)\n } : null)\n });\n const unsafeRes = await this._rpcRequest('getProgramAccounts', args);\n const baseSchema = array(KeyedAccountInfoResult);\n const res = configWithoutEncoding.withContext === true ? create(unsafeRes, jsonRpcResultAndContext(baseSchema)) : create(unsafeRes, jsonRpcResult(baseSchema));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);\n }\n return res.result;\n }\n\n /**\n * Fetch and parse all the accounts owned by the specified program id\n *\n * @return {Promise}>>}\n */\n async getParsedProgramAccounts(programId, configOrCommitment) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(configOrCommitment);\n const args = this._buildArgs([programId.toBase58()], commitment, 'jsonParsed', config);\n const unsafeRes = await this._rpcRequest('getProgramAccounts', args);\n const res = create(unsafeRes, jsonRpcResult(array(KeyedParsedAccountInfoResult)));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, `failed to get accounts owned by program ${programId.toBase58()}`);\n }\n return res.result;\n }\n\n /** @deprecated Instead, call `confirmTransaction` and pass in {@link TransactionConfirmationStrategy} */\n // eslint-disable-next-line no-dupe-class-members\n\n // eslint-disable-next-line no-dupe-class-members\n async confirmTransaction(strategy, commitment) {\n let rawSignature;\n if (typeof strategy == 'string') {\n rawSignature = strategy;\n } else {\n const config = strategy;\n if (config.abortSignal?.aborted) {\n return Promise.reject(config.abortSignal.reason);\n }\n rawSignature = config.signature;\n }\n let decodedSignature;\n try {\n decodedSignature = bs58.decode(rawSignature);\n } catch (err) {\n throw new Error('signature must be base58 encoded: ' + rawSignature);\n }\n assert(decodedSignature.length === 64, 'signature has invalid length');\n if (typeof strategy === 'string') {\n return await this.confirmTransactionUsingLegacyTimeoutStrategy({\n commitment: commitment || this.commitment,\n signature: rawSignature\n });\n } else if ('lastValidBlockHeight' in strategy) {\n return await this.confirmTransactionUsingBlockHeightExceedanceStrategy({\n commitment: commitment || this.commitment,\n strategy\n });\n } else {\n return await this.confirmTransactionUsingDurableNonceStrategy({\n commitment: commitment || this.commitment,\n strategy\n });\n }\n }\n getCancellationPromise(signal) {\n return new Promise((_, reject) => {\n if (signal == null) {\n return;\n }\n if (signal.aborted) {\n reject(signal.reason);\n } else {\n signal.addEventListener('abort', () => {\n reject(signal.reason);\n });\n }\n });\n }\n getTransactionConfirmationPromise({\n commitment,\n signature\n }) {\n let signatureSubscriptionId;\n let disposeSignatureSubscriptionStateChangeObserver;\n let done = false;\n const confirmationPromise = new Promise((resolve, reject) => {\n try {\n signatureSubscriptionId = this.onSignature(signature, (result, context) => {\n signatureSubscriptionId = undefined;\n const response = {\n context,\n value: result\n };\n resolve({\n __type: TransactionStatus.PROCESSED,\n response\n });\n }, commitment);\n const subscriptionSetupPromise = new Promise(resolveSubscriptionSetup => {\n if (signatureSubscriptionId == null) {\n resolveSubscriptionSetup();\n } else {\n disposeSignatureSubscriptionStateChangeObserver = this._onSubscriptionStateChange(signatureSubscriptionId, nextState => {\n if (nextState === 'subscribed') {\n resolveSubscriptionSetup();\n }\n });\n }\n });\n (async () => {\n await subscriptionSetupPromise;\n if (done) return;\n const response = await this.getSignatureStatus(signature);\n if (done) return;\n if (response == null) {\n return;\n }\n const {\n context,\n value\n } = response;\n if (value == null) {\n return;\n }\n if (value?.err) {\n reject(value.err);\n } else {\n switch (commitment) {\n case 'confirmed':\n case 'single':\n case 'singleGossip':\n {\n if (value.confirmationStatus === 'processed') {\n return;\n }\n break;\n }\n case 'finalized':\n case 'max':\n case 'root':\n {\n if (value.confirmationStatus === 'processed' || value.confirmationStatus === 'confirmed') {\n return;\n }\n break;\n }\n // exhaust enums to ensure full coverage\n case 'processed':\n case 'recent':\n }\n done = true;\n resolve({\n __type: TransactionStatus.PROCESSED,\n response: {\n context,\n value\n }\n });\n }\n })();\n } catch (err) {\n reject(err);\n }\n });\n const abortConfirmation = () => {\n if (disposeSignatureSubscriptionStateChangeObserver) {\n disposeSignatureSubscriptionStateChangeObserver();\n disposeSignatureSubscriptionStateChangeObserver = undefined;\n }\n if (signatureSubscriptionId != null) {\n this.removeSignatureListener(signatureSubscriptionId);\n signatureSubscriptionId = undefined;\n }\n };\n return {\n abortConfirmation,\n confirmationPromise\n };\n }\n async confirmTransactionUsingBlockHeightExceedanceStrategy({\n commitment,\n strategy: {\n abortSignal,\n lastValidBlockHeight,\n signature\n }\n }) {\n let done = false;\n const expiryPromise = new Promise(resolve => {\n const checkBlockHeight = async () => {\n try {\n const blockHeight = await this.getBlockHeight(commitment);\n return blockHeight;\n } catch (_e) {\n return -1;\n }\n };\n (async () => {\n let currentBlockHeight = await checkBlockHeight();\n if (done) return;\n while (currentBlockHeight <= lastValidBlockHeight) {\n await sleep(1000);\n if (done) return;\n currentBlockHeight = await checkBlockHeight();\n if (done) return;\n }\n resolve({\n __type: TransactionStatus.BLOCKHEIGHT_EXCEEDED\n });\n })();\n });\n const {\n abortConfirmation,\n confirmationPromise\n } = this.getTransactionConfirmationPromise({\n commitment,\n signature\n });\n const cancellationPromise = this.getCancellationPromise(abortSignal);\n let result;\n try {\n const outcome = await Promise.race([cancellationPromise, confirmationPromise, expiryPromise]);\n if (outcome.__type === TransactionStatus.PROCESSED) {\n result = outcome.response;\n } else {\n throw new TransactionExpiredBlockheightExceededError(signature);\n }\n } finally {\n done = true;\n abortConfirmation();\n }\n return result;\n }\n async confirmTransactionUsingDurableNonceStrategy({\n commitment,\n strategy: {\n abortSignal,\n minContextSlot,\n nonceAccountPubkey,\n nonceValue,\n signature\n }\n }) {\n let done = false;\n const expiryPromise = new Promise(resolve => {\n let currentNonceValue = nonceValue;\n let lastCheckedSlot = null;\n const getCurrentNonceValue = async () => {\n try {\n const {\n context,\n value: nonceAccount\n } = await this.getNonceAndContext(nonceAccountPubkey, {\n commitment,\n minContextSlot\n });\n lastCheckedSlot = context.slot;\n return nonceAccount?.nonce;\n } catch (e) {\n // If for whatever reason we can't reach/read the nonce\n // account, just keep using the last-known value.\n return currentNonceValue;\n }\n };\n (async () => {\n currentNonceValue = await getCurrentNonceValue();\n if (done) return;\n while (true // eslint-disable-line no-constant-condition\n ) {\n if (nonceValue !== currentNonceValue) {\n resolve({\n __type: TransactionStatus.NONCE_INVALID,\n slotInWhichNonceDidAdvance: lastCheckedSlot\n });\n return;\n }\n await sleep(2000);\n if (done) return;\n currentNonceValue = await getCurrentNonceValue();\n if (done) return;\n }\n })();\n });\n const {\n abortConfirmation,\n confirmationPromise\n } = this.getTransactionConfirmationPromise({\n commitment,\n signature\n });\n const cancellationPromise = this.getCancellationPromise(abortSignal);\n let result;\n try {\n const outcome = await Promise.race([cancellationPromise, confirmationPromise, expiryPromise]);\n if (outcome.__type === TransactionStatus.PROCESSED) {\n result = outcome.response;\n } else {\n // Double check that the transaction is indeed unconfirmed.\n let signatureStatus;\n while (true // eslint-disable-line no-constant-condition\n ) {\n const status = await this.getSignatureStatus(signature);\n if (status == null) {\n break;\n }\n if (status.context.slot < (outcome.slotInWhichNonceDidAdvance ?? minContextSlot)) {\n await sleep(400);\n continue;\n }\n signatureStatus = status;\n break;\n }\n if (signatureStatus?.value) {\n const commitmentForStatus = commitment || 'finalized';\n const {\n confirmationStatus\n } = signatureStatus.value;\n switch (commitmentForStatus) {\n case 'processed':\n case 'recent':\n if (confirmationStatus !== 'processed' && confirmationStatus !== 'confirmed' && confirmationStatus !== 'finalized') {\n throw new TransactionExpiredNonceInvalidError(signature);\n }\n break;\n case 'confirmed':\n case 'single':\n case 'singleGossip':\n if (confirmationStatus !== 'confirmed' && confirmationStatus !== 'finalized') {\n throw new TransactionExpiredNonceInvalidError(signature);\n }\n break;\n case 'finalized':\n case 'max':\n case 'root':\n if (confirmationStatus !== 'finalized') {\n throw new TransactionExpiredNonceInvalidError(signature);\n }\n break;\n default:\n // Exhaustive switch.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n (_ => {})(commitmentForStatus);\n }\n result = {\n context: signatureStatus.context,\n value: {\n err: signatureStatus.value.err\n }\n };\n } else {\n throw new TransactionExpiredNonceInvalidError(signature);\n }\n }\n } finally {\n done = true;\n abortConfirmation();\n }\n return result;\n }\n async confirmTransactionUsingLegacyTimeoutStrategy({\n commitment,\n signature\n }) {\n let timeoutId;\n const expiryPromise = new Promise(resolve => {\n let timeoutMs = this._confirmTransactionInitialTimeout || 60 * 1000;\n switch (commitment) {\n case 'processed':\n case 'recent':\n case 'single':\n case 'confirmed':\n case 'singleGossip':\n {\n timeoutMs = this._confirmTransactionInitialTimeout || 30 * 1000;\n break;\n }\n }\n timeoutId = setTimeout(() => resolve({\n __type: TransactionStatus.TIMED_OUT,\n timeoutMs\n }), timeoutMs);\n });\n const {\n abortConfirmation,\n confirmationPromise\n } = this.getTransactionConfirmationPromise({\n commitment,\n signature\n });\n let result;\n try {\n const outcome = await Promise.race([confirmationPromise, expiryPromise]);\n if (outcome.__type === TransactionStatus.PROCESSED) {\n result = outcome.response;\n } else {\n throw new TransactionExpiredTimeoutError(signature, outcome.timeoutMs / 1000);\n }\n } finally {\n clearTimeout(timeoutId);\n abortConfirmation();\n }\n return result;\n }\n\n /**\n * Return the list of nodes that are currently participating in the cluster\n */\n async getClusterNodes() {\n const unsafeRes = await this._rpcRequest('getClusterNodes', []);\n const res = create(unsafeRes, jsonRpcResult(array(ContactInfoResult)));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get cluster nodes');\n }\n return res.result;\n }\n\n /**\n * Return the list of nodes that are currently participating in the cluster\n */\n async getVoteAccounts(commitment) {\n const args = this._buildArgs([], commitment);\n const unsafeRes = await this._rpcRequest('getVoteAccounts', args);\n const res = create(unsafeRes, GetVoteAccounts);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get vote accounts');\n }\n return res.result;\n }\n\n /**\n * Fetch the current slot that the node is processing\n */\n async getSlot(commitmentOrConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([], commitment, undefined /* encoding */, config);\n const unsafeRes = await this._rpcRequest('getSlot', args);\n const res = create(unsafeRes, jsonRpcResult(number()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get slot');\n }\n return res.result;\n }\n\n /**\n * Fetch the current slot leader of the cluster\n */\n async getSlotLeader(commitmentOrConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([], commitment, undefined /* encoding */, config);\n const unsafeRes = await this._rpcRequest('getSlotLeader', args);\n const res = create(unsafeRes, jsonRpcResult(string()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get slot leader');\n }\n return res.result;\n }\n\n /**\n * Fetch `limit` number of slot leaders starting from `startSlot`\n *\n * @param startSlot fetch slot leaders starting from this slot\n * @param limit number of slot leaders to return\n */\n async getSlotLeaders(startSlot, limit) {\n const args = [startSlot, limit];\n const unsafeRes = await this._rpcRequest('getSlotLeaders', args);\n const res = create(unsafeRes, jsonRpcResult(array(PublicKeyFromString)));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get slot leaders');\n }\n return res.result;\n }\n\n /**\n * Fetch the current status of a signature\n */\n async getSignatureStatus(signature, config) {\n const {\n context,\n value: values\n } = await this.getSignatureStatuses([signature], config);\n assert(values.length === 1);\n const value = values[0];\n return {\n context,\n value\n };\n }\n\n /**\n * Fetch the current statuses of a batch of signatures\n */\n async getSignatureStatuses(signatures, config) {\n const params = [signatures];\n if (config) {\n params.push(config);\n }\n const unsafeRes = await this._rpcRequest('getSignatureStatuses', params);\n const res = create(unsafeRes, GetSignatureStatusesRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get signature status');\n }\n return res.result;\n }\n\n /**\n * Fetch the current transaction count of the cluster\n */\n async getTransactionCount(commitmentOrConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([], commitment, undefined /* encoding */, config);\n const unsafeRes = await this._rpcRequest('getTransactionCount', args);\n const res = create(unsafeRes, jsonRpcResult(number()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get transaction count');\n }\n return res.result;\n }\n\n /**\n * Fetch the current total currency supply of the cluster in lamports\n *\n * @deprecated Deprecated since RPC v1.2.8. Please use {@link getSupply} instead.\n */\n async getTotalSupply(commitment) {\n const result = await this.getSupply({\n commitment,\n excludeNonCirculatingAccountsList: true\n });\n return result.value.total;\n }\n\n /**\n * Fetch the cluster InflationGovernor parameters\n */\n async getInflationGovernor(commitment) {\n const args = this._buildArgs([], commitment);\n const unsafeRes = await this._rpcRequest('getInflationGovernor', args);\n const res = create(unsafeRes, GetInflationGovernorRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get inflation');\n }\n return res.result;\n }\n\n /**\n * Fetch the inflation reward for a list of addresses for an epoch\n */\n async getInflationReward(addresses, epoch, commitmentOrConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([addresses.map(pubkey => pubkey.toBase58())], commitment, undefined /* encoding */, {\n ...config,\n epoch: epoch != null ? epoch : config?.epoch\n });\n const unsafeRes = await this._rpcRequest('getInflationReward', args);\n const res = create(unsafeRes, GetInflationRewardResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get inflation reward');\n }\n return res.result;\n }\n\n /**\n * Fetch the specific inflation values for the current epoch\n */\n async getInflationRate() {\n const unsafeRes = await this._rpcRequest('getInflationRate', []);\n const res = create(unsafeRes, GetInflationRateRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get inflation rate');\n }\n return res.result;\n }\n\n /**\n * Fetch the Epoch Info parameters\n */\n async getEpochInfo(commitmentOrConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([], commitment, undefined /* encoding */, config);\n const unsafeRes = await this._rpcRequest('getEpochInfo', args);\n const res = create(unsafeRes, GetEpochInfoRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get epoch info');\n }\n return res.result;\n }\n\n /**\n * Fetch the Epoch Schedule parameters\n */\n async getEpochSchedule() {\n const unsafeRes = await this._rpcRequest('getEpochSchedule', []);\n const res = create(unsafeRes, GetEpochScheduleRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get epoch schedule');\n }\n const epochSchedule = res.result;\n return new EpochSchedule(epochSchedule.slotsPerEpoch, epochSchedule.leaderScheduleSlotOffset, epochSchedule.warmup, epochSchedule.firstNormalEpoch, epochSchedule.firstNormalSlot);\n }\n\n /**\n * Fetch the leader schedule for the current epoch\n * @return {Promise>}\n */\n async getLeaderSchedule() {\n const unsafeRes = await this._rpcRequest('getLeaderSchedule', []);\n const res = create(unsafeRes, GetLeaderScheduleRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get leader schedule');\n }\n return res.result;\n }\n\n /**\n * Fetch the minimum balance needed to exempt an account of `dataLength`\n * size from rent\n */\n async getMinimumBalanceForRentExemption(dataLength, commitment) {\n const args = this._buildArgs([dataLength], commitment);\n const unsafeRes = await this._rpcRequest('getMinimumBalanceForRentExemption', args);\n const res = create(unsafeRes, GetMinimumBalanceForRentExemptionRpcResult);\n if ('error' in res) {\n console.warn('Unable to fetch minimum balance for rent exemption');\n return 0;\n }\n return res.result;\n }\n\n /**\n * Fetch a recent blockhash from the cluster, return with context\n * @return {Promise>}\n *\n * @deprecated Deprecated since RPC v1.9.0. Please use {@link getLatestBlockhash} instead.\n */\n async getRecentBlockhashAndContext(commitment) {\n const {\n context,\n value: {\n blockhash\n }\n } = await this.getLatestBlockhashAndContext(commitment);\n const feeCalculator = {\n get lamportsPerSignature() {\n throw new Error('The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is ' + 'no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee ' + 'for a given message.');\n },\n toJSON() {\n return {};\n }\n };\n return {\n context,\n value: {\n blockhash,\n feeCalculator\n }\n };\n }\n\n /**\n * Fetch recent performance samples\n * @return {Promise>}\n */\n async getRecentPerformanceSamples(limit) {\n const unsafeRes = await this._rpcRequest('getRecentPerformanceSamples', limit ? [limit] : []);\n const res = create(unsafeRes, GetRecentPerformanceSamplesRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get recent performance samples');\n }\n return res.result;\n }\n\n /**\n * Fetch the fee calculator for a recent blockhash from the cluster, return with context\n *\n * @deprecated Deprecated since RPC v1.9.0. Please use {@link getFeeForMessage} instead.\n */\n async getFeeCalculatorForBlockhash(blockhash, commitment) {\n const args = this._buildArgs([blockhash], commitment);\n const unsafeRes = await this._rpcRequest('getFeeCalculatorForBlockhash', args);\n const res = create(unsafeRes, GetFeeCalculatorRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get fee calculator');\n }\n const {\n context,\n value\n } = res.result;\n return {\n context,\n value: value !== null ? value.feeCalculator : null\n };\n }\n\n /**\n * Fetch the fee for a message from the cluster, return with context\n */\n async getFeeForMessage(message, commitment) {\n const wireMessage = toBuffer(message.serialize()).toString('base64');\n const args = this._buildArgs([wireMessage], commitment);\n const unsafeRes = await this._rpcRequest('getFeeForMessage', args);\n const res = create(unsafeRes, jsonRpcResultAndContext(nullable(number())));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get fee for message');\n }\n if (res.result === null) {\n throw new Error('invalid blockhash');\n }\n return res.result;\n }\n\n /**\n * Fetch a list of prioritization fees from recent blocks.\n */\n async getRecentPrioritizationFees(config) {\n const accounts = config?.lockedWritableAccounts?.map(key => key.toBase58());\n const args = accounts?.length ? [accounts] : [];\n const unsafeRes = await this._rpcRequest('getRecentPrioritizationFees', args);\n const res = create(unsafeRes, GetRecentPrioritizationFeesRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get recent prioritization fees');\n }\n return res.result;\n }\n /**\n * Fetch a recent blockhash from the cluster\n * @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}\n *\n * @deprecated Deprecated since RPC v1.8.0. Please use {@link getLatestBlockhash} instead.\n */\n async getRecentBlockhash(commitment) {\n try {\n const res = await this.getRecentBlockhashAndContext(commitment);\n return res.value;\n } catch (e) {\n throw new Error('failed to get recent blockhash: ' + e);\n }\n }\n\n /**\n * Fetch the latest blockhash from the cluster\n * @return {Promise}\n */\n async getLatestBlockhash(commitmentOrConfig) {\n try {\n const res = await this.getLatestBlockhashAndContext(commitmentOrConfig);\n return res.value;\n } catch (e) {\n throw new Error('failed to get recent blockhash: ' + e);\n }\n }\n\n /**\n * Fetch the latest blockhash from the cluster\n * @return {Promise}\n */\n async getLatestBlockhashAndContext(commitmentOrConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([], commitment, undefined /* encoding */, config);\n const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);\n const res = create(unsafeRes, GetLatestBlockhashRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get latest blockhash');\n }\n return res.result;\n }\n\n /**\n * Returns whether a blockhash is still valid or not\n */\n async isBlockhashValid(blockhash, rawConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(rawConfig);\n const args = this._buildArgs([blockhash], commitment, undefined /* encoding */, config);\n const unsafeRes = await this._rpcRequest('isBlockhashValid', args);\n const res = create(unsafeRes, IsBlockhashValidRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to determine if the blockhash `' + blockhash + '`is valid');\n }\n return res.result;\n }\n\n /**\n * Fetch the node version\n */\n async getVersion() {\n const unsafeRes = await this._rpcRequest('getVersion', []);\n const res = create(unsafeRes, jsonRpcResult(VersionResult));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get version');\n }\n return res.result;\n }\n\n /**\n * Fetch the genesis hash\n */\n async getGenesisHash() {\n const unsafeRes = await this._rpcRequest('getGenesisHash', []);\n const res = create(unsafeRes, jsonRpcResult(string()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get genesis hash');\n }\n return res.result;\n }\n\n /**\n * Fetch a processed block from the cluster.\n *\n * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by\n * setting the `maxSupportedTransactionVersion` property.\n */\n\n /**\n * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by\n * setting the `maxSupportedTransactionVersion` property.\n */\n // eslint-disable-next-line no-dupe-class-members\n\n /**\n * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by\n * setting the `maxSupportedTransactionVersion` property.\n */\n // eslint-disable-next-line no-dupe-class-members\n\n /**\n * Fetch a processed block from the cluster.\n */\n // eslint-disable-next-line no-dupe-class-members\n\n // eslint-disable-next-line no-dupe-class-members\n\n // eslint-disable-next-line no-dupe-class-members\n\n /**\n * Fetch a processed block from the cluster.\n */\n // eslint-disable-next-line no-dupe-class-members\n async getBlock(slot, rawConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(rawConfig);\n const args = this._buildArgsAtLeastConfirmed([slot], commitment, undefined /* encoding */, config);\n const unsafeRes = await this._rpcRequest('getBlock', args);\n try {\n switch (config?.transactionDetails) {\n case 'accounts':\n {\n const res = create(unsafeRes, GetAccountsModeBlockRpcResult);\n if ('error' in res) {\n throw res.error;\n }\n return res.result;\n }\n case 'none':\n {\n const res = create(unsafeRes, GetNoneModeBlockRpcResult);\n if ('error' in res) {\n throw res.error;\n }\n return res.result;\n }\n default:\n {\n const res = create(unsafeRes, GetBlockRpcResult);\n if ('error' in res) {\n throw res.error;\n }\n const {\n result\n } = res;\n return result ? {\n ...result,\n transactions: result.transactions.map(({\n transaction,\n meta,\n version\n }) => ({\n meta,\n transaction: {\n ...transaction,\n message: versionedMessageFromResponse(version, transaction.message)\n },\n version\n }))\n } : null;\n }\n }\n } catch (e) {\n throw new SolanaJSONRPCError(e, 'failed to get confirmed block');\n }\n }\n\n /**\n * Fetch parsed transaction details for a confirmed or finalized block\n */\n\n // eslint-disable-next-line no-dupe-class-members\n\n // eslint-disable-next-line no-dupe-class-members\n\n // eslint-disable-next-line no-dupe-class-members\n async getParsedBlock(slot, rawConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(rawConfig);\n const args = this._buildArgsAtLeastConfirmed([slot], commitment, 'jsonParsed', config);\n const unsafeRes = await this._rpcRequest('getBlock', args);\n try {\n switch (config?.transactionDetails) {\n case 'accounts':\n {\n const res = create(unsafeRes, GetParsedAccountsModeBlockRpcResult);\n if ('error' in res) {\n throw res.error;\n }\n return res.result;\n }\n case 'none':\n {\n const res = create(unsafeRes, GetParsedNoneModeBlockRpcResult);\n if ('error' in res) {\n throw res.error;\n }\n return res.result;\n }\n default:\n {\n const res = create(unsafeRes, GetParsedBlockRpcResult);\n if ('error' in res) {\n throw res.error;\n }\n return res.result;\n }\n }\n } catch (e) {\n throw new SolanaJSONRPCError(e, 'failed to get block');\n }\n }\n /*\n * Returns recent block production information from the current or previous epoch\n */\n async getBlockProduction(configOrCommitment) {\n let extra;\n let commitment;\n if (typeof configOrCommitment === 'string') {\n commitment = configOrCommitment;\n } else if (configOrCommitment) {\n const {\n commitment: c,\n ...rest\n } = configOrCommitment;\n commitment = c;\n extra = rest;\n }\n const args = this._buildArgs([], commitment, 'base64', extra);\n const unsafeRes = await this._rpcRequest('getBlockProduction', args);\n const res = create(unsafeRes, BlockProductionResponseStruct);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get block production information');\n }\n return res.result;\n }\n\n /**\n * Fetch a confirmed or finalized transaction from the cluster.\n *\n * @deprecated Instead, call `getTransaction` using a\n * `GetVersionedTransactionConfig` by setting the\n * `maxSupportedTransactionVersion` property.\n */\n\n /**\n * Fetch a confirmed or finalized transaction from the cluster.\n */\n // eslint-disable-next-line no-dupe-class-members\n\n /**\n * Fetch a confirmed or finalized transaction from the cluster.\n */\n // eslint-disable-next-line no-dupe-class-members\n async getTransaction(signature, rawConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(rawConfig);\n const args = this._buildArgsAtLeastConfirmed([signature], commitment, undefined /* encoding */, config);\n const unsafeRes = await this._rpcRequest('getTransaction', args);\n const res = create(unsafeRes, GetTransactionRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get transaction');\n }\n const result = res.result;\n if (!result) return result;\n return {\n ...result,\n transaction: {\n ...result.transaction,\n message: versionedMessageFromResponse(result.version, result.transaction.message)\n }\n };\n }\n\n /**\n * Fetch parsed transaction details for a confirmed or finalized transaction\n */\n async getParsedTransaction(signature, commitmentOrConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed', config);\n const unsafeRes = await this._rpcRequest('getTransaction', args);\n const res = create(unsafeRes, GetParsedTransactionRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get transaction');\n }\n return res.result;\n }\n\n /**\n * Fetch parsed transaction details for a batch of confirmed transactions\n */\n async getParsedTransactions(signatures, commitmentOrConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const batch = signatures.map(signature => {\n const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed', config);\n return {\n methodName: 'getTransaction',\n args\n };\n });\n const unsafeRes = await this._rpcBatchRequest(batch);\n const res = unsafeRes.map(unsafeRes => {\n const res = create(unsafeRes, GetParsedTransactionRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get transactions');\n }\n return res.result;\n });\n return res;\n }\n\n /**\n * Fetch transaction details for a batch of confirmed transactions.\n * Similar to {@link getParsedTransactions} but returns a {@link TransactionResponse}.\n *\n * @deprecated Instead, call `getTransactions` using a\n * `GetVersionedTransactionConfig` by setting the\n * `maxSupportedTransactionVersion` property.\n */\n\n /**\n * Fetch transaction details for a batch of confirmed transactions.\n * Similar to {@link getParsedTransactions} but returns a {@link\n * VersionedTransactionResponse}.\n */\n // eslint-disable-next-line no-dupe-class-members\n\n /**\n * Fetch transaction details for a batch of confirmed transactions.\n * Similar to {@link getParsedTransactions} but returns a {@link\n * VersionedTransactionResponse}.\n */\n // eslint-disable-next-line no-dupe-class-members\n async getTransactions(signatures, commitmentOrConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const batch = signatures.map(signature => {\n const args = this._buildArgsAtLeastConfirmed([signature], commitment, undefined /* encoding */, config);\n return {\n methodName: 'getTransaction',\n args\n };\n });\n const unsafeRes = await this._rpcBatchRequest(batch);\n const res = unsafeRes.map(unsafeRes => {\n const res = create(unsafeRes, GetTransactionRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get transactions');\n }\n const result = res.result;\n if (!result) return result;\n return {\n ...result,\n transaction: {\n ...result.transaction,\n message: versionedMessageFromResponse(result.version, result.transaction.message)\n }\n };\n });\n return res;\n }\n\n /**\n * Fetch a list of Transactions and transaction statuses from the cluster\n * for a confirmed block.\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getBlock} instead.\n */\n async getConfirmedBlock(slot, commitment) {\n const args = this._buildArgsAtLeastConfirmed([slot], commitment);\n const unsafeRes = await this._rpcRequest('getBlock', args);\n const res = create(unsafeRes, GetConfirmedBlockRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');\n }\n const result = res.result;\n if (!result) {\n throw new Error('Confirmed block ' + slot + ' not found');\n }\n const block = {\n ...result,\n transactions: result.transactions.map(({\n transaction,\n meta\n }) => {\n const message = new Message(transaction.message);\n return {\n meta,\n transaction: {\n ...transaction,\n message\n }\n };\n })\n };\n return {\n ...block,\n transactions: block.transactions.map(({\n transaction,\n meta\n }) => {\n return {\n meta,\n transaction: Transaction.populate(transaction.message, transaction.signatures)\n };\n })\n };\n }\n\n /**\n * Fetch confirmed blocks between two slots\n */\n async getBlocks(startSlot, endSlot, commitment) {\n const args = this._buildArgsAtLeastConfirmed(endSlot !== undefined ? [startSlot, endSlot] : [startSlot], commitment);\n const unsafeRes = await this._rpcRequest('getBlocks', args);\n const res = create(unsafeRes, jsonRpcResult(array(number())));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get blocks');\n }\n return res.result;\n }\n\n /**\n * Fetch a list of Signatures from the cluster for a block, excluding rewards\n */\n async getBlockSignatures(slot, commitment) {\n const args = this._buildArgsAtLeastConfirmed([slot], commitment, undefined, {\n transactionDetails: 'signatures',\n rewards: false\n });\n const unsafeRes = await this._rpcRequest('getBlock', args);\n const res = create(unsafeRes, GetBlockSignaturesRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get block');\n }\n const result = res.result;\n if (!result) {\n throw new Error('Block ' + slot + ' not found');\n }\n return result;\n }\n\n /**\n * Fetch a list of Signatures from the cluster for a confirmed block, excluding rewards\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getBlockSignatures} instead.\n */\n async getConfirmedBlockSignatures(slot, commitment) {\n const args = this._buildArgsAtLeastConfirmed([slot], commitment, undefined, {\n transactionDetails: 'signatures',\n rewards: false\n });\n const unsafeRes = await this._rpcRequest('getBlock', args);\n const res = create(unsafeRes, GetBlockSignaturesRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');\n }\n const result = res.result;\n if (!result) {\n throw new Error('Confirmed block ' + slot + ' not found');\n }\n return result;\n }\n\n /**\n * Fetch a transaction details for a confirmed transaction\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getTransaction} instead.\n */\n async getConfirmedTransaction(signature, commitment) {\n const args = this._buildArgsAtLeastConfirmed([signature], commitment);\n const unsafeRes = await this._rpcRequest('getTransaction', args);\n const res = create(unsafeRes, GetTransactionRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get transaction');\n }\n const result = res.result;\n if (!result) return result;\n const message = new Message(result.transaction.message);\n const signatures = result.transaction.signatures;\n return {\n ...result,\n transaction: Transaction.populate(message, signatures)\n };\n }\n\n /**\n * Fetch parsed transaction details for a confirmed transaction\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getParsedTransaction} instead.\n */\n async getParsedConfirmedTransaction(signature, commitment) {\n const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed');\n const unsafeRes = await this._rpcRequest('getTransaction', args);\n const res = create(unsafeRes, GetParsedTransactionRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transaction');\n }\n return res.result;\n }\n\n /**\n * Fetch parsed transaction details for a batch of confirmed transactions\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getParsedTransactions} instead.\n */\n async getParsedConfirmedTransactions(signatures, commitment) {\n const batch = signatures.map(signature => {\n const args = this._buildArgsAtLeastConfirmed([signature], commitment, 'jsonParsed');\n return {\n methodName: 'getTransaction',\n args\n };\n });\n const unsafeRes = await this._rpcBatchRequest(batch);\n const res = unsafeRes.map(unsafeRes => {\n const res = create(unsafeRes, GetParsedTransactionRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get confirmed transactions');\n }\n return res.result;\n });\n return res;\n }\n\n /**\n * Fetch a list of all the confirmed signatures for transactions involving an address\n * within a specified slot range. Max range allowed is 10,000 slots.\n *\n * @deprecated Deprecated since RPC v1.3. Please use {@link getConfirmedSignaturesForAddress2} instead.\n *\n * @param address queried address\n * @param startSlot start slot, inclusive\n * @param endSlot end slot, inclusive\n */\n async getConfirmedSignaturesForAddress(address, startSlot, endSlot) {\n let options = {};\n let firstAvailableBlock = await this.getFirstAvailableBlock();\n while (!('until' in options)) {\n startSlot--;\n if (startSlot <= 0 || startSlot < firstAvailableBlock) {\n break;\n }\n try {\n const block = await this.getConfirmedBlockSignatures(startSlot, 'finalized');\n if (block.signatures.length > 0) {\n options.until = block.signatures[block.signatures.length - 1].toString();\n }\n } catch (err) {\n if (err instanceof Error && err.message.includes('skipped')) {\n continue;\n } else {\n throw err;\n }\n }\n }\n let highestConfirmedRoot = await this.getSlot('finalized');\n while (!('before' in options)) {\n endSlot++;\n if (endSlot > highestConfirmedRoot) {\n break;\n }\n try {\n const block = await this.getConfirmedBlockSignatures(endSlot);\n if (block.signatures.length > 0) {\n options.before = block.signatures[block.signatures.length - 1].toString();\n }\n } catch (err) {\n if (err instanceof Error && err.message.includes('skipped')) {\n continue;\n } else {\n throw err;\n }\n }\n }\n const confirmedSignatureInfo = await this.getConfirmedSignaturesForAddress2(address, options);\n return confirmedSignatureInfo.map(info => info.signature);\n }\n\n /**\n * Returns confirmed signatures for transactions involving an\n * address backwards in time from the provided signature or most recent confirmed block\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getSignaturesForAddress} instead.\n */\n async getConfirmedSignaturesForAddress2(address, options, commitment) {\n const args = this._buildArgsAtLeastConfirmed([address.toBase58()], commitment, undefined, options);\n const unsafeRes = await this._rpcRequest('getConfirmedSignaturesForAddress2', args);\n const res = create(unsafeRes, GetConfirmedSignaturesForAddress2RpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get confirmed signatures for address');\n }\n return res.result;\n }\n\n /**\n * Returns confirmed signatures for transactions involving an\n * address backwards in time from the provided signature or most recent confirmed block\n *\n *\n * @param address queried address\n * @param options\n */\n async getSignaturesForAddress(address, options, commitment) {\n const args = this._buildArgsAtLeastConfirmed([address.toBase58()], commitment, undefined, options);\n const unsafeRes = await this._rpcRequest('getSignaturesForAddress', args);\n const res = create(unsafeRes, GetSignaturesForAddressRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get signatures for address');\n }\n return res.result;\n }\n async getAddressLookupTable(accountKey, config) {\n const {\n context,\n value: accountInfo\n } = await this.getAccountInfoAndContext(accountKey, config);\n let value = null;\n if (accountInfo !== null) {\n value = new AddressLookupTableAccount({\n key: accountKey,\n state: AddressLookupTableAccount.deserialize(accountInfo.data)\n });\n }\n return {\n context,\n value\n };\n }\n\n /**\n * Fetch the contents of a Nonce account from the cluster, return with context\n */\n async getNonceAndContext(nonceAccount, commitmentOrConfig) {\n const {\n context,\n value: accountInfo\n } = await this.getAccountInfoAndContext(nonceAccount, commitmentOrConfig);\n let value = null;\n if (accountInfo !== null) {\n value = NonceAccount.fromAccountData(accountInfo.data);\n }\n return {\n context,\n value\n };\n }\n\n /**\n * Fetch the contents of a Nonce account from the cluster\n */\n async getNonce(nonceAccount, commitmentOrConfig) {\n return await this.getNonceAndContext(nonceAccount, commitmentOrConfig).then(x => x.value).catch(e => {\n throw new Error('failed to get nonce for account ' + nonceAccount.toBase58() + ': ' + e);\n });\n }\n\n /**\n * Request an allocation of lamports to the specified address\n *\n * ```typescript\n * import { Connection, PublicKey, LAMPORTS_PER_SOL } from \"@solana/web3.js\";\n *\n * (async () => {\n * const connection = new Connection(\"https://api.testnet.solana.com\", \"confirmed\");\n * const myAddress = new PublicKey(\"2nr1bHFT86W9tGnyvmYW4vcHKsQB3sVQfnddasz4kExM\");\n * const signature = await connection.requestAirdrop(myAddress, LAMPORTS_PER_SOL);\n * await connection.confirmTransaction(signature);\n * })();\n * ```\n */\n async requestAirdrop(to, lamports) {\n const unsafeRes = await this._rpcRequest('requestAirdrop', [to.toBase58(), lamports]);\n const res = create(unsafeRes, RequestAirdropRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, `airdrop to ${to.toBase58()} failed`);\n }\n return res.result;\n }\n\n /**\n * @internal\n */\n async _blockhashWithExpiryBlockHeight(disableCache) {\n if (!disableCache) {\n // Wait for polling to finish\n while (this._pollingBlockhash) {\n await sleep(100);\n }\n const timeSinceFetch = Date.now() - this._blockhashInfo.lastFetch;\n const expired = timeSinceFetch >= BLOCKHASH_CACHE_TIMEOUT_MS;\n if (this._blockhashInfo.latestBlockhash !== null && !expired) {\n return this._blockhashInfo.latestBlockhash;\n }\n }\n return await this._pollNewBlockhash();\n }\n\n /**\n * @internal\n */\n async _pollNewBlockhash() {\n this._pollingBlockhash = true;\n try {\n const startTime = Date.now();\n const cachedLatestBlockhash = this._blockhashInfo.latestBlockhash;\n const cachedBlockhash = cachedLatestBlockhash ? cachedLatestBlockhash.blockhash : null;\n for (let i = 0; i < 50; i++) {\n const latestBlockhash = await this.getLatestBlockhash('finalized');\n if (cachedBlockhash !== latestBlockhash.blockhash) {\n this._blockhashInfo = {\n latestBlockhash,\n lastFetch: Date.now(),\n transactionSignatures: [],\n simulatedSignatures: []\n };\n return latestBlockhash;\n }\n\n // Sleep for approximately half a slot\n await sleep(MS_PER_SLOT / 2);\n }\n throw new Error(`Unable to obtain a new blockhash after ${Date.now() - startTime}ms`);\n } finally {\n this._pollingBlockhash = false;\n }\n }\n\n /**\n * get the stake minimum delegation\n */\n async getStakeMinimumDelegation(config) {\n const {\n commitment,\n config: configArg\n } = extractCommitmentFromConfig(config);\n const args = this._buildArgs([], commitment, 'base64', configArg);\n const unsafeRes = await this._rpcRequest('getStakeMinimumDelegation', args);\n const res = create(unsafeRes, jsonRpcResultAndContext(number()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, `failed to get stake minimum delegation`);\n }\n return res.result;\n }\n\n /**\n * Simulate a transaction\n *\n * @deprecated Instead, call {@link simulateTransaction} with {@link\n * VersionedTransaction} and {@link SimulateTransactionConfig} parameters\n */\n\n /**\n * Simulate a transaction\n */\n // eslint-disable-next-line no-dupe-class-members\n\n /**\n * Simulate a transaction\n */\n // eslint-disable-next-line no-dupe-class-members\n async simulateTransaction(transactionOrMessage, configOrSigners, includeAccounts) {\n if ('message' in transactionOrMessage) {\n const versionedTx = transactionOrMessage;\n const wireTransaction = versionedTx.serialize();\n const encodedTransaction = Buffer.from(wireTransaction).toString('base64');\n if (Array.isArray(configOrSigners) || includeAccounts !== undefined) {\n throw new Error('Invalid arguments');\n }\n const config = configOrSigners || {};\n config.encoding = 'base64';\n if (!('commitment' in config)) {\n config.commitment = this.commitment;\n }\n if (configOrSigners && typeof configOrSigners === 'object' && 'innerInstructions' in configOrSigners) {\n config.innerInstructions = configOrSigners.innerInstructions;\n }\n const args = [encodedTransaction, config];\n const unsafeRes = await this._rpcRequest('simulateTransaction', args);\n const res = create(unsafeRes, SimulatedTransactionResponseStruct);\n if ('error' in res) {\n throw new Error('failed to simulate transaction: ' + res.error.message);\n }\n return res.result;\n }\n let transaction;\n if (transactionOrMessage instanceof Transaction) {\n let originalTx = transactionOrMessage;\n transaction = new Transaction();\n transaction.feePayer = originalTx.feePayer;\n transaction.instructions = transactionOrMessage.instructions;\n transaction.nonceInfo = originalTx.nonceInfo;\n transaction.signatures = originalTx.signatures;\n } else {\n transaction = Transaction.populate(transactionOrMessage);\n // HACK: this function relies on mutating the populated transaction\n transaction._message = transaction._json = undefined;\n }\n if (configOrSigners !== undefined && !Array.isArray(configOrSigners)) {\n throw new Error('Invalid arguments');\n }\n const signers = configOrSigners;\n if (transaction.nonceInfo && signers) {\n transaction.sign(...signers);\n } else {\n let disableCache = this._disableBlockhashCaching;\n for (;;) {\n const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);\n transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;\n transaction.recentBlockhash = latestBlockhash.blockhash;\n if (!signers) break;\n transaction.sign(...signers);\n if (!transaction.signature) {\n throw new Error('!signature'); // should never happen\n }\n const signature = transaction.signature.toString('base64');\n if (!this._blockhashInfo.simulatedSignatures.includes(signature) && !this._blockhashInfo.transactionSignatures.includes(signature)) {\n // The signature of this transaction has not been seen before with the\n // current recentBlockhash, all done. Let's break\n this._blockhashInfo.simulatedSignatures.push(signature);\n break;\n } else {\n // This transaction would be treated as duplicate (its derived signature\n // matched to one of already recorded signatures).\n // So, we must fetch a new blockhash for a different signature by disabling\n // our cache not to wait for the cache expiration (BLOCKHASH_CACHE_TIMEOUT_MS).\n disableCache = true;\n }\n }\n }\n const message = transaction._compile();\n const signData = message.serialize();\n const wireTransaction = transaction._serialize(signData);\n const encodedTransaction = wireTransaction.toString('base64');\n const config = {\n encoding: 'base64',\n commitment: this.commitment\n };\n if (includeAccounts) {\n const addresses = (Array.isArray(includeAccounts) ? includeAccounts : message.nonProgramIds()).map(key => key.toBase58());\n config['accounts'] = {\n encoding: 'base64',\n addresses\n };\n }\n if (signers) {\n config.sigVerify = true;\n }\n if (configOrSigners && typeof configOrSigners === 'object' && 'innerInstructions' in configOrSigners) {\n config.innerInstructions = configOrSigners.innerInstructions;\n }\n const args = [encodedTransaction, config];\n const unsafeRes = await this._rpcRequest('simulateTransaction', args);\n const res = create(unsafeRes, SimulatedTransactionResponseStruct);\n if ('error' in res) {\n let logs;\n if ('data' in res.error) {\n logs = res.error.data.logs;\n if (logs && Array.isArray(logs)) {\n const traceIndent = '\\n ';\n const logTrace = traceIndent + logs.join(traceIndent);\n console.error(res.error.message, logTrace);\n }\n }\n throw new SendTransactionError({\n action: 'simulate',\n signature: '',\n transactionMessage: res.error.message,\n logs: logs\n });\n }\n return res.result;\n }\n\n /**\n * Sign and send a transaction\n *\n * @deprecated Instead, call {@link sendTransaction} with a {@link\n * VersionedTransaction}\n */\n\n /**\n * Send a signed transaction\n */\n // eslint-disable-next-line no-dupe-class-members\n\n /**\n * Sign and send a transaction\n */\n // eslint-disable-next-line no-dupe-class-members\n async sendTransaction(transaction, signersOrOptions, options) {\n if ('version' in transaction) {\n if (signersOrOptions && Array.isArray(signersOrOptions)) {\n throw new Error('Invalid arguments');\n }\n const wireTransaction = transaction.serialize();\n return await this.sendRawTransaction(wireTransaction, signersOrOptions);\n }\n if (signersOrOptions === undefined || !Array.isArray(signersOrOptions)) {\n throw new Error('Invalid arguments');\n }\n const signers = signersOrOptions;\n if (transaction.nonceInfo) {\n transaction.sign(...signers);\n } else {\n let disableCache = this._disableBlockhashCaching;\n for (;;) {\n const latestBlockhash = await this._blockhashWithExpiryBlockHeight(disableCache);\n transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;\n transaction.recentBlockhash = latestBlockhash.blockhash;\n transaction.sign(...signers);\n if (!transaction.signature) {\n throw new Error('!signature'); // should never happen\n }\n const signature = transaction.signature.toString('base64');\n if (!this._blockhashInfo.transactionSignatures.includes(signature)) {\n // The signature of this transaction has not been seen before with the\n // current recentBlockhash, all done. Let's break\n this._blockhashInfo.transactionSignatures.push(signature);\n break;\n } else {\n // This transaction would be treated as duplicate (its derived signature\n // matched to one of already recorded signatures).\n // So, we must fetch a new blockhash for a different signature by disabling\n // our cache not to wait for the cache expiration (BLOCKHASH_CACHE_TIMEOUT_MS).\n disableCache = true;\n }\n }\n }\n const wireTransaction = transaction.serialize();\n return await this.sendRawTransaction(wireTransaction, options);\n }\n\n /**\n * Send a transaction that has already been signed and serialized into the\n * wire format\n */\n async sendRawTransaction(rawTransaction, options) {\n const encodedTransaction = toBuffer(rawTransaction).toString('base64');\n const result = await this.sendEncodedTransaction(encodedTransaction, options);\n return result;\n }\n\n /**\n * Send a transaction that has already been signed, serialized into the\n * wire format, and encoded as a base64 string\n */\n async sendEncodedTransaction(encodedTransaction, options) {\n const config = {\n encoding: 'base64'\n };\n const skipPreflight = options && options.skipPreflight;\n const preflightCommitment = skipPreflight === true ? 'processed' // FIXME Remove when https://github.com/anza-xyz/agave/pull/483 is deployed.\n : options && options.preflightCommitment || this.commitment;\n if (options && options.maxRetries != null) {\n config.maxRetries = options.maxRetries;\n }\n if (options && options.minContextSlot != null) {\n config.minContextSlot = options.minContextSlot;\n }\n if (skipPreflight) {\n config.skipPreflight = skipPreflight;\n }\n if (preflightCommitment) {\n config.preflightCommitment = preflightCommitment;\n }\n const args = [encodedTransaction, config];\n const unsafeRes = await this._rpcRequest('sendTransaction', args);\n const res = create(unsafeRes, SendTransactionRpcResult);\n if ('error' in res) {\n let logs = undefined;\n if ('data' in res.error) {\n logs = res.error.data.logs;\n }\n throw new SendTransactionError({\n action: skipPreflight ? 'send' : 'simulate',\n signature: '',\n transactionMessage: res.error.message,\n logs: logs\n });\n }\n return res.result;\n }\n\n /**\n * @internal\n */\n _wsOnOpen() {\n this._rpcWebSocketConnected = true;\n this._rpcWebSocketHeartbeat = setInterval(() => {\n // Ping server every 5s to prevent idle timeouts\n (async () => {\n try {\n await this._rpcWebSocket.notify('ping');\n // eslint-disable-next-line no-empty\n } catch {}\n })();\n }, 5000);\n this._updateSubscriptions();\n }\n\n /**\n * @internal\n */\n _wsOnError(err) {\n this._rpcWebSocketConnected = false;\n console.error('ws error:', err.message);\n }\n\n /**\n * @internal\n */\n _wsOnClose(code) {\n this._rpcWebSocketConnected = false;\n this._rpcWebSocketGeneration = (this._rpcWebSocketGeneration + 1) % Number.MAX_SAFE_INTEGER;\n if (this._rpcWebSocketIdleTimeout) {\n clearTimeout(this._rpcWebSocketIdleTimeout);\n this._rpcWebSocketIdleTimeout = null;\n }\n if (this._rpcWebSocketHeartbeat) {\n clearInterval(this._rpcWebSocketHeartbeat);\n this._rpcWebSocketHeartbeat = null;\n }\n if (code === 1000) {\n // explicit close, check if any subscriptions have been made since close\n this._updateSubscriptions();\n return;\n }\n\n // implicit close, prepare subscriptions for auto-reconnect\n this._subscriptionCallbacksByServerSubscriptionId = {};\n Object.entries(this._subscriptionsByHash).forEach(([hash, subscription]) => {\n this._setSubscription(hash, {\n ...subscription,\n state: 'pending'\n });\n });\n }\n\n /**\n * @internal\n */\n _setSubscription(hash, nextSubscription) {\n const prevState = this._subscriptionsByHash[hash]?.state;\n this._subscriptionsByHash[hash] = nextSubscription;\n if (prevState !== nextSubscription.state) {\n const stateChangeCallbacks = this._subscriptionStateChangeCallbacksByHash[hash];\n if (stateChangeCallbacks) {\n stateChangeCallbacks.forEach(cb => {\n try {\n cb(nextSubscription.state);\n // eslint-disable-next-line no-empty\n } catch {}\n });\n }\n }\n }\n\n /**\n * @internal\n */\n _onSubscriptionStateChange(clientSubscriptionId, callback) {\n const hash = this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];\n if (hash == null) {\n return () => {};\n }\n const stateChangeCallbacks = this._subscriptionStateChangeCallbacksByHash[hash] ||= new Set();\n stateChangeCallbacks.add(callback);\n return () => {\n stateChangeCallbacks.delete(callback);\n if (stateChangeCallbacks.size === 0) {\n delete this._subscriptionStateChangeCallbacksByHash[hash];\n }\n };\n }\n\n /**\n * @internal\n */\n async _updateSubscriptions() {\n if (Object.keys(this._subscriptionsByHash).length === 0) {\n if (this._rpcWebSocketConnected) {\n this._rpcWebSocketConnected = false;\n this._rpcWebSocketIdleTimeout = setTimeout(() => {\n this._rpcWebSocketIdleTimeout = null;\n try {\n this._rpcWebSocket.close();\n } catch (err) {\n // swallow error if socket has already been closed.\n if (err instanceof Error) {\n console.log(`Error when closing socket connection: ${err.message}`);\n }\n }\n }, 500);\n }\n return;\n }\n if (this._rpcWebSocketIdleTimeout !== null) {\n clearTimeout(this._rpcWebSocketIdleTimeout);\n this._rpcWebSocketIdleTimeout = null;\n this._rpcWebSocketConnected = true;\n }\n if (!this._rpcWebSocketConnected) {\n this._rpcWebSocket.connect();\n return;\n }\n const activeWebSocketGeneration = this._rpcWebSocketGeneration;\n const isCurrentConnectionStillActive = () => {\n return activeWebSocketGeneration === this._rpcWebSocketGeneration;\n };\n await Promise.all(\n // Don't be tempted to change this to `Object.entries`. We call\n // `_updateSubscriptions` recursively when processing the state,\n // so it's important that we look up the *current* version of\n // each subscription, every time we process a hash.\n Object.keys(this._subscriptionsByHash).map(async hash => {\n const subscription = this._subscriptionsByHash[hash];\n if (subscription === undefined) {\n // This entry has since been deleted. Skip.\n return;\n }\n switch (subscription.state) {\n case 'pending':\n case 'unsubscribed':\n if (subscription.callbacks.size === 0) {\n /**\n * You can end up here when:\n *\n * - a subscription has recently unsubscribed\n * without having new callbacks added to it\n * while the unsubscribe was in flight, or\n * - when a pending subscription has its\n * listeners removed before a request was\n * sent to the server.\n *\n * Being that nobody is interested in this\n * subscription any longer, delete it.\n */\n delete this._subscriptionsByHash[hash];\n if (subscription.state === 'unsubscribed') {\n delete this._subscriptionCallbacksByServerSubscriptionId[subscription.serverSubscriptionId];\n }\n await this._updateSubscriptions();\n return;\n }\n await (async () => {\n const {\n args,\n method\n } = subscription;\n try {\n this._setSubscription(hash, {\n ...subscription,\n state: 'subscribing'\n });\n const serverSubscriptionId = await this._rpcWebSocket.call(method, args);\n this._setSubscription(hash, {\n ...subscription,\n serverSubscriptionId,\n state: 'subscribed'\n });\n this._subscriptionCallbacksByServerSubscriptionId[serverSubscriptionId] = subscription.callbacks;\n await this._updateSubscriptions();\n } catch (e) {\n console.error(`Received ${e instanceof Error ? '' : 'JSON-RPC '}error calling \\`${method}\\``, {\n args,\n error: e\n });\n if (!isCurrentConnectionStillActive()) {\n return;\n }\n // TODO: Maybe add an 'errored' state or a retry limit?\n this._setSubscription(hash, {\n ...subscription,\n state: 'pending'\n });\n await this._updateSubscriptions();\n }\n })();\n break;\n case 'subscribed':\n if (subscription.callbacks.size === 0) {\n // By the time we successfully set up a subscription\n // with the server, the client stopped caring about it.\n // Tear it down now.\n await (async () => {\n const {\n serverSubscriptionId,\n unsubscribeMethod\n } = subscription;\n if (this._subscriptionsAutoDisposedByRpc.has(serverSubscriptionId)) {\n /**\n * Special case.\n * If we're dealing with a subscription that has been auto-\n * disposed by the RPC, then we can skip the RPC call to\n * tear down the subscription here.\n *\n * NOTE: There is a proposal to eliminate this special case, here:\n * https://github.com/solana-labs/solana/issues/18892\n */\n this._subscriptionsAutoDisposedByRpc.delete(serverSubscriptionId);\n } else {\n this._setSubscription(hash, {\n ...subscription,\n state: 'unsubscribing'\n });\n this._setSubscription(hash, {\n ...subscription,\n state: 'unsubscribing'\n });\n try {\n await this._rpcWebSocket.call(unsubscribeMethod, [serverSubscriptionId]);\n } catch (e) {\n if (e instanceof Error) {\n console.error(`${unsubscribeMethod} error:`, e.message);\n }\n if (!isCurrentConnectionStillActive()) {\n return;\n }\n // TODO: Maybe add an 'errored' state or a retry limit?\n this._setSubscription(hash, {\n ...subscription,\n state: 'subscribed'\n });\n await this._updateSubscriptions();\n return;\n }\n }\n this._setSubscription(hash, {\n ...subscription,\n state: 'unsubscribed'\n });\n await this._updateSubscriptions();\n })();\n }\n break;\n }\n }));\n }\n\n /**\n * @internal\n */\n _handleServerNotification(serverSubscriptionId, callbackArgs) {\n const callbacks = this._subscriptionCallbacksByServerSubscriptionId[serverSubscriptionId];\n if (callbacks === undefined) {\n return;\n }\n callbacks.forEach(cb => {\n try {\n cb(\n // I failed to find a way to convince TypeScript that `cb` is of type\n // `TCallback` which is certainly compatible with `Parameters`.\n // See https://github.com/microsoft/TypeScript/issues/47615\n // @ts-ignore\n ...callbackArgs);\n } catch (e) {\n console.error(e);\n }\n });\n }\n\n /**\n * @internal\n */\n _wsOnAccountNotification(notification) {\n const {\n result,\n subscription\n } = create(notification, AccountNotificationResult);\n this._handleServerNotification(subscription, [result.value, result.context]);\n }\n\n /**\n * @internal\n */\n _makeSubscription(subscriptionConfig,\n /**\n * When preparing `args` for a call to `_makeSubscription`, be sure\n * to carefully apply a default `commitment` property, if necessary.\n *\n * - If the user supplied a `commitment` use that.\n * - Otherwise, if the `Connection::commitment` is set, use that.\n * - Otherwise, set it to the RPC server default: `finalized`.\n *\n * This is extremely important to ensure that these two fundamentally\n * identical subscriptions produce the same identifying hash:\n *\n * - A subscription made without specifying a commitment.\n * - A subscription made where the commitment specified is the same\n * as the default applied to the subscription above.\n *\n * Example; these two subscriptions must produce the same hash:\n *\n * - An `accountSubscribe` subscription for `'PUBKEY'`\n * - An `accountSubscribe` subscription for `'PUBKEY'` with commitment\n * `'finalized'`.\n *\n * See the 'making a subscription with defaulted params omitted' test\n * in `connection-subscriptions.ts` for more.\n */\n args) {\n const clientSubscriptionId = this._nextClientSubscriptionId++;\n const hash = fastStableStringify([subscriptionConfig.method, args]);\n const existingSubscription = this._subscriptionsByHash[hash];\n if (existingSubscription === undefined) {\n this._subscriptionsByHash[hash] = {\n ...subscriptionConfig,\n args,\n callbacks: new Set([subscriptionConfig.callback]),\n state: 'pending'\n };\n } else {\n existingSubscription.callbacks.add(subscriptionConfig.callback);\n }\n this._subscriptionHashByClientSubscriptionId[clientSubscriptionId] = hash;\n this._subscriptionDisposeFunctionsByClientSubscriptionId[clientSubscriptionId] = async () => {\n delete this._subscriptionDisposeFunctionsByClientSubscriptionId[clientSubscriptionId];\n delete this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];\n const subscription = this._subscriptionsByHash[hash];\n assert(subscription !== undefined, `Could not find a \\`Subscription\\` when tearing down client subscription #${clientSubscriptionId}`);\n subscription.callbacks.delete(subscriptionConfig.callback);\n await this._updateSubscriptions();\n };\n this._updateSubscriptions();\n return clientSubscriptionId;\n }\n\n /**\n * Register a callback to be invoked whenever the specified account changes\n *\n * @param publicKey Public key of the account to monitor\n * @param callback Function to invoke whenever the account is changed\n * @param config\n * @return subscription id\n */\n\n /** @deprecated Instead, pass in an {@link AccountSubscriptionConfig} */\n // eslint-disable-next-line no-dupe-class-members\n\n // eslint-disable-next-line no-dupe-class-members\n onAccountChange(publicKey, callback, commitmentOrConfig) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([publicKey.toBase58()], commitment || this._commitment || 'finalized',\n // Apply connection/server default.\n 'base64', config);\n return this._makeSubscription({\n callback,\n method: 'accountSubscribe',\n unsubscribeMethod: 'accountUnsubscribe'\n }, args);\n }\n\n /**\n * Deregister an account notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */\n async removeAccountChangeListener(clientSubscriptionId) {\n await this._unsubscribeClientSubscription(clientSubscriptionId, 'account change');\n }\n\n /**\n * @internal\n */\n _wsOnProgramAccountNotification(notification) {\n const {\n result,\n subscription\n } = create(notification, ProgramAccountNotificationResult);\n this._handleServerNotification(subscription, [{\n accountId: result.value.pubkey,\n accountInfo: result.value.account\n }, result.context]);\n }\n\n /**\n * Register a callback to be invoked whenever accounts owned by the\n * specified program change\n *\n * @param programId Public key of the program to monitor\n * @param callback Function to invoke whenever the account is changed\n * @param config\n * @return subscription id\n */\n\n /** @deprecated Instead, pass in a {@link ProgramAccountSubscriptionConfig} */\n // eslint-disable-next-line no-dupe-class-members\n\n // eslint-disable-next-line no-dupe-class-members\n onProgramAccountChange(programId, callback, commitmentOrConfig, maybeFilters) {\n const {\n commitment,\n config\n } = extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs([programId.toBase58()], commitment || this._commitment || 'finalized',\n // Apply connection/server default.\n 'base64' /* encoding */, config ? config : maybeFilters ? {\n filters: applyDefaultMemcmpEncodingToFilters(maybeFilters)\n } : undefined /* extra */);\n return this._makeSubscription({\n callback,\n method: 'programSubscribe',\n unsubscribeMethod: 'programUnsubscribe'\n }, args);\n }\n\n /**\n * Deregister an account notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */\n async removeProgramAccountChangeListener(clientSubscriptionId) {\n await this._unsubscribeClientSubscription(clientSubscriptionId, 'program account change');\n }\n\n /**\n * Registers a callback to be invoked whenever logs are emitted.\n */\n onLogs(filter, callback, commitment) {\n const args = this._buildArgs([typeof filter === 'object' ? {\n mentions: [filter.toString()]\n } : filter], commitment || this._commitment || 'finalized' // Apply connection/server default.\n );\n return this._makeSubscription({\n callback,\n method: 'logsSubscribe',\n unsubscribeMethod: 'logsUnsubscribe'\n }, args);\n }\n\n /**\n * Deregister a logs callback.\n *\n * @param clientSubscriptionId client subscription id to deregister.\n */\n async removeOnLogsListener(clientSubscriptionId) {\n await this._unsubscribeClientSubscription(clientSubscriptionId, 'logs');\n }\n\n /**\n * @internal\n */\n _wsOnLogsNotification(notification) {\n const {\n result,\n subscription\n } = create(notification, LogsNotificationResult);\n this._handleServerNotification(subscription, [result.value, result.context]);\n }\n\n /**\n * @internal\n */\n _wsOnSlotNotification(notification) {\n const {\n result,\n subscription\n } = create(notification, SlotNotificationResult);\n this._handleServerNotification(subscription, [result]);\n }\n\n /**\n * Register a callback to be invoked upon slot changes\n *\n * @param callback Function to invoke whenever the slot changes\n * @return subscription id\n */\n onSlotChange(callback) {\n return this._makeSubscription({\n callback,\n method: 'slotSubscribe',\n unsubscribeMethod: 'slotUnsubscribe'\n }, [] /* args */);\n }\n\n /**\n * Deregister a slot notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */\n async removeSlotChangeListener(clientSubscriptionId) {\n await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot change');\n }\n\n /**\n * @internal\n */\n _wsOnSlotUpdatesNotification(notification) {\n const {\n result,\n subscription\n } = create(notification, SlotUpdateNotificationResult);\n this._handleServerNotification(subscription, [result]);\n }\n\n /**\n * Register a callback to be invoked upon slot updates. {@link SlotUpdate}'s\n * may be useful to track live progress of a cluster.\n *\n * @param callback Function to invoke whenever the slot updates\n * @return subscription id\n */\n onSlotUpdate(callback) {\n return this._makeSubscription({\n callback,\n method: 'slotsUpdatesSubscribe',\n unsubscribeMethod: 'slotsUpdatesUnsubscribe'\n }, [] /* args */);\n }\n\n /**\n * Deregister a slot update notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */\n async removeSlotUpdateListener(clientSubscriptionId) {\n await this._unsubscribeClientSubscription(clientSubscriptionId, 'slot update');\n }\n\n /**\n * @internal\n */\n\n async _unsubscribeClientSubscription(clientSubscriptionId, subscriptionName) {\n const dispose = this._subscriptionDisposeFunctionsByClientSubscriptionId[clientSubscriptionId];\n if (dispose) {\n await dispose();\n } else {\n console.warn('Ignored unsubscribe request because an active subscription with id ' + `\\`${clientSubscriptionId}\\` for '${subscriptionName}' events ` + 'could not be found.');\n }\n }\n _buildArgs(args, override, encoding, extra) {\n const commitment = override || this._commitment;\n if (commitment || encoding || extra) {\n let options = {};\n if (encoding) {\n options.encoding = encoding;\n }\n if (commitment) {\n options.commitment = commitment;\n }\n if (extra) {\n options = Object.assign(options, extra);\n }\n args.push(options);\n }\n return args;\n }\n\n /**\n * @internal\n */\n _buildArgsAtLeastConfirmed(args, override, encoding, extra) {\n const commitment = override || this._commitment;\n if (commitment && !['confirmed', 'finalized'].includes(commitment)) {\n throw new Error('Using Connection with default commitment: `' + this._commitment + '`, but method requires at least `confirmed`');\n }\n return this._buildArgs(args, override, encoding, extra);\n }\n\n /**\n * @internal\n */\n _wsOnSignatureNotification(notification) {\n const {\n result,\n subscription\n } = create(notification, SignatureNotificationResult);\n if (result.value !== 'receivedSignature') {\n /**\n * Special case.\n * After a signature is processed, RPCs automatically dispose of the\n * subscription on the server side. We need to track which of these\n * subscriptions have been disposed in such a way, so that we know\n * whether the client is dealing with a not-yet-processed signature\n * (in which case we must tear down the server subscription) or an\n * already-processed signature (in which case the client can simply\n * clear out the subscription locally without telling the server).\n *\n * NOTE: There is a proposal to eliminate this special case, here:\n * https://github.com/solana-labs/solana/issues/18892\n */\n this._subscriptionsAutoDisposedByRpc.add(subscription);\n }\n this._handleServerNotification(subscription, result.value === 'receivedSignature' ? [{\n type: 'received'\n }, result.context] : [{\n type: 'status',\n result: result.value\n }, result.context]);\n }\n\n /**\n * Register a callback to be invoked upon signature updates\n *\n * @param signature Transaction signature string in base 58\n * @param callback Function to invoke on signature notifications\n * @param commitment Specify the commitment level signature must reach before notification\n * @return subscription id\n */\n onSignature(signature, callback, commitment) {\n const args = this._buildArgs([signature], commitment || this._commitment || 'finalized' // Apply connection/server default.\n );\n const clientSubscriptionId = this._makeSubscription({\n callback: (notification, context) => {\n if (notification.type === 'status') {\n callback(notification.result, context);\n // Signatures subscriptions are auto-removed by the RPC service\n // so no need to explicitly send an unsubscribe message.\n try {\n this.removeSignatureListener(clientSubscriptionId);\n // eslint-disable-next-line no-empty\n } catch (_err) {\n // Already removed.\n }\n }\n },\n method: 'signatureSubscribe',\n unsubscribeMethod: 'signatureUnsubscribe'\n }, args);\n return clientSubscriptionId;\n }\n\n /**\n * Register a callback to be invoked when a transaction is\n * received and/or processed.\n *\n * @param signature Transaction signature string in base 58\n * @param callback Function to invoke on signature notifications\n * @param options Enable received notifications and set the commitment\n * level that signature must reach before notification\n * @return subscription id\n */\n onSignatureWithOptions(signature, callback, options) {\n const {\n commitment,\n ...extra\n } = {\n ...options,\n commitment: options && options.commitment || this._commitment || 'finalized' // Apply connection/server default.\n };\n const args = this._buildArgs([signature], commitment, undefined /* encoding */, extra);\n const clientSubscriptionId = this._makeSubscription({\n callback: (notification, context) => {\n callback(notification, context);\n // Signatures subscriptions are auto-removed by the RPC service\n // so no need to explicitly send an unsubscribe message.\n try {\n this.removeSignatureListener(clientSubscriptionId);\n // eslint-disable-next-line no-empty\n } catch (_err) {\n // Already removed.\n }\n },\n method: 'signatureSubscribe',\n unsubscribeMethod: 'signatureUnsubscribe'\n }, args);\n return clientSubscriptionId;\n }\n\n /**\n * Deregister a signature notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */\n async removeSignatureListener(clientSubscriptionId) {\n await this._unsubscribeClientSubscription(clientSubscriptionId, 'signature result');\n }\n\n /**\n * @internal\n */\n _wsOnRootNotification(notification) {\n const {\n result,\n subscription\n } = create(notification, RootNotificationResult);\n this._handleServerNotification(subscription, [result]);\n }\n\n /**\n * Register a callback to be invoked upon root changes\n *\n * @param callback Function to invoke whenever the root changes\n * @return subscription id\n */\n onRootChange(callback) {\n return this._makeSubscription({\n callback,\n method: 'rootSubscribe',\n unsubscribeMethod: 'rootUnsubscribe'\n }, [] /* args */);\n }\n\n /**\n * Deregister a root notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */\n async removeRootChangeListener(clientSubscriptionId) {\n await this._unsubscribeClientSubscription(clientSubscriptionId, 'root change');\n }\n}\n\n/**\n * Keypair signer interface\n */\n\n/**\n * An account keypair used for signing transactions.\n */\nclass Keypair {\n /**\n * Create a new keypair instance.\n * Generate random keypair if no {@link Ed25519Keypair} is provided.\n *\n * @param {Ed25519Keypair} keypair ed25519 keypair\n */\n constructor(keypair) {\n this._keypair = void 0;\n this._keypair = keypair ?? generateKeypair();\n }\n\n /**\n * Generate a new random keypair\n *\n * @returns {Keypair} Keypair\n */\n static generate() {\n return new Keypair(generateKeypair());\n }\n\n /**\n * Create a keypair from a raw secret key byte array.\n *\n * This method should only be used to recreate a keypair from a previously\n * generated secret key. Generating keypairs from a random seed should be done\n * with the {@link Keypair.fromSeed} method.\n *\n * @throws error if the provided secret key is invalid and validation is not skipped.\n *\n * @param secretKey secret key byte array\n * @param options skip secret key validation\n *\n * @returns {Keypair} Keypair\n */\n static fromSecretKey(secretKey, options) {\n if (secretKey.byteLength !== 64) {\n throw new Error('bad secret key size');\n }\n const publicKey = secretKey.slice(32, 64);\n if (!options || !options.skipValidation) {\n const privateScalar = secretKey.slice(0, 32);\n const computedPublicKey = getPublicKey(privateScalar);\n for (let ii = 0; ii < 32; ii++) {\n if (publicKey[ii] !== computedPublicKey[ii]) {\n throw new Error('provided secretKey is invalid');\n }\n }\n }\n return new Keypair({\n publicKey,\n secretKey\n });\n }\n\n /**\n * Generate a keypair from a 32 byte seed.\n *\n * @param seed seed byte array\n *\n * @returns {Keypair} Keypair\n */\n static fromSeed(seed) {\n const publicKey = getPublicKey(seed);\n const secretKey = new Uint8Array(64);\n secretKey.set(seed);\n secretKey.set(publicKey, 32);\n return new Keypair({\n publicKey,\n secretKey\n });\n }\n\n /**\n * The public key for this keypair\n *\n * @returns {PublicKey} PublicKey\n */\n get publicKey() {\n return new PublicKey(this._keypair.publicKey);\n }\n\n /**\n * The raw secret key for this keypair\n * @returns {Uint8Array} Secret key in an array of Uint8 bytes\n */\n get secretKey() {\n return new Uint8Array(this._keypair.secretKey);\n }\n}\n\n/**\n * An enumeration of valid LookupTableInstructionType's\n */\n\n/**\n * An enumeration of valid address lookup table InstructionType's\n * @internal\n */\nconst LOOKUP_TABLE_INSTRUCTION_LAYOUTS = Object.freeze({\n CreateLookupTable: {\n index: 0,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), u64('recentSlot'), BufferLayout.u8('bumpSeed')])\n },\n FreezeLookupTable: {\n index: 1,\n layout: BufferLayout.struct([BufferLayout.u32('instruction')])\n },\n ExtendLookupTable: {\n index: 2,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), u64(), BufferLayout.seq(publicKey(), BufferLayout.offset(BufferLayout.u32(), -8), 'addresses')])\n },\n DeactivateLookupTable: {\n index: 3,\n layout: BufferLayout.struct([BufferLayout.u32('instruction')])\n },\n CloseLookupTable: {\n index: 4,\n layout: BufferLayout.struct([BufferLayout.u32('instruction')])\n }\n});\nclass AddressLookupTableInstruction {\n /**\n * @internal\n */\n constructor() {}\n static decodeInstructionType(instruction) {\n this.checkProgramId(instruction.programId);\n const instructionTypeLayout = BufferLayout.u32('instruction');\n const index = instructionTypeLayout.decode(instruction.data);\n let type;\n for (const [layoutType, layout] of Object.entries(LOOKUP_TABLE_INSTRUCTION_LAYOUTS)) {\n if (layout.index == index) {\n type = layoutType;\n break;\n }\n }\n if (!type) {\n throw new Error('Invalid Instruction. Should be a LookupTable Instruction');\n }\n return type;\n }\n static decodeCreateLookupTable(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeysLength(instruction.keys, 4);\n const {\n recentSlot\n } = decodeData$1(LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable, instruction.data);\n return {\n authority: instruction.keys[1].pubkey,\n payer: instruction.keys[2].pubkey,\n recentSlot: Number(recentSlot)\n };\n }\n static decodeExtendLookupTable(instruction) {\n this.checkProgramId(instruction.programId);\n if (instruction.keys.length < 2) {\n throw new Error(`invalid instruction; found ${instruction.keys.length} keys, expected at least 2`);\n }\n const {\n addresses\n } = decodeData$1(LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable, instruction.data);\n return {\n lookupTable: instruction.keys[0].pubkey,\n authority: instruction.keys[1].pubkey,\n payer: instruction.keys.length > 2 ? instruction.keys[2].pubkey : undefined,\n addresses: addresses.map(buffer => new PublicKey(buffer))\n };\n }\n static decodeCloseLookupTable(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeysLength(instruction.keys, 3);\n return {\n lookupTable: instruction.keys[0].pubkey,\n authority: instruction.keys[1].pubkey,\n recipient: instruction.keys[2].pubkey\n };\n }\n static decodeFreezeLookupTable(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeysLength(instruction.keys, 2);\n return {\n lookupTable: instruction.keys[0].pubkey,\n authority: instruction.keys[1].pubkey\n };\n }\n static decodeDeactivateLookupTable(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeysLength(instruction.keys, 2);\n return {\n lookupTable: instruction.keys[0].pubkey,\n authority: instruction.keys[1].pubkey\n };\n }\n\n /**\n * @internal\n */\n static checkProgramId(programId) {\n if (!programId.equals(AddressLookupTableProgram.programId)) {\n throw new Error('invalid instruction; programId is not AddressLookupTable Program');\n }\n }\n /**\n * @internal\n */\n static checkKeysLength(keys, expectedLength) {\n if (keys.length < expectedLength) {\n throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);\n }\n }\n}\nclass AddressLookupTableProgram {\n /**\n * @internal\n */\n constructor() {}\n static createLookupTable(params) {\n const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync([params.authority.toBuffer(), toBufferLE(BigInt(params.recentSlot), 8)], this.programId);\n const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable;\n const data = encodeData(type, {\n recentSlot: BigInt(params.recentSlot),\n bumpSeed: bumpSeed\n });\n const keys = [{\n pubkey: lookupTableAddress,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: params.authority,\n isSigner: true,\n isWritable: false\n }, {\n pubkey: params.payer,\n isSigner: true,\n isWritable: true\n }, {\n pubkey: SystemProgram.programId,\n isSigner: false,\n isWritable: false\n }];\n return [new TransactionInstruction({\n programId: this.programId,\n keys: keys,\n data: data\n }), lookupTableAddress];\n }\n static freezeLookupTable(params) {\n const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.FreezeLookupTable;\n const data = encodeData(type);\n const keys = [{\n pubkey: params.lookupTable,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: params.authority,\n isSigner: true,\n isWritable: false\n }];\n return new TransactionInstruction({\n programId: this.programId,\n keys: keys,\n data: data\n });\n }\n static extendLookupTable(params) {\n const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable;\n const data = encodeData(type, {\n addresses: params.addresses.map(addr => addr.toBytes())\n });\n const keys = [{\n pubkey: params.lookupTable,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: params.authority,\n isSigner: true,\n isWritable: false\n }];\n if (params.payer) {\n keys.push({\n pubkey: params.payer,\n isSigner: true,\n isWritable: true\n }, {\n pubkey: SystemProgram.programId,\n isSigner: false,\n isWritable: false\n });\n }\n return new TransactionInstruction({\n programId: this.programId,\n keys: keys,\n data: data\n });\n }\n static deactivateLookupTable(params) {\n const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.DeactivateLookupTable;\n const data = encodeData(type);\n const keys = [{\n pubkey: params.lookupTable,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: params.authority,\n isSigner: true,\n isWritable: false\n }];\n return new TransactionInstruction({\n programId: this.programId,\n keys: keys,\n data: data\n });\n }\n static closeLookupTable(params) {\n const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CloseLookupTable;\n const data = encodeData(type);\n const keys = [{\n pubkey: params.lookupTable,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: params.authority,\n isSigner: true,\n isWritable: false\n }, {\n pubkey: params.recipient,\n isSigner: false,\n isWritable: true\n }];\n return new TransactionInstruction({\n programId: this.programId,\n keys: keys,\n data: data\n });\n }\n}\nAddressLookupTableProgram.programId = new PublicKey('AddressLookupTab1e1111111111111111111111111');\n\n/**\n * Compute Budget Instruction class\n */\nclass ComputeBudgetInstruction {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Decode a compute budget instruction and retrieve the instruction type.\n */\n static decodeInstructionType(instruction) {\n this.checkProgramId(instruction.programId);\n const instructionTypeLayout = BufferLayout.u8('instruction');\n const typeIndex = instructionTypeLayout.decode(instruction.data);\n let type;\n for (const [ixType, layout] of Object.entries(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS)) {\n if (layout.index == typeIndex) {\n type = ixType;\n break;\n }\n }\n if (!type) {\n throw new Error('Instruction type incorrect; not a ComputeBudgetInstruction');\n }\n return type;\n }\n\n /**\n * Decode request units compute budget instruction and retrieve the instruction params.\n */\n static decodeRequestUnits(instruction) {\n this.checkProgramId(instruction.programId);\n const {\n units,\n additionalFee\n } = decodeData$1(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits, instruction.data);\n return {\n units,\n additionalFee\n };\n }\n\n /**\n * Decode request heap frame compute budget instruction and retrieve the instruction params.\n */\n static decodeRequestHeapFrame(instruction) {\n this.checkProgramId(instruction.programId);\n const {\n bytes\n } = decodeData$1(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame, instruction.data);\n return {\n bytes\n };\n }\n\n /**\n * Decode set compute unit limit compute budget instruction and retrieve the instruction params.\n */\n static decodeSetComputeUnitLimit(instruction) {\n this.checkProgramId(instruction.programId);\n const {\n units\n } = decodeData$1(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitLimit, instruction.data);\n return {\n units\n };\n }\n\n /**\n * Decode set compute unit price compute budget instruction and retrieve the instruction params.\n */\n static decodeSetComputeUnitPrice(instruction) {\n this.checkProgramId(instruction.programId);\n const {\n microLamports\n } = decodeData$1(COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitPrice, instruction.data);\n return {\n microLamports\n };\n }\n\n /**\n * @internal\n */\n static checkProgramId(programId) {\n if (!programId.equals(ComputeBudgetProgram.programId)) {\n throw new Error('invalid instruction; programId is not ComputeBudgetProgram');\n }\n }\n}\n\n/**\n * An enumeration of valid ComputeBudgetInstructionType's\n */\n\n/**\n * Request units instruction params\n */\n\n/**\n * Request heap frame instruction params\n */\n\n/**\n * Set compute unit limit instruction params\n */\n\n/**\n * Set compute unit price instruction params\n */\n\n/**\n * An enumeration of valid ComputeBudget InstructionType's\n * @internal\n */\nconst COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = Object.freeze({\n RequestUnits: {\n index: 0,\n layout: BufferLayout.struct([BufferLayout.u8('instruction'), BufferLayout.u32('units'), BufferLayout.u32('additionalFee')])\n },\n RequestHeapFrame: {\n index: 1,\n layout: BufferLayout.struct([BufferLayout.u8('instruction'), BufferLayout.u32('bytes')])\n },\n SetComputeUnitLimit: {\n index: 2,\n layout: BufferLayout.struct([BufferLayout.u8('instruction'), BufferLayout.u32('units')])\n },\n SetComputeUnitPrice: {\n index: 3,\n layout: BufferLayout.struct([BufferLayout.u8('instruction'), u64('microLamports')])\n }\n});\n\n/**\n * Factory class for transaction instructions to interact with the Compute Budget program\n */\nclass ComputeBudgetProgram {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Public key that identifies the Compute Budget program\n */\n\n /**\n * @deprecated Instead, call {@link setComputeUnitLimit} and/or {@link setComputeUnitPrice}\n */\n static requestUnits(params) {\n const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits;\n const data = encodeData(type, params);\n return new TransactionInstruction({\n keys: [],\n programId: this.programId,\n data\n });\n }\n static requestHeapFrame(params) {\n const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame;\n const data = encodeData(type, params);\n return new TransactionInstruction({\n keys: [],\n programId: this.programId,\n data\n });\n }\n static setComputeUnitLimit(params) {\n const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitLimit;\n const data = encodeData(type, params);\n return new TransactionInstruction({\n keys: [],\n programId: this.programId,\n data\n });\n }\n static setComputeUnitPrice(params) {\n const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitPrice;\n const data = encodeData(type, {\n microLamports: BigInt(params.microLamports)\n });\n return new TransactionInstruction({\n keys: [],\n programId: this.programId,\n data\n });\n }\n}\nComputeBudgetProgram.programId = new PublicKey('ComputeBudget111111111111111111111111111111');\n\nconst PRIVATE_KEY_BYTES$1 = 64;\nconst PUBLIC_KEY_BYTES$1 = 32;\nconst SIGNATURE_BYTES = 64;\n\n/**\n * Params for creating an ed25519 instruction using a public key\n */\n\n/**\n * Params for creating an ed25519 instruction using a private key\n */\n\nconst ED25519_INSTRUCTION_LAYOUT = BufferLayout.struct([BufferLayout.u8('numSignatures'), BufferLayout.u8('padding'), BufferLayout.u16('signatureOffset'), BufferLayout.u16('signatureInstructionIndex'), BufferLayout.u16('publicKeyOffset'), BufferLayout.u16('publicKeyInstructionIndex'), BufferLayout.u16('messageDataOffset'), BufferLayout.u16('messageDataSize'), BufferLayout.u16('messageInstructionIndex')]);\nclass Ed25519Program {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Public key that identifies the ed25519 program\n */\n\n /**\n * Create an ed25519 instruction with a public key and signature. The\n * public key must be a buffer that is 32 bytes long, and the signature\n * must be a buffer of 64 bytes.\n */\n static createInstructionWithPublicKey(params) {\n const {\n publicKey,\n message,\n signature,\n instructionIndex\n } = params;\n assert(publicKey.length === PUBLIC_KEY_BYTES$1, `Public Key must be ${PUBLIC_KEY_BYTES$1} bytes but received ${publicKey.length} bytes`);\n assert(signature.length === SIGNATURE_BYTES, `Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`);\n const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;\n const signatureOffset = publicKeyOffset + publicKey.length;\n const messageDataOffset = signatureOffset + signature.length;\n const numSignatures = 1;\n const instructionData = Buffer.alloc(messageDataOffset + message.length);\n const index = instructionIndex == null ? 0xffff // An index of `u16::MAX` makes it default to the current instruction.\n : instructionIndex;\n ED25519_INSTRUCTION_LAYOUT.encode({\n numSignatures,\n padding: 0,\n signatureOffset,\n signatureInstructionIndex: index,\n publicKeyOffset,\n publicKeyInstructionIndex: index,\n messageDataOffset,\n messageDataSize: message.length,\n messageInstructionIndex: index\n }, instructionData);\n instructionData.fill(publicKey, publicKeyOffset);\n instructionData.fill(signature, signatureOffset);\n instructionData.fill(message, messageDataOffset);\n return new TransactionInstruction({\n keys: [],\n programId: Ed25519Program.programId,\n data: instructionData\n });\n }\n\n /**\n * Create an ed25519 instruction with a private key. The private key\n * must be a buffer that is 64 bytes long.\n */\n static createInstructionWithPrivateKey(params) {\n const {\n privateKey,\n message,\n instructionIndex\n } = params;\n assert(privateKey.length === PRIVATE_KEY_BYTES$1, `Private key must be ${PRIVATE_KEY_BYTES$1} bytes but received ${privateKey.length} bytes`);\n try {\n const keypair = Keypair.fromSecretKey(privateKey);\n const publicKey = keypair.publicKey.toBytes();\n const signature = sign(message, keypair.secretKey);\n return this.createInstructionWithPublicKey({\n publicKey,\n message,\n signature,\n instructionIndex\n });\n } catch (error) {\n throw new Error(`Error creating instruction; ${error}`);\n }\n }\n}\nEd25519Program.programId = new PublicKey('Ed25519SigVerify111111111111111111111111111');\n\nconst ecdsaSign = (msgHash, privKey) => {\n const signature = secp256k1.sign(msgHash, privKey);\n return [signature.toCompactRawBytes(), signature.recovery];\n};\nsecp256k1.utils.isValidPrivateKey;\nconst publicKeyCreate = secp256k1.getPublicKey;\n\nconst PRIVATE_KEY_BYTES = 32;\nconst ETHEREUM_ADDRESS_BYTES = 20;\nconst PUBLIC_KEY_BYTES = 64;\nconst SIGNATURE_OFFSETS_SERIALIZED_SIZE = 11;\n\n/**\n * Params for creating an secp256k1 instruction using a public key\n */\n\n/**\n * Params for creating an secp256k1 instruction using an Ethereum address\n */\n\n/**\n * Params for creating an secp256k1 instruction using a private key\n */\n\nconst SECP256K1_INSTRUCTION_LAYOUT = BufferLayout.struct([BufferLayout.u8('numSignatures'), BufferLayout.u16('signatureOffset'), BufferLayout.u8('signatureInstructionIndex'), BufferLayout.u16('ethAddressOffset'), BufferLayout.u8('ethAddressInstructionIndex'), BufferLayout.u16('messageDataOffset'), BufferLayout.u16('messageDataSize'), BufferLayout.u8('messageInstructionIndex'), BufferLayout.blob(20, 'ethAddress'), BufferLayout.blob(64, 'signature'), BufferLayout.u8('recoveryId')]);\nclass Secp256k1Program {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Public key that identifies the secp256k1 program\n */\n\n /**\n * Construct an Ethereum address from a secp256k1 public key buffer.\n * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer\n */\n static publicKeyToEthAddress(publicKey) {\n assert(publicKey.length === PUBLIC_KEY_BYTES, `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`);\n try {\n return Buffer.from(keccak_256(toBuffer(publicKey))).slice(-ETHEREUM_ADDRESS_BYTES);\n } catch (error) {\n throw new Error(`Error constructing Ethereum address: ${error}`);\n }\n }\n\n /**\n * Create an secp256k1 instruction with a public key. The public key\n * must be a buffer that is 64 bytes long.\n */\n static createInstructionWithPublicKey(params) {\n const {\n publicKey,\n message,\n signature,\n recoveryId,\n instructionIndex\n } = params;\n return Secp256k1Program.createInstructionWithEthAddress({\n ethAddress: Secp256k1Program.publicKeyToEthAddress(publicKey),\n message,\n signature,\n recoveryId,\n instructionIndex\n });\n }\n\n /**\n * Create an secp256k1 instruction with an Ethereum address. The address\n * must be a hex string or a buffer that is 20 bytes long.\n */\n static createInstructionWithEthAddress(params) {\n const {\n ethAddress: rawAddress,\n message,\n signature,\n recoveryId,\n instructionIndex = 0\n } = params;\n let ethAddress;\n if (typeof rawAddress === 'string') {\n if (rawAddress.startsWith('0x')) {\n ethAddress = Buffer.from(rawAddress.substr(2), 'hex');\n } else {\n ethAddress = Buffer.from(rawAddress, 'hex');\n }\n } else {\n ethAddress = rawAddress;\n }\n assert(ethAddress.length === ETHEREUM_ADDRESS_BYTES, `Address must be ${ETHEREUM_ADDRESS_BYTES} bytes but received ${ethAddress.length} bytes`);\n const dataStart = 1 + SIGNATURE_OFFSETS_SERIALIZED_SIZE;\n const ethAddressOffset = dataStart;\n const signatureOffset = dataStart + ethAddress.length;\n const messageDataOffset = signatureOffset + signature.length + 1;\n const numSignatures = 1;\n const instructionData = Buffer.alloc(SECP256K1_INSTRUCTION_LAYOUT.span + message.length);\n SECP256K1_INSTRUCTION_LAYOUT.encode({\n numSignatures,\n signatureOffset,\n signatureInstructionIndex: instructionIndex,\n ethAddressOffset,\n ethAddressInstructionIndex: instructionIndex,\n messageDataOffset,\n messageDataSize: message.length,\n messageInstructionIndex: instructionIndex,\n signature: toBuffer(signature),\n ethAddress: toBuffer(ethAddress),\n recoveryId\n }, instructionData);\n instructionData.fill(toBuffer(message), SECP256K1_INSTRUCTION_LAYOUT.span);\n return new TransactionInstruction({\n keys: [],\n programId: Secp256k1Program.programId,\n data: instructionData\n });\n }\n\n /**\n * Create an secp256k1 instruction with a private key. The private key\n * must be a buffer that is 32 bytes long.\n */\n static createInstructionWithPrivateKey(params) {\n const {\n privateKey: pkey,\n message,\n instructionIndex\n } = params;\n assert(pkey.length === PRIVATE_KEY_BYTES, `Private key must be ${PRIVATE_KEY_BYTES} bytes but received ${pkey.length} bytes`);\n try {\n const privateKey = toBuffer(pkey);\n const publicKey = publicKeyCreate(privateKey, false /* isCompressed */).slice(1); // throw away leading byte\n const messageHash = Buffer.from(keccak_256(toBuffer(message)));\n const [signature, recoveryId] = ecdsaSign(messageHash, privateKey);\n return this.createInstructionWithPublicKey({\n publicKey,\n message,\n signature,\n recoveryId,\n instructionIndex\n });\n } catch (error) {\n throw new Error(`Error creating instruction; ${error}`);\n }\n }\n}\nSecp256k1Program.programId = new PublicKey('KeccakSecp256k11111111111111111111111111111');\n\nvar _Lockup;\n\n/**\n * Address of the stake config account which configures the rate\n * of stake warmup and cooldown as well as the slashing penalty.\n */\nconst STAKE_CONFIG_ID = new PublicKey('StakeConfig11111111111111111111111111111111');\n\n/**\n * Stake account authority info\n */\nclass Authorized {\n /**\n * Create a new Authorized object\n * @param staker the stake authority\n * @param withdrawer the withdraw authority\n */\n constructor(staker, withdrawer) {\n /** stake authority */\n this.staker = void 0;\n /** withdraw authority */\n this.withdrawer = void 0;\n this.staker = staker;\n this.withdrawer = withdrawer;\n }\n}\n/**\n * Stake account lockup info\n */\nclass Lockup {\n /**\n * Create a new Lockup object\n */\n constructor(unixTimestamp, epoch, custodian) {\n /** Unix timestamp of lockup expiration */\n this.unixTimestamp = void 0;\n /** Epoch of lockup expiration */\n this.epoch = void 0;\n /** Lockup custodian authority */\n this.custodian = void 0;\n this.unixTimestamp = unixTimestamp;\n this.epoch = epoch;\n this.custodian = custodian;\n }\n\n /**\n * Default, inactive Lockup value\n */\n}\n_Lockup = Lockup;\nLockup.default = new _Lockup(0, 0, PublicKey.default);\n/**\n * Create stake account transaction params\n */\n/**\n * Create stake account with seed transaction params\n */\n/**\n * Initialize stake instruction params\n */\n/**\n * Delegate stake instruction params\n */\n/**\n * Authorize stake instruction params\n */\n/**\n * Authorize stake instruction params using a derived key\n */\n/**\n * Split stake instruction params\n */\n/**\n * Split with seed transaction params\n */\n/**\n * Withdraw stake instruction params\n */\n/**\n * Deactivate stake instruction params\n */\n/**\n * Merge stake instruction params\n */\n/**\n * Stake Instruction class\n */\nclass StakeInstruction {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Decode a stake instruction and retrieve the instruction type.\n */\n static decodeInstructionType(instruction) {\n this.checkProgramId(instruction.programId);\n const instructionTypeLayout = BufferLayout.u32('instruction');\n const typeIndex = instructionTypeLayout.decode(instruction.data);\n let type;\n for (const [ixType, layout] of Object.entries(STAKE_INSTRUCTION_LAYOUTS)) {\n if (layout.index == typeIndex) {\n type = ixType;\n break;\n }\n }\n if (!type) {\n throw new Error('Instruction type incorrect; not a StakeInstruction');\n }\n return type;\n }\n\n /**\n * Decode a initialize stake instruction and retrieve the instruction params.\n */\n static decodeInitialize(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n const {\n authorized,\n lockup\n } = decodeData$1(STAKE_INSTRUCTION_LAYOUTS.Initialize, instruction.data);\n return {\n stakePubkey: instruction.keys[0].pubkey,\n authorized: new Authorized(new PublicKey(authorized.staker), new PublicKey(authorized.withdrawer)),\n lockup: new Lockup(lockup.unixTimestamp, lockup.epoch, new PublicKey(lockup.custodian))\n };\n }\n\n /**\n * Decode a delegate stake instruction and retrieve the instruction params.\n */\n static decodeDelegate(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 6);\n decodeData$1(STAKE_INSTRUCTION_LAYOUTS.Delegate, instruction.data);\n return {\n stakePubkey: instruction.keys[0].pubkey,\n votePubkey: instruction.keys[1].pubkey,\n authorizedPubkey: instruction.keys[5].pubkey\n };\n }\n\n /**\n * Decode an authorize stake instruction and retrieve the instruction params.\n */\n static decodeAuthorize(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const {\n newAuthorized,\n stakeAuthorizationType\n } = decodeData$1(STAKE_INSTRUCTION_LAYOUTS.Authorize, instruction.data);\n const o = {\n stakePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: instruction.keys[2].pubkey,\n newAuthorizedPubkey: new PublicKey(newAuthorized),\n stakeAuthorizationType: {\n index: stakeAuthorizationType\n }\n };\n if (instruction.keys.length > 3) {\n o.custodianPubkey = instruction.keys[3].pubkey;\n }\n return o;\n }\n\n /**\n * Decode an authorize-with-seed stake instruction and retrieve the instruction params.\n */\n static decodeAuthorizeWithSeed(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n const {\n newAuthorized,\n stakeAuthorizationType,\n authoritySeed,\n authorityOwner\n } = decodeData$1(STAKE_INSTRUCTION_LAYOUTS.AuthorizeWithSeed, instruction.data);\n const o = {\n stakePubkey: instruction.keys[0].pubkey,\n authorityBase: instruction.keys[1].pubkey,\n authoritySeed: authoritySeed,\n authorityOwner: new PublicKey(authorityOwner),\n newAuthorizedPubkey: new PublicKey(newAuthorized),\n stakeAuthorizationType: {\n index: stakeAuthorizationType\n }\n };\n if (instruction.keys.length > 3) {\n o.custodianPubkey = instruction.keys[3].pubkey;\n }\n return o;\n }\n\n /**\n * Decode a split stake instruction and retrieve the instruction params.\n */\n static decodeSplit(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const {\n lamports\n } = decodeData$1(STAKE_INSTRUCTION_LAYOUTS.Split, instruction.data);\n return {\n stakePubkey: instruction.keys[0].pubkey,\n splitStakePubkey: instruction.keys[1].pubkey,\n authorizedPubkey: instruction.keys[2].pubkey,\n lamports\n };\n }\n\n /**\n * Decode a merge stake instruction and retrieve the instruction params.\n */\n static decodeMerge(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n decodeData$1(STAKE_INSTRUCTION_LAYOUTS.Merge, instruction.data);\n return {\n stakePubkey: instruction.keys[0].pubkey,\n sourceStakePubKey: instruction.keys[1].pubkey,\n authorizedPubkey: instruction.keys[4].pubkey\n };\n }\n\n /**\n * Decode a withdraw stake instruction and retrieve the instruction params.\n */\n static decodeWithdraw(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 5);\n const {\n lamports\n } = decodeData$1(STAKE_INSTRUCTION_LAYOUTS.Withdraw, instruction.data);\n const o = {\n stakePubkey: instruction.keys[0].pubkey,\n toPubkey: instruction.keys[1].pubkey,\n authorizedPubkey: instruction.keys[4].pubkey,\n lamports\n };\n if (instruction.keys.length > 5) {\n o.custodianPubkey = instruction.keys[5].pubkey;\n }\n return o;\n }\n\n /**\n * Decode a deactivate stake instruction and retrieve the instruction params.\n */\n static decodeDeactivate(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n decodeData$1(STAKE_INSTRUCTION_LAYOUTS.Deactivate, instruction.data);\n return {\n stakePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: instruction.keys[2].pubkey\n };\n }\n\n /**\n * @internal\n */\n static checkProgramId(programId) {\n if (!programId.equals(StakeProgram.programId)) {\n throw new Error('invalid instruction; programId is not StakeProgram');\n }\n }\n\n /**\n * @internal\n */\n static checkKeyLength(keys, expectedLength) {\n if (keys.length < expectedLength) {\n throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);\n }\n }\n}\n\n/**\n * An enumeration of valid StakeInstructionType's\n */\n\n/**\n * An enumeration of valid stake InstructionType's\n * @internal\n */\nconst STAKE_INSTRUCTION_LAYOUTS = Object.freeze({\n Initialize: {\n index: 0,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), authorized(), lockup()])\n },\n Authorize: {\n index: 1,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('newAuthorized'), BufferLayout.u32('stakeAuthorizationType')])\n },\n Delegate: {\n index: 2,\n layout: BufferLayout.struct([BufferLayout.u32('instruction')])\n },\n Split: {\n index: 3,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports')])\n },\n Withdraw: {\n index: 4,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports')])\n },\n Deactivate: {\n index: 5,\n layout: BufferLayout.struct([BufferLayout.u32('instruction')])\n },\n Merge: {\n index: 7,\n layout: BufferLayout.struct([BufferLayout.u32('instruction')])\n },\n AuthorizeWithSeed: {\n index: 8,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('newAuthorized'), BufferLayout.u32('stakeAuthorizationType'), rustString('authoritySeed'), publicKey('authorityOwner')])\n }\n});\n\n/**\n * Stake authorization type\n */\n\n/**\n * An enumeration of valid StakeAuthorizationLayout's\n */\nconst StakeAuthorizationLayout = Object.freeze({\n Staker: {\n index: 0\n },\n Withdrawer: {\n index: 1\n }\n});\n\n/**\n * Factory class for transactions to interact with the Stake program\n */\nclass StakeProgram {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Public key that identifies the Stake program\n */\n\n /**\n * Generate an Initialize instruction to add to a Stake Create transaction\n */\n static initialize(params) {\n const {\n stakePubkey,\n authorized,\n lockup: maybeLockup\n } = params;\n const lockup = maybeLockup || Lockup.default;\n const type = STAKE_INSTRUCTION_LAYOUTS.Initialize;\n const data = encodeData(type, {\n authorized: {\n staker: toBuffer(authorized.staker.toBuffer()),\n withdrawer: toBuffer(authorized.withdrawer.toBuffer())\n },\n lockup: {\n unixTimestamp: lockup.unixTimestamp,\n epoch: lockup.epoch,\n custodian: toBuffer(lockup.custodian.toBuffer())\n }\n });\n const instructionData = {\n keys: [{\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: SYSVAR_RENT_PUBKEY,\n isSigner: false,\n isWritable: false\n }],\n programId: this.programId,\n data\n };\n return new TransactionInstruction(instructionData);\n }\n\n /**\n * Generate a Transaction that creates a new Stake account at\n * an address generated with `from`, a seed, and the Stake programId\n */\n static createAccountWithSeed(params) {\n const transaction = new Transaction();\n transaction.add(SystemProgram.createAccountWithSeed({\n fromPubkey: params.fromPubkey,\n newAccountPubkey: params.stakePubkey,\n basePubkey: params.basePubkey,\n seed: params.seed,\n lamports: params.lamports,\n space: this.space,\n programId: this.programId\n }));\n const {\n stakePubkey,\n authorized,\n lockup\n } = params;\n return transaction.add(this.initialize({\n stakePubkey,\n authorized,\n lockup\n }));\n }\n\n /**\n * Generate a Transaction that creates a new Stake account\n */\n static createAccount(params) {\n const transaction = new Transaction();\n transaction.add(SystemProgram.createAccount({\n fromPubkey: params.fromPubkey,\n newAccountPubkey: params.stakePubkey,\n lamports: params.lamports,\n space: this.space,\n programId: this.programId\n }));\n const {\n stakePubkey,\n authorized,\n lockup\n } = params;\n return transaction.add(this.initialize({\n stakePubkey,\n authorized,\n lockup\n }));\n }\n\n /**\n * Generate a Transaction that delegates Stake tokens to a validator\n * Vote PublicKey. This transaction can also be used to redelegate Stake\n * to a new validator Vote PublicKey.\n */\n static delegate(params) {\n const {\n stakePubkey,\n authorizedPubkey,\n votePubkey\n } = params;\n const type = STAKE_INSTRUCTION_LAYOUTS.Delegate;\n const data = encodeData(type);\n return new Transaction().add({\n keys: [{\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: votePubkey,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: SYSVAR_CLOCK_PUBKEY,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: SYSVAR_STAKE_HISTORY_PUBKEY,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: STAKE_CONFIG_ID,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: authorizedPubkey,\n isSigner: true,\n isWritable: false\n }],\n programId: this.programId,\n data\n });\n }\n\n /**\n * Generate a Transaction that authorizes a new PublicKey as Staker\n * or Withdrawer on the Stake account.\n */\n static authorize(params) {\n const {\n stakePubkey,\n authorizedPubkey,\n newAuthorizedPubkey,\n stakeAuthorizationType,\n custodianPubkey\n } = params;\n const type = STAKE_INSTRUCTION_LAYOUTS.Authorize;\n const data = encodeData(type, {\n newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),\n stakeAuthorizationType: stakeAuthorizationType.index\n });\n const keys = [{\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: SYSVAR_CLOCK_PUBKEY,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: authorizedPubkey,\n isSigner: true,\n isWritable: false\n }];\n if (custodianPubkey) {\n keys.push({\n pubkey: custodianPubkey,\n isSigner: true,\n isWritable: false\n });\n }\n return new Transaction().add({\n keys,\n programId: this.programId,\n data\n });\n }\n\n /**\n * Generate a Transaction that authorizes a new PublicKey as Staker\n * or Withdrawer on the Stake account.\n */\n static authorizeWithSeed(params) {\n const {\n stakePubkey,\n authorityBase,\n authoritySeed,\n authorityOwner,\n newAuthorizedPubkey,\n stakeAuthorizationType,\n custodianPubkey\n } = params;\n const type = STAKE_INSTRUCTION_LAYOUTS.AuthorizeWithSeed;\n const data = encodeData(type, {\n newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),\n stakeAuthorizationType: stakeAuthorizationType.index,\n authoritySeed: authoritySeed,\n authorityOwner: toBuffer(authorityOwner.toBuffer())\n });\n const keys = [{\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: authorityBase,\n isSigner: true,\n isWritable: false\n }, {\n pubkey: SYSVAR_CLOCK_PUBKEY,\n isSigner: false,\n isWritable: false\n }];\n if (custodianPubkey) {\n keys.push({\n pubkey: custodianPubkey,\n isSigner: true,\n isWritable: false\n });\n }\n return new Transaction().add({\n keys,\n programId: this.programId,\n data\n });\n }\n\n /**\n * @internal\n */\n static splitInstruction(params) {\n const {\n stakePubkey,\n authorizedPubkey,\n splitStakePubkey,\n lamports\n } = params;\n const type = STAKE_INSTRUCTION_LAYOUTS.Split;\n const data = encodeData(type, {\n lamports\n });\n return new TransactionInstruction({\n keys: [{\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: splitStakePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: authorizedPubkey,\n isSigner: true,\n isWritable: false\n }],\n programId: this.programId,\n data\n });\n }\n\n /**\n * Generate a Transaction that splits Stake tokens into another stake account\n */\n static split(params,\n // Compute the cost of allocating the new stake account in lamports\n rentExemptReserve) {\n const transaction = new Transaction();\n transaction.add(SystemProgram.createAccount({\n fromPubkey: params.authorizedPubkey,\n newAccountPubkey: params.splitStakePubkey,\n lamports: rentExemptReserve,\n space: this.space,\n programId: this.programId\n }));\n return transaction.add(this.splitInstruction(params));\n }\n\n /**\n * Generate a Transaction that splits Stake tokens into another account\n * derived from a base public key and seed\n */\n static splitWithSeed(params,\n // If this stake account is new, compute the cost of allocating it in lamports\n rentExemptReserve) {\n const {\n stakePubkey,\n authorizedPubkey,\n splitStakePubkey,\n basePubkey,\n seed,\n lamports\n } = params;\n const transaction = new Transaction();\n transaction.add(SystemProgram.allocate({\n accountPubkey: splitStakePubkey,\n basePubkey,\n seed,\n space: this.space,\n programId: this.programId\n }));\n if (rentExemptReserve && rentExemptReserve > 0) {\n transaction.add(SystemProgram.transfer({\n fromPubkey: params.authorizedPubkey,\n toPubkey: splitStakePubkey,\n lamports: rentExemptReserve\n }));\n }\n return transaction.add(this.splitInstruction({\n stakePubkey,\n authorizedPubkey,\n splitStakePubkey,\n lamports\n }));\n }\n\n /**\n * Generate a Transaction that merges Stake accounts.\n */\n static merge(params) {\n const {\n stakePubkey,\n sourceStakePubKey,\n authorizedPubkey\n } = params;\n const type = STAKE_INSTRUCTION_LAYOUTS.Merge;\n const data = encodeData(type);\n return new Transaction().add({\n keys: [{\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: sourceStakePubKey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: SYSVAR_CLOCK_PUBKEY,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: SYSVAR_STAKE_HISTORY_PUBKEY,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: authorizedPubkey,\n isSigner: true,\n isWritable: false\n }],\n programId: this.programId,\n data\n });\n }\n\n /**\n * Generate a Transaction that withdraws deactivated Stake tokens.\n */\n static withdraw(params) {\n const {\n stakePubkey,\n authorizedPubkey,\n toPubkey,\n lamports,\n custodianPubkey\n } = params;\n const type = STAKE_INSTRUCTION_LAYOUTS.Withdraw;\n const data = encodeData(type, {\n lamports\n });\n const keys = [{\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: toPubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: SYSVAR_CLOCK_PUBKEY,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: SYSVAR_STAKE_HISTORY_PUBKEY,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: authorizedPubkey,\n isSigner: true,\n isWritable: false\n }];\n if (custodianPubkey) {\n keys.push({\n pubkey: custodianPubkey,\n isSigner: true,\n isWritable: false\n });\n }\n return new Transaction().add({\n keys,\n programId: this.programId,\n data\n });\n }\n\n /**\n * Generate a Transaction that deactivates Stake tokens.\n */\n static deactivate(params) {\n const {\n stakePubkey,\n authorizedPubkey\n } = params;\n const type = STAKE_INSTRUCTION_LAYOUTS.Deactivate;\n const data = encodeData(type);\n return new Transaction().add({\n keys: [{\n pubkey: stakePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: SYSVAR_CLOCK_PUBKEY,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: authorizedPubkey,\n isSigner: true,\n isWritable: false\n }],\n programId: this.programId,\n data\n });\n }\n}\nStakeProgram.programId = new PublicKey('Stake11111111111111111111111111111111111111');\n/**\n * Max space of a Stake account\n *\n * This is generated from the solana-stake-program StakeState struct as\n * `StakeStateV2::size_of()`:\n * https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeStateV2.html\n */\nStakeProgram.space = 200;\n\n/**\n * Vote account info\n */\nclass VoteInit {\n /** [0, 100] */\n\n constructor(nodePubkey, authorizedVoter, authorizedWithdrawer, commission) {\n this.nodePubkey = void 0;\n this.authorizedVoter = void 0;\n this.authorizedWithdrawer = void 0;\n this.commission = void 0;\n this.nodePubkey = nodePubkey;\n this.authorizedVoter = authorizedVoter;\n this.authorizedWithdrawer = authorizedWithdrawer;\n this.commission = commission;\n }\n}\n\n/**\n * Create vote account transaction params\n */\n\n/**\n * InitializeAccount instruction params\n */\n\n/**\n * Authorize instruction params\n */\n\n/**\n * AuthorizeWithSeed instruction params\n */\n\n/**\n * Withdraw from vote account transaction params\n */\n\n/**\n * Update validator identity (node pubkey) vote account instruction params.\n */\n\n/**\n * Vote Instruction class\n */\nclass VoteInstruction {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Decode a vote instruction and retrieve the instruction type.\n */\n static decodeInstructionType(instruction) {\n this.checkProgramId(instruction.programId);\n const instructionTypeLayout = BufferLayout.u32('instruction');\n const typeIndex = instructionTypeLayout.decode(instruction.data);\n let type;\n for (const [ixType, layout] of Object.entries(VOTE_INSTRUCTION_LAYOUTS)) {\n if (layout.index == typeIndex) {\n type = ixType;\n break;\n }\n }\n if (!type) {\n throw new Error('Instruction type incorrect; not a VoteInstruction');\n }\n return type;\n }\n\n /**\n * Decode an initialize vote instruction and retrieve the instruction params.\n */\n static decodeInitializeAccount(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 4);\n const {\n voteInit\n } = decodeData$1(VOTE_INSTRUCTION_LAYOUTS.InitializeAccount, instruction.data);\n return {\n votePubkey: instruction.keys[0].pubkey,\n nodePubkey: instruction.keys[3].pubkey,\n voteInit: new VoteInit(new PublicKey(voteInit.nodePubkey), new PublicKey(voteInit.authorizedVoter), new PublicKey(voteInit.authorizedWithdrawer), voteInit.commission)\n };\n }\n\n /**\n * Decode an authorize instruction and retrieve the instruction params.\n */\n static decodeAuthorize(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const {\n newAuthorized,\n voteAuthorizationType\n } = decodeData$1(VOTE_INSTRUCTION_LAYOUTS.Authorize, instruction.data);\n return {\n votePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: instruction.keys[2].pubkey,\n newAuthorizedPubkey: new PublicKey(newAuthorized),\n voteAuthorizationType: {\n index: voteAuthorizationType\n }\n };\n }\n\n /**\n * Decode an authorize instruction and retrieve the instruction params.\n */\n static decodeAuthorizeWithSeed(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const {\n voteAuthorizeWithSeedArgs: {\n currentAuthorityDerivedKeyOwnerPubkey,\n currentAuthorityDerivedKeySeed,\n newAuthorized,\n voteAuthorizationType\n }\n } = decodeData$1(VOTE_INSTRUCTION_LAYOUTS.AuthorizeWithSeed, instruction.data);\n return {\n currentAuthorityDerivedKeyBasePubkey: instruction.keys[2].pubkey,\n currentAuthorityDerivedKeyOwnerPubkey: new PublicKey(currentAuthorityDerivedKeyOwnerPubkey),\n currentAuthorityDerivedKeySeed: currentAuthorityDerivedKeySeed,\n newAuthorizedPubkey: new PublicKey(newAuthorized),\n voteAuthorizationType: {\n index: voteAuthorizationType\n },\n votePubkey: instruction.keys[0].pubkey\n };\n }\n\n /**\n * Decode a withdraw instruction and retrieve the instruction params.\n */\n static decodeWithdraw(instruction) {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const {\n lamports\n } = decodeData$1(VOTE_INSTRUCTION_LAYOUTS.Withdraw, instruction.data);\n return {\n votePubkey: instruction.keys[0].pubkey,\n authorizedWithdrawerPubkey: instruction.keys[2].pubkey,\n lamports,\n toPubkey: instruction.keys[1].pubkey\n };\n }\n\n /**\n * @internal\n */\n static checkProgramId(programId) {\n if (!programId.equals(VoteProgram.programId)) {\n throw new Error('invalid instruction; programId is not VoteProgram');\n }\n }\n\n /**\n * @internal\n */\n static checkKeyLength(keys, expectedLength) {\n if (keys.length < expectedLength) {\n throw new Error(`invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`);\n }\n }\n}\n\n/**\n * An enumeration of valid VoteInstructionType's\n */\n\n/** @internal */\n\nconst VOTE_INSTRUCTION_LAYOUTS = Object.freeze({\n InitializeAccount: {\n index: 0,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), voteInit()])\n },\n Authorize: {\n index: 1,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), publicKey('newAuthorized'), BufferLayout.u32('voteAuthorizationType')])\n },\n Withdraw: {\n index: 3,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports')])\n },\n UpdateValidatorIdentity: {\n index: 4,\n layout: BufferLayout.struct([BufferLayout.u32('instruction')])\n },\n AuthorizeWithSeed: {\n index: 10,\n layout: BufferLayout.struct([BufferLayout.u32('instruction'), voteAuthorizeWithSeedArgs()])\n }\n});\n\n/**\n * VoteAuthorize type\n */\n\n/**\n * An enumeration of valid VoteAuthorization layouts.\n */\nconst VoteAuthorizationLayout = Object.freeze({\n Voter: {\n index: 0\n },\n Withdrawer: {\n index: 1\n }\n});\n\n/**\n * Factory class for transactions to interact with the Vote program\n */\nclass VoteProgram {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Public key that identifies the Vote program\n */\n\n /**\n * Generate an Initialize instruction.\n */\n static initializeAccount(params) {\n const {\n votePubkey,\n nodePubkey,\n voteInit\n } = params;\n const type = VOTE_INSTRUCTION_LAYOUTS.InitializeAccount;\n const data = encodeData(type, {\n voteInit: {\n nodePubkey: toBuffer(voteInit.nodePubkey.toBuffer()),\n authorizedVoter: toBuffer(voteInit.authorizedVoter.toBuffer()),\n authorizedWithdrawer: toBuffer(voteInit.authorizedWithdrawer.toBuffer()),\n commission: voteInit.commission\n }\n });\n const instructionData = {\n keys: [{\n pubkey: votePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: SYSVAR_RENT_PUBKEY,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: SYSVAR_CLOCK_PUBKEY,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: nodePubkey,\n isSigner: true,\n isWritable: false\n }],\n programId: this.programId,\n data\n };\n return new TransactionInstruction(instructionData);\n }\n\n /**\n * Generate a transaction that creates a new Vote account.\n */\n static createAccount(params) {\n const transaction = new Transaction();\n transaction.add(SystemProgram.createAccount({\n fromPubkey: params.fromPubkey,\n newAccountPubkey: params.votePubkey,\n lamports: params.lamports,\n space: this.space,\n programId: this.programId\n }));\n return transaction.add(this.initializeAccount({\n votePubkey: params.votePubkey,\n nodePubkey: params.voteInit.nodePubkey,\n voteInit: params.voteInit\n }));\n }\n\n /**\n * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account.\n */\n static authorize(params) {\n const {\n votePubkey,\n authorizedPubkey,\n newAuthorizedPubkey,\n voteAuthorizationType\n } = params;\n const type = VOTE_INSTRUCTION_LAYOUTS.Authorize;\n const data = encodeData(type, {\n newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),\n voteAuthorizationType: voteAuthorizationType.index\n });\n const keys = [{\n pubkey: votePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: SYSVAR_CLOCK_PUBKEY,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: authorizedPubkey,\n isSigner: true,\n isWritable: false\n }];\n return new Transaction().add({\n keys,\n programId: this.programId,\n data\n });\n }\n\n /**\n * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account\n * where the current Voter or Withdrawer authority is a derived key.\n */\n static authorizeWithSeed(params) {\n const {\n currentAuthorityDerivedKeyBasePubkey,\n currentAuthorityDerivedKeyOwnerPubkey,\n currentAuthorityDerivedKeySeed,\n newAuthorizedPubkey,\n voteAuthorizationType,\n votePubkey\n } = params;\n const type = VOTE_INSTRUCTION_LAYOUTS.AuthorizeWithSeed;\n const data = encodeData(type, {\n voteAuthorizeWithSeedArgs: {\n currentAuthorityDerivedKeyOwnerPubkey: toBuffer(currentAuthorityDerivedKeyOwnerPubkey.toBuffer()),\n currentAuthorityDerivedKeySeed: currentAuthorityDerivedKeySeed,\n newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),\n voteAuthorizationType: voteAuthorizationType.index\n }\n });\n const keys = [{\n pubkey: votePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: SYSVAR_CLOCK_PUBKEY,\n isSigner: false,\n isWritable: false\n }, {\n pubkey: currentAuthorityDerivedKeyBasePubkey,\n isSigner: true,\n isWritable: false\n }];\n return new Transaction().add({\n keys,\n programId: this.programId,\n data\n });\n }\n\n /**\n * Generate a transaction to withdraw from a Vote account.\n */\n static withdraw(params) {\n const {\n votePubkey,\n authorizedWithdrawerPubkey,\n lamports,\n toPubkey\n } = params;\n const type = VOTE_INSTRUCTION_LAYOUTS.Withdraw;\n const data = encodeData(type, {\n lamports\n });\n const keys = [{\n pubkey: votePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: toPubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: authorizedWithdrawerPubkey,\n isSigner: true,\n isWritable: false\n }];\n return new Transaction().add({\n keys,\n programId: this.programId,\n data\n });\n }\n\n /**\n * Generate a transaction to withdraw safely from a Vote account.\n *\n * This function was created as a safeguard for vote accounts running validators, `safeWithdraw`\n * checks that the withdraw amount will not exceed the specified balance while leaving enough left\n * to cover rent. If you wish to close the vote account by withdrawing the full amount, call the\n * `withdraw` method directly.\n */\n static safeWithdraw(params, currentVoteAccountBalance, rentExemptMinimum) {\n if (params.lamports > currentVoteAccountBalance - rentExemptMinimum) {\n throw new Error('Withdraw will leave vote account with insufficient funds.');\n }\n return VoteProgram.withdraw(params);\n }\n\n /**\n * Generate a transaction to update the validator identity (node pubkey) of a Vote account.\n */\n static updateValidatorIdentity(params) {\n const {\n votePubkey,\n authorizedWithdrawerPubkey,\n nodePubkey\n } = params;\n const type = VOTE_INSTRUCTION_LAYOUTS.UpdateValidatorIdentity;\n const data = encodeData(type);\n const keys = [{\n pubkey: votePubkey,\n isSigner: false,\n isWritable: true\n }, {\n pubkey: nodePubkey,\n isSigner: true,\n isWritable: false\n }, {\n pubkey: authorizedWithdrawerPubkey,\n isSigner: true,\n isWritable: false\n }];\n return new Transaction().add({\n keys,\n programId: this.programId,\n data\n });\n }\n}\nVoteProgram.programId = new PublicKey('Vote111111111111111111111111111111111111111');\n/**\n * Max space of a Vote account\n *\n * This is generated from the solana-vote-program VoteState struct as\n * `VoteState::size_of()`:\n * https://docs.rs/solana-vote-program/1.9.5/solana_vote_program/vote_state/struct.VoteState.html#method.size_of\n *\n * KEEP IN SYNC WITH `VoteState::size_of()` in https://github.com/solana-labs/solana/blob/a474cb24b9238f5edcc982f65c0b37d4a1046f7e/sdk/program/src/vote/state/mod.rs#L340-L342\n */\nVoteProgram.space = 3762;\n\nconst VALIDATOR_INFO_KEY = new PublicKey('Va1idator1nfo111111111111111111111111111111');\n\n/**\n * @internal\n */\n\n/**\n * Info used to identity validators.\n */\n\nconst InfoString = type({\n name: string(),\n website: optional(string()),\n details: optional(string()),\n iconUrl: optional(string()),\n keybaseUsername: optional(string())\n});\n\n/**\n * ValidatorInfo class\n */\nclass ValidatorInfo {\n /**\n * Construct a valid ValidatorInfo\n *\n * @param key validator public key\n * @param info validator information\n */\n constructor(key, info) {\n /**\n * validator public key\n */\n this.key = void 0;\n /**\n * validator information\n */\n this.info = void 0;\n this.key = key;\n this.info = info;\n }\n\n /**\n * Deserialize ValidatorInfo from the config account data. Exactly two config\n * keys are required in the data.\n *\n * @param buffer config account data\n * @return null if info was not found\n */\n static fromConfigData(buffer) {\n let byteArray = [...buffer];\n const configKeyCount = decodeLength(byteArray);\n if (configKeyCount !== 2) return null;\n const configKeys = [];\n for (let i = 0; i < 2; i++) {\n const publicKey = new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH));\n const isSigner = guardedShift(byteArray) === 1;\n configKeys.push({\n publicKey,\n isSigner\n });\n }\n if (configKeys[0].publicKey.equals(VALIDATOR_INFO_KEY)) {\n if (configKeys[1].isSigner) {\n const rawInfo = rustString().decode(Buffer.from(byteArray));\n const info = JSON.parse(rawInfo);\n assert$1(info, InfoString);\n return new ValidatorInfo(configKeys[1].publicKey, info);\n }\n }\n return null;\n }\n}\n\nconst VOTE_PROGRAM_ID = new PublicKey('Vote111111111111111111111111111111111111111');\n\n/**\n * History of how many credits earned by the end of each epoch\n */\n\n/**\n * See https://github.com/solana-labs/solana/blob/8a12ed029cfa38d4a45400916c2463fb82bbec8c/programs/vote_api/src/vote_state.rs#L68-L88\n *\n * @internal\n */\nconst VoteAccountLayout = BufferLayout.struct([publicKey('nodePubkey'), publicKey('authorizedWithdrawer'), BufferLayout.u8('commission'), BufferLayout.nu64(),\n// votes.length\nBufferLayout.seq(BufferLayout.struct([BufferLayout.nu64('slot'), BufferLayout.u32('confirmationCount')]), BufferLayout.offset(BufferLayout.u32(), -8), 'votes'), BufferLayout.u8('rootSlotValid'), BufferLayout.nu64('rootSlot'), BufferLayout.nu64(),\n// authorizedVoters.length\nBufferLayout.seq(BufferLayout.struct([BufferLayout.nu64('epoch'), publicKey('authorizedVoter')]), BufferLayout.offset(BufferLayout.u32(), -8), 'authorizedVoters'), BufferLayout.struct([BufferLayout.seq(BufferLayout.struct([publicKey('authorizedPubkey'), BufferLayout.nu64('epochOfLastAuthorizedSwitch'), BufferLayout.nu64('targetEpoch')]), 32, 'buf'), BufferLayout.nu64('idx'), BufferLayout.u8('isEmpty')], 'priorVoters'), BufferLayout.nu64(),\n// epochCredits.length\nBufferLayout.seq(BufferLayout.struct([BufferLayout.nu64('epoch'), BufferLayout.nu64('credits'), BufferLayout.nu64('prevCredits')]), BufferLayout.offset(BufferLayout.u32(), -8), 'epochCredits'), BufferLayout.struct([BufferLayout.nu64('slot'), BufferLayout.nu64('timestamp')], 'lastTimestamp')]);\n/**\n * VoteAccount class\n */\nclass VoteAccount {\n /**\n * @internal\n */\n constructor(args) {\n this.nodePubkey = void 0;\n this.authorizedWithdrawer = void 0;\n this.commission = void 0;\n this.rootSlot = void 0;\n this.votes = void 0;\n this.authorizedVoters = void 0;\n this.priorVoters = void 0;\n this.epochCredits = void 0;\n this.lastTimestamp = void 0;\n this.nodePubkey = args.nodePubkey;\n this.authorizedWithdrawer = args.authorizedWithdrawer;\n this.commission = args.commission;\n this.rootSlot = args.rootSlot;\n this.votes = args.votes;\n this.authorizedVoters = args.authorizedVoters;\n this.priorVoters = args.priorVoters;\n this.epochCredits = args.epochCredits;\n this.lastTimestamp = args.lastTimestamp;\n }\n\n /**\n * Deserialize VoteAccount from the account data.\n *\n * @param buffer account data\n * @return VoteAccount\n */\n static fromAccountData(buffer) {\n const versionOffset = 4;\n const va = VoteAccountLayout.decode(toBuffer(buffer), versionOffset);\n let rootSlot = va.rootSlot;\n if (!va.rootSlotValid) {\n rootSlot = null;\n }\n return new VoteAccount({\n nodePubkey: new PublicKey(va.nodePubkey),\n authorizedWithdrawer: new PublicKey(va.authorizedWithdrawer),\n commission: va.commission,\n votes: va.votes,\n rootSlot,\n authorizedVoters: va.authorizedVoters.map(parseAuthorizedVoter),\n priorVoters: getPriorVoters(va.priorVoters),\n epochCredits: va.epochCredits,\n lastTimestamp: va.lastTimestamp\n });\n }\n}\nfunction parseAuthorizedVoter({\n authorizedVoter,\n epoch\n}) {\n return {\n epoch,\n authorizedVoter: new PublicKey(authorizedVoter)\n };\n}\nfunction parsePriorVoters({\n authorizedPubkey,\n epochOfLastAuthorizedSwitch,\n targetEpoch\n}) {\n return {\n authorizedPubkey: new PublicKey(authorizedPubkey),\n epochOfLastAuthorizedSwitch,\n targetEpoch\n };\n}\nfunction getPriorVoters({\n buf,\n idx,\n isEmpty\n}) {\n if (isEmpty) {\n return [];\n }\n return [...buf.slice(idx + 1).map(parsePriorVoters), ...buf.slice(0, idx).map(parsePriorVoters)];\n}\n\nconst endpoint = {\n http: {\n devnet: 'http://api.devnet.solana.com',\n testnet: 'http://api.testnet.solana.com',\n 'mainnet-beta': 'http://api.mainnet-beta.solana.com/'\n },\n https: {\n devnet: 'https://api.devnet.solana.com',\n testnet: 'https://api.testnet.solana.com',\n 'mainnet-beta': 'https://api.mainnet-beta.solana.com/'\n }\n};\n/**\n * Retrieves the RPC API URL for the specified cluster\n * @param {Cluster} [cluster=\"devnet\"] - The cluster name of the RPC API URL to use. Possible options: 'devnet' | 'testnet' | 'mainnet-beta'\n * @param {boolean} [tls=\"http\"] - Use TLS when connecting to cluster.\n *\n * @returns {string} URL string of the RPC endpoint\n */\nfunction clusterApiUrl(cluster, tls) {\n const key = tls === false ? 'http' : 'https';\n if (!cluster) {\n return endpoint[key]['devnet'];\n }\n const url = endpoint[key][cluster];\n if (!url) {\n throw new Error(`Unknown ${key} cluster: ${cluster}`);\n }\n return url;\n}\n\n/**\n * Send and confirm a raw transaction\n *\n * If `commitment` option is not specified, defaults to 'max' commitment.\n *\n * @param {Connection} connection\n * @param {Buffer} rawTransaction\n * @param {TransactionConfirmationStrategy} confirmationStrategy\n * @param {ConfirmOptions} [options]\n * @returns {Promise}\n */\n\n/**\n * @deprecated Calling `sendAndConfirmRawTransaction()` without a `confirmationStrategy`\n * is no longer supported and will be removed in a future version.\n */\n// eslint-disable-next-line no-redeclare\n\n// eslint-disable-next-line no-redeclare\nasync function sendAndConfirmRawTransaction(connection, rawTransaction, confirmationStrategyOrConfirmOptions, maybeConfirmOptions) {\n let confirmationStrategy;\n let options;\n if (confirmationStrategyOrConfirmOptions && Object.prototype.hasOwnProperty.call(confirmationStrategyOrConfirmOptions, 'lastValidBlockHeight')) {\n confirmationStrategy = confirmationStrategyOrConfirmOptions;\n options = maybeConfirmOptions;\n } else if (confirmationStrategyOrConfirmOptions && Object.prototype.hasOwnProperty.call(confirmationStrategyOrConfirmOptions, 'nonceValue')) {\n confirmationStrategy = confirmationStrategyOrConfirmOptions;\n options = maybeConfirmOptions;\n } else {\n options = confirmationStrategyOrConfirmOptions;\n }\n const sendOptions = options && {\n skipPreflight: options.skipPreflight,\n preflightCommitment: options.preflightCommitment || options.commitment,\n minContextSlot: options.minContextSlot\n };\n const signature = await connection.sendRawTransaction(rawTransaction, sendOptions);\n const commitment = options && options.commitment;\n const confirmationPromise = confirmationStrategy ? connection.confirmTransaction(confirmationStrategy, commitment) : connection.confirmTransaction(signature, commitment);\n const status = (await confirmationPromise).value;\n if (status.err) {\n if (signature != null) {\n throw new SendTransactionError({\n action: sendOptions?.skipPreflight ? 'send' : 'simulate',\n signature: signature,\n transactionMessage: `Status: (${JSON.stringify(status)})`\n });\n }\n throw new Error(`Raw transaction ${signature} failed (${JSON.stringify(status)})`);\n }\n return signature;\n}\n\n/**\n * There are 1-billion lamports in one SOL\n */\nconst LAMPORTS_PER_SOL = 1000000000;\n\nexport { Account, AddressLookupTableAccount, AddressLookupTableInstruction, AddressLookupTableProgram, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, COMPUTE_BUDGET_INSTRUCTION_LAYOUTS, ComputeBudgetInstruction, ComputeBudgetProgram, Connection, Ed25519Program, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, LOOKUP_TABLE_INSTRUCTION_LAYOUTS, Loader, Lockup, MAX_SEED_LENGTH, Message, MessageAccountKeys, MessageV0, NONCE_ACCOUNT_LENGTH, NonceAccount, PACKET_DATA_SIZE, PUBLIC_KEY_LENGTH, PublicKey, SIGNATURE_LENGTH_IN_BYTES, SOLANA_SCHEMA, STAKE_CONFIG_ID, STAKE_INSTRUCTION_LAYOUTS, SYSTEM_INSTRUCTION_LAYOUTS, SYSVAR_CLOCK_PUBKEY, SYSVAR_EPOCH_SCHEDULE_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_REWARDS_PUBKEY, SYSVAR_SLOT_HASHES_PUBKEY, SYSVAR_SLOT_HISTORY_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, Secp256k1Program, SendTransactionError, SolanaJSONRPCError, SolanaJSONRPCErrorCode, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionExpiredBlockheightExceededError, TransactionExpiredNonceInvalidError, TransactionExpiredTimeoutError, TransactionInstruction, TransactionMessage, TransactionStatus, VALIDATOR_INFO_KEY, VERSION_PREFIX_MASK, VOTE_PROGRAM_ID, ValidatorInfo, VersionedMessage, VersionedTransaction, VoteAccount, VoteAuthorizationLayout, VoteInit, VoteInstruction, VoteProgram, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };\n//# sourceMappingURL=index.browser.esm.js.map\n","import {ed25519} from '@noble/curves/ed25519';\n\n/**\n * A 64 byte secret key, the first 32 bytes of which is the\n * private scalar and the last 32 bytes is the public key.\n * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/\n */\ntype Ed25519SecretKey = Uint8Array;\n\n/**\n * Ed25519 Keypair\n */\nexport interface Ed25519Keypair {\n publicKey: Uint8Array;\n secretKey: Ed25519SecretKey;\n}\n\nexport const generatePrivateKey = ed25519.utils.randomPrivateKey;\nexport const generateKeypair = (): Ed25519Keypair => {\n const privateScalar = ed25519.utils.randomPrivateKey();\n const publicKey = getPublicKey(privateScalar);\n const secretKey = new Uint8Array(64);\n secretKey.set(privateScalar);\n secretKey.set(publicKey, 32);\n return {\n publicKey,\n secretKey,\n };\n};\nexport const getPublicKey = ed25519.getPublicKey;\nexport function isOnCurve(publicKey: Uint8Array): boolean {\n try {\n ed25519.ExtendedPoint.fromHex(publicKey);\n return true;\n } catch {\n return false;\n }\n}\nexport const sign = (\n message: Parameters[0],\n secretKey: Ed25519SecretKey,\n) => ed25519.sign(message, secretKey.slice(0, 32));\nexport const verify = ed25519.verify;\n","import {Buffer} from 'buffer';\n\nexport const toBuffer = (arr: Buffer | Uint8Array | Array): Buffer => {\n if (Buffer.isBuffer(arr)) {\n return arr;\n } else if (arr instanceof Uint8Array) {\n return Buffer.from(arr.buffer, arr.byteOffset, arr.byteLength);\n } else {\n return Buffer.from(arr);\n }\n};\n","import {Buffer} from 'buffer';\nimport {serialize, deserialize, deserializeUnchecked} from 'borsh';\n\n// Class wrapping a plain object\nexport class Struct {\n constructor(properties: any) {\n Object.assign(this, properties);\n }\n\n encode(): Buffer {\n return Buffer.from(serialize(SOLANA_SCHEMA, this));\n }\n\n static decode(data: Buffer): any {\n return deserialize(SOLANA_SCHEMA, this, data);\n }\n\n static decodeUnchecked(data: Buffer): any {\n return deserializeUnchecked(SOLANA_SCHEMA, this, data);\n }\n}\n\n// Class representing a Rust-compatible enum, since enums are only strings or\n// numbers in pure JS\nexport class Enum extends Struct {\n enum: string = '';\n constructor(properties: any) {\n super(properties);\n if (Object.keys(properties).length !== 1) {\n throw new Error('Enum can only take single value');\n }\n Object.keys(properties).map(key => {\n this.enum = key;\n });\n }\n}\n\nexport const SOLANA_SCHEMA: Map = new Map();\n","import BN from 'bn.js';\nimport bs58 from 'bs58';\nimport {Buffer} from 'buffer';\nimport {sha256} from '@noble/hashes/sha256';\n\nimport {isOnCurve} from './utils/ed25519';\nimport {Struct, SOLANA_SCHEMA} from './utils/borsh-schema';\nimport {toBuffer} from './utils/to-buffer';\n\n/**\n * Maximum length of derived pubkey seed\n */\nexport const MAX_SEED_LENGTH = 32;\n\n/**\n * Size of public key in bytes\n */\nexport const PUBLIC_KEY_LENGTH = 32;\n\n/**\n * Value to be converted into public key\n */\nexport type PublicKeyInitData =\n | number\n | string\n | Uint8Array\n | Array\n | PublicKeyData;\n\n/**\n * JSON object representation of PublicKey class\n */\nexport type PublicKeyData = {\n /** @internal */\n _bn: BN;\n};\n\nfunction isPublicKeyData(value: PublicKeyInitData): value is PublicKeyData {\n return (value as PublicKeyData)._bn !== undefined;\n}\n\n// local counter used by PublicKey.unique()\nlet uniquePublicKeyCounter = 1;\n\n/**\n * A public key\n */\nexport class PublicKey extends Struct {\n /** @internal */\n _bn: BN;\n\n /**\n * Create a new PublicKey object\n * @param value ed25519 public key as buffer or base-58 encoded string\n */\n constructor(value: PublicKeyInitData) {\n super({});\n if (isPublicKeyData(value)) {\n this._bn = value._bn;\n } else {\n if (typeof value === 'string') {\n // assume base 58 encoding by default\n const decoded = bs58.decode(value);\n if (decoded.length != PUBLIC_KEY_LENGTH) {\n throw new Error(`Invalid public key input`);\n }\n this._bn = new BN(decoded);\n } else {\n this._bn = new BN(value);\n }\n\n if (this._bn.byteLength() > PUBLIC_KEY_LENGTH) {\n throw new Error(`Invalid public key input`);\n }\n }\n }\n\n /**\n * Returns a unique PublicKey for tests and benchmarks using a counter\n */\n static unique(): PublicKey {\n const key = new PublicKey(uniquePublicKeyCounter);\n uniquePublicKeyCounter += 1;\n return new PublicKey(key.toBuffer());\n }\n\n /**\n * Default public key value. The base58-encoded string representation is all ones (as seen below)\n * The underlying BN number is 32 bytes that are all zeros\n */\n static default: PublicKey = new PublicKey('11111111111111111111111111111111');\n\n /**\n * Checks if two publicKeys are equal\n */\n equals(publicKey: PublicKey): boolean {\n return this._bn.eq(publicKey._bn);\n }\n\n /**\n * Return the base-58 representation of the public key\n */\n toBase58(): string {\n return bs58.encode(this.toBytes());\n }\n\n toJSON(): string {\n return this.toBase58();\n }\n\n /**\n * Return the byte array representation of the public key in big endian\n */\n toBytes(): Uint8Array {\n const buf = this.toBuffer();\n return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);\n }\n\n /**\n * Return the Buffer representation of the public key in big endian\n */\n toBuffer(): Buffer {\n const b = this._bn.toArrayLike(Buffer);\n if (b.length === PUBLIC_KEY_LENGTH) {\n return b;\n }\n\n const zeroPad = Buffer.alloc(32);\n b.copy(zeroPad, 32 - b.length);\n return zeroPad;\n }\n\n get [Symbol.toStringTag](): string {\n return `PublicKey(${this.toString()})`;\n }\n\n /**\n * Return the base-58 representation of the public key\n */\n toString(): string {\n return this.toBase58();\n }\n\n /**\n * Derive a public key from another key, a seed, and a program ID.\n * The program ID will also serve as the owner of the public key, giving\n * it permission to write data to the account.\n */\n /* eslint-disable require-await */\n static async createWithSeed(\n fromPublicKey: PublicKey,\n seed: string,\n programId: PublicKey,\n ): Promise {\n const buffer = Buffer.concat([\n fromPublicKey.toBuffer(),\n Buffer.from(seed),\n programId.toBuffer(),\n ]);\n const publicKeyBytes = sha256(buffer);\n return new PublicKey(publicKeyBytes);\n }\n\n /**\n * Derive a program address from seeds and a program ID.\n */\n /* eslint-disable require-await */\n static createProgramAddressSync(\n seeds: Array,\n programId: PublicKey,\n ): PublicKey {\n let buffer = Buffer.alloc(0);\n seeds.forEach(function (seed) {\n if (seed.length > MAX_SEED_LENGTH) {\n throw new TypeError(`Max seed length exceeded`);\n }\n buffer = Buffer.concat([buffer, toBuffer(seed)]);\n });\n buffer = Buffer.concat([\n buffer,\n programId.toBuffer(),\n Buffer.from('ProgramDerivedAddress'),\n ]);\n const publicKeyBytes = sha256(buffer);\n if (isOnCurve(publicKeyBytes)) {\n throw new Error(`Invalid seeds, address must fall off the curve`);\n }\n return new PublicKey(publicKeyBytes);\n }\n\n /**\n * Async version of createProgramAddressSync\n * For backwards compatibility\n *\n * @deprecated Use {@link createProgramAddressSync} instead\n */\n /* eslint-disable require-await */\n static async createProgramAddress(\n seeds: Array,\n programId: PublicKey,\n ): Promise {\n return this.createProgramAddressSync(seeds, programId);\n }\n\n /**\n * Find a valid program address\n *\n * Valid program addresses must fall off the ed25519 curve. This function\n * iterates a nonce until it finds one that when combined with the seeds\n * results in a valid program address.\n */\n static findProgramAddressSync(\n seeds: Array,\n programId: PublicKey,\n ): [PublicKey, number] {\n let nonce = 255;\n let address;\n while (nonce != 0) {\n try {\n const seedsWithNonce = seeds.concat(Buffer.from([nonce]));\n address = this.createProgramAddressSync(seedsWithNonce, programId);\n } catch (err) {\n if (err instanceof TypeError) {\n throw err;\n }\n nonce--;\n continue;\n }\n return [address, nonce];\n }\n throw new Error(`Unable to find a viable program address nonce`);\n }\n\n /**\n * Async version of findProgramAddressSync\n * For backwards compatibility\n *\n * @deprecated Use {@link findProgramAddressSync} instead\n */\n static async findProgramAddress(\n seeds: Array,\n programId: PublicKey,\n ): Promise<[PublicKey, number]> {\n return this.findProgramAddressSync(seeds, programId);\n }\n\n /**\n * Check that a pubkey is on the ed25519 curve.\n */\n static isOnCurve(pubkeyData: PublicKeyInitData): boolean {\n const pubkey = new PublicKey(pubkeyData);\n return isOnCurve(pubkey.toBytes());\n }\n}\n\nSOLANA_SCHEMA.set(PublicKey, {\n kind: 'struct',\n fields: [['_bn', 'u256']],\n});\n","import {Buffer} from 'buffer';\n\nimport {generatePrivateKey, getPublicKey} from './utils/ed25519';\nimport {toBuffer} from './utils/to-buffer';\nimport {PublicKey} from './publickey';\n\n/**\n * An account key pair (public and secret keys).\n *\n * @deprecated since v1.10.0, please use {@link Keypair} instead.\n */\nexport class Account {\n /** @internal */\n private _publicKey: Buffer;\n /** @internal */\n private _secretKey: Buffer;\n\n /**\n * Create a new Account object\n *\n * If the secretKey parameter is not provided a new key pair is randomly\n * created for the account\n *\n * @param secretKey Secret key for the account\n */\n constructor(secretKey?: Uint8Array | Array) {\n if (secretKey) {\n const secretKeyBuffer = toBuffer(secretKey);\n if (secretKey.length !== 64) {\n throw new Error('bad secret key size');\n }\n this._publicKey = secretKeyBuffer.slice(32, 64);\n this._secretKey = secretKeyBuffer.slice(0, 32);\n } else {\n this._secretKey = toBuffer(generatePrivateKey());\n this._publicKey = toBuffer(getPublicKey(this._secretKey));\n }\n }\n\n /**\n * The public key for this account\n */\n get publicKey(): PublicKey {\n return new PublicKey(this._publicKey);\n }\n\n /**\n * The **unencrypted** secret key for this account. The first 32 bytes\n * is the private scalar and the last 32 bytes is the public key.\n * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/\n */\n get secretKey(): Buffer {\n return Buffer.concat([this._secretKey, this._publicKey], 64);\n }\n}\n","import {PublicKey} from './publickey';\n\nexport const BPF_LOADER_DEPRECATED_PROGRAM_ID = new PublicKey(\n 'BPFLoader1111111111111111111111111111111111',\n);\n","/**\n * Maximum over-the-wire size of a Transaction\n *\n * 1280 is IPv6 minimum MTU\n * 40 bytes is the size of the IPv6 header\n * 8 bytes is the size of the fragment header\n */\nexport const PACKET_DATA_SIZE = 1280 - 40 - 8;\n\nexport const VERSION_PREFIX_MASK = 0x7f;\n\nexport const SIGNATURE_LENGTH_IN_BYTES = 64;\n","export class TransactionExpiredBlockheightExceededError extends Error {\n signature: string;\n\n constructor(signature: string) {\n super(`Signature ${signature} has expired: block height exceeded.`);\n this.signature = signature;\n }\n}\n\nObject.defineProperty(\n TransactionExpiredBlockheightExceededError.prototype,\n 'name',\n {\n value: 'TransactionExpiredBlockheightExceededError',\n },\n);\n\nexport class TransactionExpiredTimeoutError extends Error {\n signature: string;\n\n constructor(signature: string, timeoutSeconds: number) {\n super(\n `Transaction was not confirmed in ${timeoutSeconds.toFixed(\n 2,\n )} seconds. It is ` +\n 'unknown if it succeeded or failed. Check signature ' +\n `${signature} using the Solana Explorer or CLI tools.`,\n );\n this.signature = signature;\n }\n}\n\nObject.defineProperty(TransactionExpiredTimeoutError.prototype, 'name', {\n value: 'TransactionExpiredTimeoutError',\n});\n\nexport class TransactionExpiredNonceInvalidError extends Error {\n signature: string;\n\n constructor(signature: string) {\n super(`Signature ${signature} has expired: the nonce is no longer valid.`);\n this.signature = signature;\n }\n}\n\nObject.defineProperty(TransactionExpiredNonceInvalidError.prototype, 'name', {\n value: 'TransactionExpiredNonceInvalidError',\n});\n","import {LoadedAddresses} from '../connection';\nimport {PublicKey} from '../publickey';\nimport {TransactionInstruction} from '../transaction';\nimport {MessageCompiledInstruction} from './index';\n\nexport type AccountKeysFromLookups = LoadedAddresses;\n\nexport class MessageAccountKeys {\n staticAccountKeys: Array;\n accountKeysFromLookups?: AccountKeysFromLookups;\n\n constructor(\n staticAccountKeys: Array,\n accountKeysFromLookups?: AccountKeysFromLookups,\n ) {\n this.staticAccountKeys = staticAccountKeys;\n this.accountKeysFromLookups = accountKeysFromLookups;\n }\n\n keySegments(): Array> {\n const keySegments = [this.staticAccountKeys];\n if (this.accountKeysFromLookups) {\n keySegments.push(this.accountKeysFromLookups.writable);\n keySegments.push(this.accountKeysFromLookups.readonly);\n }\n return keySegments;\n }\n\n get(index: number): PublicKey | undefined {\n for (const keySegment of this.keySegments()) {\n if (index < keySegment.length) {\n return keySegment[index];\n } else {\n index -= keySegment.length;\n }\n }\n return;\n }\n\n get length(): number {\n return this.keySegments().flat().length;\n }\n\n compileInstructions(\n instructions: Array,\n ): Array {\n // Bail early if any account indexes would overflow a u8\n const U8_MAX = 255;\n if (this.length > U8_MAX + 1) {\n throw new Error('Account index overflow encountered during compilation');\n }\n\n const keyIndexMap = new Map();\n this.keySegments()\n .flat()\n .forEach((key, index) => {\n keyIndexMap.set(key.toBase58(), index);\n });\n\n const findKeyIndex = (key: PublicKey) => {\n const keyIndex = keyIndexMap.get(key.toBase58());\n if (keyIndex === undefined)\n throw new Error(\n 'Encountered an unknown instruction account key during compilation',\n );\n return keyIndex;\n };\n\n return instructions.map((instruction): MessageCompiledInstruction => {\n return {\n programIdIndex: findKeyIndex(instruction.programId),\n accountKeyIndexes: instruction.keys.map(meta =>\n findKeyIndex(meta.pubkey),\n ),\n data: instruction.data,\n };\n });\n }\n}\n","import {Buffer} from 'buffer';\nimport * as BufferLayout from '@solana/buffer-layout';\n\nimport {VoteAuthorizeWithSeedArgs} from './programs/vote';\n\n/**\n * Layout for a public key\n */\nexport const publicKey = (property: string = 'publicKey') => {\n return BufferLayout.blob(32, property);\n};\n\n/**\n * Layout for a signature\n */\nexport const signature = (property: string = 'signature') => {\n return BufferLayout.blob(64, property);\n};\n\n/**\n * Layout for a 64bit unsigned value\n */\nexport const uint64 = (property: string = 'uint64') => {\n return BufferLayout.blob(8, property);\n};\n\ninterface IRustStringShim\n extends Omit<\n BufferLayout.Structure<\n Readonly<{\n length: number;\n lengthPadding: number;\n chars: Uint8Array;\n }>\n >,\n 'decode' | 'encode' | 'replicate'\n > {\n alloc: (str: string) => number;\n decode: (b: Uint8Array, offset?: number) => string;\n encode: (str: string, b: Uint8Array, offset?: number) => number;\n replicate: (property: string) => this;\n}\n\n/**\n * Layout for a Rust String type\n */\nexport const rustString = (\n property: string = 'string',\n): BufferLayout.Layout => {\n const rsl = BufferLayout.struct<\n Readonly<{\n length?: number;\n lengthPadding?: number;\n chars: Uint8Array;\n }>\n >(\n [\n BufferLayout.u32('length'),\n BufferLayout.u32('lengthPadding'),\n BufferLayout.blob(BufferLayout.offset(BufferLayout.u32(), -8), 'chars'),\n ],\n property,\n );\n const _decode = rsl.decode.bind(rsl);\n const _encode = rsl.encode.bind(rsl);\n\n const rslShim = rsl as unknown as IRustStringShim;\n\n rslShim.decode = (b: Uint8Array, offset?: number) => {\n const data = _decode(b, offset);\n return data['chars'].toString();\n };\n\n rslShim.encode = (str: string, b: Uint8Array, offset?: number) => {\n const data = {\n chars: Buffer.from(str, 'utf8'),\n };\n return _encode(data, b, offset);\n };\n\n rslShim.alloc = (str: string) => {\n return (\n BufferLayout.u32().span +\n BufferLayout.u32().span +\n Buffer.from(str, 'utf8').length\n );\n };\n\n return rslShim;\n};\n\n/**\n * Layout for an Authorized object\n */\nexport const authorized = (property: string = 'authorized') => {\n return BufferLayout.struct<\n Readonly<{\n staker: Uint8Array;\n withdrawer: Uint8Array;\n }>\n >([publicKey('staker'), publicKey('withdrawer')], property);\n};\n\n/**\n * Layout for a Lockup object\n */\nexport const lockup = (property: string = 'lockup') => {\n return BufferLayout.struct<\n Readonly<{\n custodian: Uint8Array;\n epoch: number;\n unixTimestamp: number;\n }>\n >(\n [\n BufferLayout.ns64('unixTimestamp'),\n BufferLayout.ns64('epoch'),\n publicKey('custodian'),\n ],\n property,\n );\n};\n\n/**\n * Layout for a VoteInit object\n */\nexport const voteInit = (property: string = 'voteInit') => {\n return BufferLayout.struct<\n Readonly<{\n authorizedVoter: Uint8Array;\n authorizedWithdrawer: Uint8Array;\n commission: number;\n nodePubkey: Uint8Array;\n }>\n >(\n [\n publicKey('nodePubkey'),\n publicKey('authorizedVoter'),\n publicKey('authorizedWithdrawer'),\n BufferLayout.u8('commission'),\n ],\n property,\n );\n};\n\n/**\n * Layout for a VoteAuthorizeWithSeedArgs object\n */\nexport const voteAuthorizeWithSeedArgs = (\n property: string = 'voteAuthorizeWithSeedArgs',\n) => {\n return BufferLayout.struct(\n [\n BufferLayout.u32('voteAuthorizationType'),\n publicKey('currentAuthorityDerivedKeyOwnerPubkey'),\n rustString('currentAuthorityDerivedKeySeed'),\n publicKey('newAuthorized'),\n ],\n property,\n );\n};\n\nexport function getAlloc(type: any, fields: any): number {\n const getItemAlloc = (item: any): number => {\n if (item.span >= 0) {\n return item.span;\n } else if (typeof item.alloc === 'function') {\n return item.alloc(fields[item.property]);\n } else if ('count' in item && 'elementLayout' in item) {\n const field = fields[item.property];\n if (Array.isArray(field)) {\n return field.length * getItemAlloc(item.elementLayout);\n }\n } else if ('fields' in item) {\n // This is a `Structure` whose size needs to be recursively measured.\n return getAlloc({layout: item}, fields[item.property]);\n }\n // Couldn't determine allocated size of layout\n return 0;\n };\n\n let alloc = 0;\n type.layout.fields.forEach((item: any) => {\n alloc += getItemAlloc(item);\n });\n\n return alloc;\n}\n","export function decodeLength(bytes: Array): number {\n let len = 0;\n let size = 0;\n for (;;) {\n let elem = bytes.shift() as number;\n len |= (elem & 0x7f) << (size * 7);\n size += 1;\n if ((elem & 0x80) === 0) {\n break;\n }\n }\n return len;\n}\n\nexport function encodeLength(bytes: Array, len: number) {\n let rem_len = len;\n for (;;) {\n let elem = rem_len & 0x7f;\n rem_len >>= 7;\n if (rem_len == 0) {\n bytes.push(elem);\n break;\n } else {\n elem |= 0x80;\n bytes.push(elem);\n }\n }\n}\n","export default function (\n condition: unknown,\n message?: string,\n): asserts condition {\n if (!condition) {\n throw new Error(message || 'Assertion failed');\n }\n}\n","import {MessageHeader, MessageAddressTableLookup} from './index';\nimport {AccountKeysFromLookups} from './account-keys';\nimport {AddressLookupTableAccount} from '../programs';\nimport {TransactionInstruction} from '../transaction';\nimport assert from '../utils/assert';\nimport {PublicKey} from '../publickey';\n\nexport type CompiledKeyMeta = {\n isSigner: boolean;\n isWritable: boolean;\n isInvoked: boolean;\n};\n\ntype KeyMetaMap = Map;\n\nexport class CompiledKeys {\n payer: PublicKey;\n keyMetaMap: KeyMetaMap;\n\n constructor(payer: PublicKey, keyMetaMap: KeyMetaMap) {\n this.payer = payer;\n this.keyMetaMap = keyMetaMap;\n }\n\n static compile(\n instructions: Array,\n payer: PublicKey,\n ): CompiledKeys {\n const keyMetaMap: KeyMetaMap = new Map();\n const getOrInsertDefault = (pubkey: PublicKey): CompiledKeyMeta => {\n const address = pubkey.toBase58();\n let keyMeta = keyMetaMap.get(address);\n if (keyMeta === undefined) {\n keyMeta = {\n isSigner: false,\n isWritable: false,\n isInvoked: false,\n };\n keyMetaMap.set(address, keyMeta);\n }\n return keyMeta;\n };\n\n const payerKeyMeta = getOrInsertDefault(payer);\n payerKeyMeta.isSigner = true;\n payerKeyMeta.isWritable = true;\n\n for (const ix of instructions) {\n getOrInsertDefault(ix.programId).isInvoked = true;\n for (const accountMeta of ix.keys) {\n const keyMeta = getOrInsertDefault(accountMeta.pubkey);\n keyMeta.isSigner ||= accountMeta.isSigner;\n keyMeta.isWritable ||= accountMeta.isWritable;\n }\n }\n\n return new CompiledKeys(payer, keyMetaMap);\n }\n\n getMessageComponents(): [MessageHeader, Array] {\n const mapEntries = [...this.keyMetaMap.entries()];\n assert(mapEntries.length <= 256, 'Max static account keys length exceeded');\n\n const writableSigners = mapEntries.filter(\n ([, meta]) => meta.isSigner && meta.isWritable,\n );\n const readonlySigners = mapEntries.filter(\n ([, meta]) => meta.isSigner && !meta.isWritable,\n );\n const writableNonSigners = mapEntries.filter(\n ([, meta]) => !meta.isSigner && meta.isWritable,\n );\n const readonlyNonSigners = mapEntries.filter(\n ([, meta]) => !meta.isSigner && !meta.isWritable,\n );\n\n const header: MessageHeader = {\n numRequiredSignatures: writableSigners.length + readonlySigners.length,\n numReadonlySignedAccounts: readonlySigners.length,\n numReadonlyUnsignedAccounts: readonlyNonSigners.length,\n };\n\n // sanity checks\n {\n assert(\n writableSigners.length > 0,\n 'Expected at least one writable signer key',\n );\n const [payerAddress] = writableSigners[0];\n assert(\n payerAddress === this.payer.toBase58(),\n 'Expected first writable signer key to be the fee payer',\n );\n }\n\n const staticAccountKeys = [\n ...writableSigners.map(([address]) => new PublicKey(address)),\n ...readonlySigners.map(([address]) => new PublicKey(address)),\n ...writableNonSigners.map(([address]) => new PublicKey(address)),\n ...readonlyNonSigners.map(([address]) => new PublicKey(address)),\n ];\n\n return [header, staticAccountKeys];\n }\n\n extractTableLookup(\n lookupTable: AddressLookupTableAccount,\n ): [MessageAddressTableLookup, AccountKeysFromLookups] | undefined {\n const [writableIndexes, drainedWritableKeys] =\n this.drainKeysFoundInLookupTable(\n lookupTable.state.addresses,\n keyMeta =>\n !keyMeta.isSigner && !keyMeta.isInvoked && keyMeta.isWritable,\n );\n const [readonlyIndexes, drainedReadonlyKeys] =\n this.drainKeysFoundInLookupTable(\n lookupTable.state.addresses,\n keyMeta =>\n !keyMeta.isSigner && !keyMeta.isInvoked && !keyMeta.isWritable,\n );\n\n // Don't extract lookup if no keys were found\n if (writableIndexes.length === 0 && readonlyIndexes.length === 0) {\n return;\n }\n\n return [\n {\n accountKey: lookupTable.key,\n writableIndexes,\n readonlyIndexes,\n },\n {\n writable: drainedWritableKeys,\n readonly: drainedReadonlyKeys,\n },\n ];\n }\n\n /** @internal */\n private drainKeysFoundInLookupTable(\n lookupTableEntries: Array,\n keyMetaFilter: (keyMeta: CompiledKeyMeta) => boolean,\n ): [Array, Array] {\n const lookupTableIndexes = new Array();\n const drainedKeys = new Array();\n\n for (const [address, keyMeta] of this.keyMetaMap.entries()) {\n if (keyMetaFilter(keyMeta)) {\n const key = new PublicKey(address);\n const lookupTableIndex = lookupTableEntries.findIndex(entry =>\n entry.equals(key),\n );\n if (lookupTableIndex >= 0) {\n assert(lookupTableIndex < 256, 'Max lookup table index exceeded');\n lookupTableIndexes.push(lookupTableIndex);\n drainedKeys.push(key);\n this.keyMetaMap.delete(address);\n }\n }\n }\n\n return [lookupTableIndexes, drainedKeys];\n }\n}\n","const END_OF_BUFFER_ERROR_MESSAGE = 'Reached end of buffer unexpectedly';\n\n/**\n * Delegates to `Array#shift`, but throws if the array is zero-length.\n */\nexport function guardedShift(byteArray: T[]): T {\n if (byteArray.length === 0) {\n throw new Error(END_OF_BUFFER_ERROR_MESSAGE);\n }\n return byteArray.shift() as T;\n}\n\n/**\n * Delegates to `Array#splice`, but throws if the section being spliced out extends past the end of\n * the array.\n */\nexport function guardedSplice(\n byteArray: T[],\n ...args:\n | [start: number, deleteCount?: number]\n | [start: number, deleteCount: number, ...items: T[]]\n): T[] {\n const [start] = args;\n if (\n args.length === 2 // Implies that `deleteCount` was supplied\n ? start + (args[1] ?? 0) > byteArray.length\n : start >= byteArray.length\n ) {\n throw new Error(END_OF_BUFFER_ERROR_MESSAGE);\n }\n return byteArray.splice(\n ...(args as Parameters),\n );\n}\n","import bs58 from 'bs58';\nimport {Buffer} from 'buffer';\nimport * as BufferLayout from '@solana/buffer-layout';\n\nimport {PublicKey, PUBLIC_KEY_LENGTH} from '../publickey';\nimport type {Blockhash} from '../blockhash';\nimport * as Layout from '../layout';\nimport {PACKET_DATA_SIZE, VERSION_PREFIX_MASK} from '../transaction/constants';\nimport * as shortvec from '../utils/shortvec-encoding';\nimport {toBuffer} from '../utils/to-buffer';\nimport {\n MessageHeader,\n MessageAddressTableLookup,\n MessageCompiledInstruction,\n} from './index';\nimport {TransactionInstruction} from '../transaction';\nimport {CompiledKeys} from './compiled-keys';\nimport {MessageAccountKeys} from './account-keys';\nimport {guardedShift, guardedSplice} from '../utils/guarded-array-utils';\n\n/**\n * An instruction to execute by a program\n *\n * @property {number} programIdIndex\n * @property {number[]} accounts\n * @property {string} data\n */\nexport type CompiledInstruction = {\n /** Index into the transaction keys array indicating the program account that executes this instruction */\n programIdIndex: number;\n /** Ordered indices into the transaction keys array indicating which accounts to pass to the program */\n accounts: number[];\n /** The program input data encoded as base 58 */\n data: string;\n};\n\n/**\n * Message constructor arguments\n */\nexport type MessageArgs = {\n /** The message header, identifying signed and read-only `accountKeys` */\n header: MessageHeader;\n /** All the account keys used by this transaction */\n accountKeys: string[] | PublicKey[];\n /** The hash of a recent ledger block */\n recentBlockhash: Blockhash;\n /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */\n instructions: CompiledInstruction[];\n};\n\nexport type CompileLegacyArgs = {\n payerKey: PublicKey;\n instructions: Array;\n recentBlockhash: Blockhash;\n};\n\n/**\n * List of instructions to be processed atomically\n */\nexport class Message {\n header: MessageHeader;\n accountKeys: PublicKey[];\n recentBlockhash: Blockhash;\n instructions: CompiledInstruction[];\n\n private indexToProgramIds: Map = new Map<\n number,\n PublicKey\n >();\n\n constructor(args: MessageArgs) {\n this.header = args.header;\n this.accountKeys = args.accountKeys.map(account => new PublicKey(account));\n this.recentBlockhash = args.recentBlockhash;\n this.instructions = args.instructions;\n this.instructions.forEach(ix =>\n this.indexToProgramIds.set(\n ix.programIdIndex,\n this.accountKeys[ix.programIdIndex],\n ),\n );\n }\n\n get version(): 'legacy' {\n return 'legacy';\n }\n\n get staticAccountKeys(): Array {\n return this.accountKeys;\n }\n\n get compiledInstructions(): Array {\n return this.instructions.map(\n (ix): MessageCompiledInstruction => ({\n programIdIndex: ix.programIdIndex,\n accountKeyIndexes: ix.accounts,\n data: bs58.decode(ix.data),\n }),\n );\n }\n\n get addressTableLookups(): Array {\n return [];\n }\n\n getAccountKeys(): MessageAccountKeys {\n return new MessageAccountKeys(this.staticAccountKeys);\n }\n\n static compile(args: CompileLegacyArgs): Message {\n const compiledKeys = CompiledKeys.compile(args.instructions, args.payerKey);\n const [header, staticAccountKeys] = compiledKeys.getMessageComponents();\n const accountKeys = new MessageAccountKeys(staticAccountKeys);\n const instructions = accountKeys.compileInstructions(args.instructions).map(\n (ix: MessageCompiledInstruction): CompiledInstruction => ({\n programIdIndex: ix.programIdIndex,\n accounts: ix.accountKeyIndexes,\n data: bs58.encode(ix.data),\n }),\n );\n return new Message({\n header,\n accountKeys: staticAccountKeys,\n recentBlockhash: args.recentBlockhash,\n instructions,\n });\n }\n\n isAccountSigner(index: number): boolean {\n return index < this.header.numRequiredSignatures;\n }\n\n isAccountWritable(index: number): boolean {\n const numSignedAccounts = this.header.numRequiredSignatures;\n if (index >= this.header.numRequiredSignatures) {\n const unsignedAccountIndex = index - numSignedAccounts;\n const numUnsignedAccounts = this.accountKeys.length - numSignedAccounts;\n const numWritableUnsignedAccounts =\n numUnsignedAccounts - this.header.numReadonlyUnsignedAccounts;\n return unsignedAccountIndex < numWritableUnsignedAccounts;\n } else {\n const numWritableSignedAccounts =\n numSignedAccounts - this.header.numReadonlySignedAccounts;\n return index < numWritableSignedAccounts;\n }\n }\n\n isProgramId(index: number): boolean {\n return this.indexToProgramIds.has(index);\n }\n\n programIds(): PublicKey[] {\n return [...this.indexToProgramIds.values()];\n }\n\n nonProgramIds(): PublicKey[] {\n return this.accountKeys.filter((_, index) => !this.isProgramId(index));\n }\n\n serialize(): Buffer {\n const numKeys = this.accountKeys.length;\n\n let keyCount: number[] = [];\n shortvec.encodeLength(keyCount, numKeys);\n\n const instructions = this.instructions.map(instruction => {\n const {accounts, programIdIndex} = instruction;\n const data = Array.from(bs58.decode(instruction.data));\n\n let keyIndicesCount: number[] = [];\n shortvec.encodeLength(keyIndicesCount, accounts.length);\n\n let dataCount: number[] = [];\n shortvec.encodeLength(dataCount, data.length);\n\n return {\n programIdIndex,\n keyIndicesCount: Buffer.from(keyIndicesCount),\n keyIndices: accounts,\n dataLength: Buffer.from(dataCount),\n data,\n };\n });\n\n let instructionCount: number[] = [];\n shortvec.encodeLength(instructionCount, instructions.length);\n let instructionBuffer = Buffer.alloc(PACKET_DATA_SIZE);\n Buffer.from(instructionCount).copy(instructionBuffer);\n let instructionBufferLength = instructionCount.length;\n\n instructions.forEach(instruction => {\n const instructionLayout = BufferLayout.struct<\n Readonly<{\n data: number[];\n dataLength: Uint8Array;\n keyIndices: number[];\n keyIndicesCount: Uint8Array;\n programIdIndex: number;\n }>\n >([\n BufferLayout.u8('programIdIndex'),\n\n BufferLayout.blob(\n instruction.keyIndicesCount.length,\n 'keyIndicesCount',\n ),\n BufferLayout.seq(\n BufferLayout.u8('keyIndex'),\n instruction.keyIndices.length,\n 'keyIndices',\n ),\n BufferLayout.blob(instruction.dataLength.length, 'dataLength'),\n BufferLayout.seq(\n BufferLayout.u8('userdatum'),\n instruction.data.length,\n 'data',\n ),\n ]);\n const length = instructionLayout.encode(\n instruction,\n instructionBuffer,\n instructionBufferLength,\n );\n instructionBufferLength += length;\n });\n instructionBuffer = instructionBuffer.slice(0, instructionBufferLength);\n\n const signDataLayout = BufferLayout.struct<\n Readonly<{\n keyCount: Uint8Array;\n keys: Uint8Array[];\n numReadonlySignedAccounts: Uint8Array;\n numReadonlyUnsignedAccounts: Uint8Array;\n numRequiredSignatures: Uint8Array;\n recentBlockhash: Uint8Array;\n }>\n >([\n BufferLayout.blob(1, 'numRequiredSignatures'),\n BufferLayout.blob(1, 'numReadonlySignedAccounts'),\n BufferLayout.blob(1, 'numReadonlyUnsignedAccounts'),\n BufferLayout.blob(keyCount.length, 'keyCount'),\n BufferLayout.seq(Layout.publicKey('key'), numKeys, 'keys'),\n Layout.publicKey('recentBlockhash'),\n ]);\n\n const transaction = {\n numRequiredSignatures: Buffer.from([this.header.numRequiredSignatures]),\n numReadonlySignedAccounts: Buffer.from([\n this.header.numReadonlySignedAccounts,\n ]),\n numReadonlyUnsignedAccounts: Buffer.from([\n this.header.numReadonlyUnsignedAccounts,\n ]),\n keyCount: Buffer.from(keyCount),\n keys: this.accountKeys.map(key => toBuffer(key.toBytes())),\n recentBlockhash: bs58.decode(this.recentBlockhash),\n };\n\n let signData = Buffer.alloc(2048);\n const length = signDataLayout.encode(transaction, signData);\n instructionBuffer.copy(signData, length);\n return signData.slice(0, length + instructionBuffer.length);\n }\n\n /**\n * Decode a compiled message into a Message object.\n */\n static from(buffer: Buffer | Uint8Array | Array): Message {\n // Slice up wire data\n let byteArray = [...buffer];\n\n const numRequiredSignatures = guardedShift(byteArray);\n if (\n numRequiredSignatures !==\n (numRequiredSignatures & VERSION_PREFIX_MASK)\n ) {\n throw new Error(\n 'Versioned messages must be deserialized with VersionedMessage.deserialize()',\n );\n }\n\n const numReadonlySignedAccounts = guardedShift(byteArray);\n const numReadonlyUnsignedAccounts = guardedShift(byteArray);\n\n const accountCount = shortvec.decodeLength(byteArray);\n let accountKeys = [];\n for (let i = 0; i < accountCount; i++) {\n const account = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);\n accountKeys.push(new PublicKey(Buffer.from(account)));\n }\n\n const recentBlockhash = guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH);\n\n const instructionCount = shortvec.decodeLength(byteArray);\n let instructions: CompiledInstruction[] = [];\n for (let i = 0; i < instructionCount; i++) {\n const programIdIndex = guardedShift(byteArray);\n const accountCount = shortvec.decodeLength(byteArray);\n const accounts = guardedSplice(byteArray, 0, accountCount);\n const dataLength = shortvec.decodeLength(byteArray);\n const dataSlice = guardedSplice(byteArray, 0, dataLength);\n const data = bs58.encode(Buffer.from(dataSlice));\n instructions.push({\n programIdIndex,\n accounts,\n data,\n });\n }\n\n const messageArgs = {\n header: {\n numRequiredSignatures,\n numReadonlySignedAccounts,\n numReadonlyUnsignedAccounts,\n },\n recentBlockhash: bs58.encode(Buffer.from(recentBlockhash)),\n accountKeys,\n instructions,\n };\n\n return new Message(messageArgs);\n }\n}\n","import bs58 from 'bs58';\nimport * as BufferLayout from '@solana/buffer-layout';\n\nimport * as Layout from '../layout';\nimport {Blockhash} from '../blockhash';\nimport {\n MessageHeader,\n MessageAddressTableLookup,\n MessageCompiledInstruction,\n} from './index';\nimport {PublicKey, PUBLIC_KEY_LENGTH} from '../publickey';\nimport * as shortvec from '../utils/shortvec-encoding';\nimport assert from '../utils/assert';\nimport {PACKET_DATA_SIZE, VERSION_PREFIX_MASK} from '../transaction/constants';\nimport {TransactionInstruction} from '../transaction';\nimport {AddressLookupTableAccount} from '../programs';\nimport {CompiledKeys} from './compiled-keys';\nimport {AccountKeysFromLookups, MessageAccountKeys} from './account-keys';\nimport {guardedShift, guardedSplice} from '../utils/guarded-array-utils';\n\n/**\n * Message constructor arguments\n */\nexport type MessageV0Args = {\n /** The message header, identifying signed and read-only `accountKeys` */\n header: MessageHeader;\n /** The static account keys used by this transaction */\n staticAccountKeys: PublicKey[];\n /** The hash of a recent ledger block */\n recentBlockhash: Blockhash;\n /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */\n compiledInstructions: MessageCompiledInstruction[];\n /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */\n addressTableLookups: MessageAddressTableLookup[];\n};\n\nexport type CompileV0Args = {\n payerKey: PublicKey;\n instructions: Array;\n recentBlockhash: Blockhash;\n addressLookupTableAccounts?: Array;\n};\n\nexport type GetAccountKeysArgs =\n | {\n accountKeysFromLookups?: AccountKeysFromLookups | null;\n }\n | {\n addressLookupTableAccounts?: AddressLookupTableAccount[] | null;\n };\n\nexport class MessageV0 {\n header: MessageHeader;\n staticAccountKeys: Array;\n recentBlockhash: Blockhash;\n compiledInstructions: Array;\n addressTableLookups: Array;\n\n constructor(args: MessageV0Args) {\n this.header = args.header;\n this.staticAccountKeys = args.staticAccountKeys;\n this.recentBlockhash = args.recentBlockhash;\n this.compiledInstructions = args.compiledInstructions;\n this.addressTableLookups = args.addressTableLookups;\n }\n\n get version(): 0 {\n return 0;\n }\n\n get numAccountKeysFromLookups(): number {\n let count = 0;\n for (const lookup of this.addressTableLookups) {\n count += lookup.readonlyIndexes.length + lookup.writableIndexes.length;\n }\n return count;\n }\n\n getAccountKeys(args?: GetAccountKeysArgs): MessageAccountKeys {\n let accountKeysFromLookups: AccountKeysFromLookups | undefined;\n if (\n args &&\n 'accountKeysFromLookups' in args &&\n args.accountKeysFromLookups\n ) {\n if (\n this.numAccountKeysFromLookups !=\n args.accountKeysFromLookups.writable.length +\n args.accountKeysFromLookups.readonly.length\n ) {\n throw new Error(\n 'Failed to get account keys because of a mismatch in the number of account keys from lookups',\n );\n }\n accountKeysFromLookups = args.accountKeysFromLookups;\n } else if (\n args &&\n 'addressLookupTableAccounts' in args &&\n args.addressLookupTableAccounts\n ) {\n accountKeysFromLookups = this.resolveAddressTableLookups(\n args.addressLookupTableAccounts,\n );\n } else if (this.addressTableLookups.length > 0) {\n throw new Error(\n 'Failed to get account keys because address table lookups were not resolved',\n );\n }\n return new MessageAccountKeys(\n this.staticAccountKeys,\n accountKeysFromLookups,\n );\n }\n\n isAccountSigner(index: number): boolean {\n return index < this.header.numRequiredSignatures;\n }\n\n isAccountWritable(index: number): boolean {\n const numSignedAccounts = this.header.numRequiredSignatures;\n const numStaticAccountKeys = this.staticAccountKeys.length;\n if (index >= numStaticAccountKeys) {\n const lookupAccountKeysIndex = index - numStaticAccountKeys;\n const numWritableLookupAccountKeys = this.addressTableLookups.reduce(\n (count, lookup) => count + lookup.writableIndexes.length,\n 0,\n );\n return lookupAccountKeysIndex < numWritableLookupAccountKeys;\n } else if (index >= this.header.numRequiredSignatures) {\n const unsignedAccountIndex = index - numSignedAccounts;\n const numUnsignedAccounts = numStaticAccountKeys - numSignedAccounts;\n const numWritableUnsignedAccounts =\n numUnsignedAccounts - this.header.numReadonlyUnsignedAccounts;\n return unsignedAccountIndex < numWritableUnsignedAccounts;\n } else {\n const numWritableSignedAccounts =\n numSignedAccounts - this.header.numReadonlySignedAccounts;\n return index < numWritableSignedAccounts;\n }\n }\n\n resolveAddressTableLookups(\n addressLookupTableAccounts: AddressLookupTableAccount[],\n ): AccountKeysFromLookups {\n const accountKeysFromLookups: AccountKeysFromLookups = {\n writable: [],\n readonly: [],\n };\n\n for (const tableLookup of this.addressTableLookups) {\n const tableAccount = addressLookupTableAccounts.find(account =>\n account.key.equals(tableLookup.accountKey),\n );\n if (!tableAccount) {\n throw new Error(\n `Failed to find address lookup table account for table key ${tableLookup.accountKey.toBase58()}`,\n );\n }\n\n for (const index of tableLookup.writableIndexes) {\n if (index < tableAccount.state.addresses.length) {\n accountKeysFromLookups.writable.push(\n tableAccount.state.addresses[index],\n );\n } else {\n throw new Error(\n `Failed to find address for index ${index} in address lookup table ${tableLookup.accountKey.toBase58()}`,\n );\n }\n }\n\n for (const index of tableLookup.readonlyIndexes) {\n if (index < tableAccount.state.addresses.length) {\n accountKeysFromLookups.readonly.push(\n tableAccount.state.addresses[index],\n );\n } else {\n throw new Error(\n `Failed to find address for index ${index} in address lookup table ${tableLookup.accountKey.toBase58()}`,\n );\n }\n }\n }\n\n return accountKeysFromLookups;\n }\n\n static compile(args: CompileV0Args): MessageV0 {\n const compiledKeys = CompiledKeys.compile(args.instructions, args.payerKey);\n\n const addressTableLookups = new Array();\n const accountKeysFromLookups: AccountKeysFromLookups = {\n writable: new Array(),\n readonly: new Array(),\n };\n const lookupTableAccounts = args.addressLookupTableAccounts || [];\n for (const lookupTable of lookupTableAccounts) {\n const extractResult = compiledKeys.extractTableLookup(lookupTable);\n if (extractResult !== undefined) {\n const [addressTableLookup, {writable, readonly}] = extractResult;\n addressTableLookups.push(addressTableLookup);\n accountKeysFromLookups.writable.push(...writable);\n accountKeysFromLookups.readonly.push(...readonly);\n }\n }\n\n const [header, staticAccountKeys] = compiledKeys.getMessageComponents();\n const accountKeys = new MessageAccountKeys(\n staticAccountKeys,\n accountKeysFromLookups,\n );\n const compiledInstructions = accountKeys.compileInstructions(\n args.instructions,\n );\n return new MessageV0({\n header,\n staticAccountKeys,\n recentBlockhash: args.recentBlockhash,\n compiledInstructions,\n addressTableLookups,\n });\n }\n\n serialize(): Uint8Array {\n const encodedStaticAccountKeysLength = Array();\n shortvec.encodeLength(\n encodedStaticAccountKeysLength,\n this.staticAccountKeys.length,\n );\n\n const serializedInstructions = this.serializeInstructions();\n const encodedInstructionsLength = Array();\n shortvec.encodeLength(\n encodedInstructionsLength,\n this.compiledInstructions.length,\n );\n\n const serializedAddressTableLookups = this.serializeAddressTableLookups();\n const encodedAddressTableLookupsLength = Array();\n shortvec.encodeLength(\n encodedAddressTableLookupsLength,\n this.addressTableLookups.length,\n );\n\n const messageLayout = BufferLayout.struct<{\n prefix: number;\n header: MessageHeader;\n staticAccountKeysLength: Uint8Array;\n staticAccountKeys: Array;\n recentBlockhash: Uint8Array;\n instructionsLength: Uint8Array;\n serializedInstructions: Uint8Array;\n addressTableLookupsLength: Uint8Array;\n serializedAddressTableLookups: Uint8Array;\n }>([\n BufferLayout.u8('prefix'),\n BufferLayout.struct(\n [\n BufferLayout.u8('numRequiredSignatures'),\n BufferLayout.u8('numReadonlySignedAccounts'),\n BufferLayout.u8('numReadonlyUnsignedAccounts'),\n ],\n 'header',\n ),\n BufferLayout.blob(\n encodedStaticAccountKeysLength.length,\n 'staticAccountKeysLength',\n ),\n BufferLayout.seq(\n Layout.publicKey(),\n this.staticAccountKeys.length,\n 'staticAccountKeys',\n ),\n Layout.publicKey('recentBlockhash'),\n BufferLayout.blob(encodedInstructionsLength.length, 'instructionsLength'),\n BufferLayout.blob(\n serializedInstructions.length,\n 'serializedInstructions',\n ),\n BufferLayout.blob(\n encodedAddressTableLookupsLength.length,\n 'addressTableLookupsLength',\n ),\n BufferLayout.blob(\n serializedAddressTableLookups.length,\n 'serializedAddressTableLookups',\n ),\n ]);\n\n const serializedMessage = new Uint8Array(PACKET_DATA_SIZE);\n const MESSAGE_VERSION_0_PREFIX = 1 << 7;\n const serializedMessageLength = messageLayout.encode(\n {\n prefix: MESSAGE_VERSION_0_PREFIX,\n header: this.header,\n staticAccountKeysLength: new Uint8Array(encodedStaticAccountKeysLength),\n staticAccountKeys: this.staticAccountKeys.map(key => key.toBytes()),\n recentBlockhash: bs58.decode(this.recentBlockhash),\n instructionsLength: new Uint8Array(encodedInstructionsLength),\n serializedInstructions,\n addressTableLookupsLength: new Uint8Array(\n encodedAddressTableLookupsLength,\n ),\n serializedAddressTableLookups,\n },\n serializedMessage,\n );\n return serializedMessage.slice(0, serializedMessageLength);\n }\n\n private serializeInstructions(): Uint8Array {\n let serializedLength = 0;\n const serializedInstructions = new Uint8Array(PACKET_DATA_SIZE);\n for (const instruction of this.compiledInstructions) {\n const encodedAccountKeyIndexesLength = Array();\n shortvec.encodeLength(\n encodedAccountKeyIndexesLength,\n instruction.accountKeyIndexes.length,\n );\n\n const encodedDataLength = Array();\n shortvec.encodeLength(encodedDataLength, instruction.data.length);\n\n const instructionLayout = BufferLayout.struct<{\n programIdIndex: number;\n encodedAccountKeyIndexesLength: Uint8Array;\n accountKeyIndexes: number[];\n encodedDataLength: Uint8Array;\n data: Uint8Array;\n }>([\n BufferLayout.u8('programIdIndex'),\n BufferLayout.blob(\n encodedAccountKeyIndexesLength.length,\n 'encodedAccountKeyIndexesLength',\n ),\n BufferLayout.seq(\n BufferLayout.u8(),\n instruction.accountKeyIndexes.length,\n 'accountKeyIndexes',\n ),\n BufferLayout.blob(encodedDataLength.length, 'encodedDataLength'),\n BufferLayout.blob(instruction.data.length, 'data'),\n ]);\n\n serializedLength += instructionLayout.encode(\n {\n programIdIndex: instruction.programIdIndex,\n encodedAccountKeyIndexesLength: new Uint8Array(\n encodedAccountKeyIndexesLength,\n ),\n accountKeyIndexes: instruction.accountKeyIndexes,\n encodedDataLength: new Uint8Array(encodedDataLength),\n data: instruction.data,\n },\n serializedInstructions,\n serializedLength,\n );\n }\n\n return serializedInstructions.slice(0, serializedLength);\n }\n\n private serializeAddressTableLookups(): Uint8Array {\n let serializedLength = 0;\n const serializedAddressTableLookups = new Uint8Array(PACKET_DATA_SIZE);\n for (const lookup of this.addressTableLookups) {\n const encodedWritableIndexesLength = Array();\n shortvec.encodeLength(\n encodedWritableIndexesLength,\n lookup.writableIndexes.length,\n );\n\n const encodedReadonlyIndexesLength = Array();\n shortvec.encodeLength(\n encodedReadonlyIndexesLength,\n lookup.readonlyIndexes.length,\n );\n\n const addressTableLookupLayout = BufferLayout.struct<{\n accountKey: Uint8Array;\n encodedWritableIndexesLength: Uint8Array;\n writableIndexes: number[];\n encodedReadonlyIndexesLength: Uint8Array;\n readonlyIndexes: number[];\n }>([\n Layout.publicKey('accountKey'),\n BufferLayout.blob(\n encodedWritableIndexesLength.length,\n 'encodedWritableIndexesLength',\n ),\n BufferLayout.seq(\n BufferLayout.u8(),\n lookup.writableIndexes.length,\n 'writableIndexes',\n ),\n BufferLayout.blob(\n encodedReadonlyIndexesLength.length,\n 'encodedReadonlyIndexesLength',\n ),\n BufferLayout.seq(\n BufferLayout.u8(),\n lookup.readonlyIndexes.length,\n 'readonlyIndexes',\n ),\n ]);\n\n serializedLength += addressTableLookupLayout.encode(\n {\n accountKey: lookup.accountKey.toBytes(),\n encodedWritableIndexesLength: new Uint8Array(\n encodedWritableIndexesLength,\n ),\n writableIndexes: lookup.writableIndexes,\n encodedReadonlyIndexesLength: new Uint8Array(\n encodedReadonlyIndexesLength,\n ),\n readonlyIndexes: lookup.readonlyIndexes,\n },\n serializedAddressTableLookups,\n serializedLength,\n );\n }\n\n return serializedAddressTableLookups.slice(0, serializedLength);\n }\n\n static deserialize(serializedMessage: Uint8Array): MessageV0 {\n let byteArray = [...serializedMessage];\n\n const prefix = guardedShift(byteArray);\n const maskedPrefix = prefix & VERSION_PREFIX_MASK;\n assert(\n prefix !== maskedPrefix,\n `Expected versioned message but received legacy message`,\n );\n\n const version = maskedPrefix;\n assert(\n version === 0,\n `Expected versioned message with version 0 but found version ${version}`,\n );\n\n const header: MessageHeader = {\n numRequiredSignatures: guardedShift(byteArray),\n numReadonlySignedAccounts: guardedShift(byteArray),\n numReadonlyUnsignedAccounts: guardedShift(byteArray),\n };\n\n const staticAccountKeys = [];\n const staticAccountKeysLength = shortvec.decodeLength(byteArray);\n for (let i = 0; i < staticAccountKeysLength; i++) {\n staticAccountKeys.push(\n new PublicKey(guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH)),\n );\n }\n\n const recentBlockhash = bs58.encode(\n guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH),\n );\n\n const instructionCount = shortvec.decodeLength(byteArray);\n const compiledInstructions: MessageCompiledInstruction[] = [];\n for (let i = 0; i < instructionCount; i++) {\n const programIdIndex = guardedShift(byteArray);\n const accountKeyIndexesLength = shortvec.decodeLength(byteArray);\n const accountKeyIndexes = guardedSplice(\n byteArray,\n 0,\n accountKeyIndexesLength,\n );\n const dataLength = shortvec.decodeLength(byteArray);\n const data = new Uint8Array(guardedSplice(byteArray, 0, dataLength));\n compiledInstructions.push({\n programIdIndex,\n accountKeyIndexes,\n data,\n });\n }\n\n const addressTableLookupsCount = shortvec.decodeLength(byteArray);\n const addressTableLookups: MessageAddressTableLookup[] = [];\n for (let i = 0; i < addressTableLookupsCount; i++) {\n const accountKey = new PublicKey(\n guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH),\n );\n const writableIndexesLength = shortvec.decodeLength(byteArray);\n const writableIndexes = guardedSplice(\n byteArray,\n 0,\n writableIndexesLength,\n );\n const readonlyIndexesLength = shortvec.decodeLength(byteArray);\n const readonlyIndexes = guardedSplice(\n byteArray,\n 0,\n readonlyIndexesLength,\n );\n addressTableLookups.push({\n accountKey,\n writableIndexes,\n readonlyIndexes,\n });\n }\n\n return new MessageV0({\n header,\n staticAccountKeys,\n recentBlockhash,\n compiledInstructions,\n addressTableLookups,\n });\n }\n}\n","import {VERSION_PREFIX_MASK} from '../transaction/constants';\nimport {Message} from './legacy';\nimport {MessageV0} from './v0';\n\nexport type VersionedMessage = Message | MessageV0;\n// eslint-disable-next-line no-redeclare\nexport const VersionedMessage = {\n deserializeMessageVersion(serializedMessage: Uint8Array): 'legacy' | number {\n const prefix = serializedMessage[0];\n const maskedPrefix = prefix & VERSION_PREFIX_MASK;\n\n // if the highest bit of the prefix is not set, the message is not versioned\n if (maskedPrefix === prefix) {\n return 'legacy';\n }\n\n // the lower 7 bits of the prefix indicate the message version\n return maskedPrefix;\n },\n\n deserialize: (serializedMessage: Uint8Array): VersionedMessage => {\n const version =\n VersionedMessage.deserializeMessageVersion(serializedMessage);\n if (version === 'legacy') {\n return Message.from(serializedMessage);\n }\n\n if (version === 0) {\n return MessageV0.deserialize(serializedMessage);\n } else {\n throw new Error(\n `Transaction message version ${version} deserialization is not supported`,\n );\n }\n },\n};\n","import bs58 from 'bs58';\nimport {Buffer} from 'buffer';\n\nimport {PACKET_DATA_SIZE, SIGNATURE_LENGTH_IN_BYTES} from './constants';\nimport {Connection} from '../connection';\nimport {Message} from '../message';\nimport {PublicKey} from '../publickey';\nimport * as shortvec from '../utils/shortvec-encoding';\nimport {toBuffer} from '../utils/to-buffer';\nimport invariant from '../utils/assert';\nimport type {Signer} from '../keypair';\nimport type {Blockhash} from '../blockhash';\nimport type {CompiledInstruction} from '../message';\nimport {sign, verify} from '../utils/ed25519';\nimport {guardedSplice} from '../utils/guarded-array-utils';\n\n/** @internal */\ntype MessageSignednessErrors = {\n invalid?: PublicKey[];\n missing?: PublicKey[];\n};\n\n/**\n * Transaction signature as base-58 encoded string\n */\nexport type TransactionSignature = string;\n\nexport const enum TransactionStatus {\n BLOCKHEIGHT_EXCEEDED,\n PROCESSED,\n TIMED_OUT,\n NONCE_INVALID,\n}\n\n/**\n * Default (empty) signature\n */\nconst DEFAULT_SIGNATURE = Buffer.alloc(SIGNATURE_LENGTH_IN_BYTES).fill(0);\n\n/**\n * Account metadata used to define instructions\n */\nexport type AccountMeta = {\n /** An account's public key */\n pubkey: PublicKey;\n /** True if an instruction requires a transaction signature matching `pubkey` */\n isSigner: boolean;\n /** True if the `pubkey` can be loaded as a read-write account. */\n isWritable: boolean;\n};\n\n/**\n * List of TransactionInstruction object fields that may be initialized at construction\n */\nexport type TransactionInstructionCtorFields = {\n keys: Array;\n programId: PublicKey;\n data?: Buffer;\n};\n\n/**\n * Configuration object for Transaction.serialize()\n */\nexport type SerializeConfig = {\n /** Require all transaction signatures be present (default: true) */\n requireAllSignatures?: boolean;\n /** Verify provided signatures (default: true) */\n verifySignatures?: boolean;\n};\n\n/**\n * @internal\n */\nexport interface TransactionInstructionJSON {\n keys: {\n pubkey: string;\n isSigner: boolean;\n isWritable: boolean;\n }[];\n programId: string;\n data: number[];\n}\n\n/**\n * Transaction Instruction class\n */\nexport class TransactionInstruction {\n /**\n * Public keys to include in this transaction\n * Boolean represents whether this pubkey needs to sign the transaction\n */\n keys: Array;\n\n /**\n * Program Id to execute\n */\n programId: PublicKey;\n\n /**\n * Program input\n */\n data: Buffer = Buffer.alloc(0);\n\n constructor(opts: TransactionInstructionCtorFields) {\n this.programId = opts.programId;\n this.keys = opts.keys;\n if (opts.data) {\n this.data = opts.data;\n }\n }\n\n /**\n * @internal\n */\n toJSON(): TransactionInstructionJSON {\n return {\n keys: this.keys.map(({pubkey, isSigner, isWritable}) => ({\n pubkey: pubkey.toJSON(),\n isSigner,\n isWritable,\n })),\n programId: this.programId.toJSON(),\n data: [...this.data],\n };\n }\n}\n\n/**\n * Pair of signature and corresponding public key\n */\nexport type SignaturePubkeyPair = {\n signature: Buffer | null;\n publicKey: PublicKey;\n};\n\n/**\n * List of Transaction object fields that may be initialized at construction\n */\nexport type TransactionCtorFields_DEPRECATED = {\n /** Optional nonce information used for offline nonce'd transactions */\n nonceInfo?: NonceInformation | null;\n /** The transaction fee payer */\n feePayer?: PublicKey | null;\n /** One or more signatures */\n signatures?: Array;\n /** A recent blockhash */\n recentBlockhash?: Blockhash;\n};\n\n// For backward compatibility; an unfortunate consequence of being\n// forced to over-export types by the documentation generator.\n// See https://github.com/solana-labs/solana/pull/25820\nexport type TransactionCtorFields = TransactionCtorFields_DEPRECATED;\n\n/**\n * Blockhash-based transactions have a lifetime that are defined by\n * the blockhash they include. Any transaction whose blockhash is\n * too old will be rejected.\n */\nexport type TransactionBlockhashCtor = {\n /** The transaction fee payer */\n feePayer?: PublicKey | null;\n /** One or more signatures */\n signatures?: Array;\n /** A recent blockhash */\n blockhash: Blockhash;\n /** the last block chain can advance to before tx is declared expired */\n lastValidBlockHeight: number;\n};\n\n/**\n * Use these options to construct a durable nonce transaction.\n */\nexport type TransactionNonceCtor = {\n /** The transaction fee payer */\n feePayer?: PublicKey | null;\n minContextSlot: number;\n nonceInfo: NonceInformation;\n /** One or more signatures */\n signatures?: Array;\n};\n\n/**\n * Nonce information to be used to build an offline Transaction.\n */\nexport type NonceInformation = {\n /** The current blockhash stored in the nonce */\n nonce: Blockhash;\n /** AdvanceNonceAccount Instruction */\n nonceInstruction: TransactionInstruction;\n};\n\n/**\n * @internal\n */\nexport interface TransactionJSON {\n recentBlockhash: string | null;\n feePayer: string | null;\n nonceInfo: {\n nonce: string;\n nonceInstruction: TransactionInstructionJSON;\n } | null;\n instructions: TransactionInstructionJSON[];\n signers: string[];\n}\n\n/**\n * Transaction class\n */\nexport class Transaction {\n /**\n * Signatures for the transaction. Typically created by invoking the\n * `sign()` method\n */\n signatures: Array = [];\n\n /**\n * The first (payer) Transaction signature\n *\n * @returns {Buffer | null} Buffer of payer's signature\n */\n get signature(): Buffer | null {\n if (this.signatures.length > 0) {\n return this.signatures[0].signature;\n }\n return null;\n }\n\n /**\n * The transaction fee payer\n */\n feePayer?: PublicKey;\n\n /**\n * The instructions to atomically execute\n */\n instructions: Array = [];\n\n /**\n * A recent transaction id. Must be populated by the caller\n */\n recentBlockhash?: Blockhash;\n\n /**\n * the last block chain can advance to before tx is declared expired\n * */\n lastValidBlockHeight?: number;\n\n /**\n * Optional Nonce information. If populated, transaction will use a durable\n * Nonce hash instead of a recentBlockhash. Must be populated by the caller\n */\n nonceInfo?: NonceInformation;\n\n /**\n * If this is a nonce transaction this represents the minimum slot from which\n * to evaluate if the nonce has advanced when attempting to confirm the\n * transaction. This protects against a case where the transaction confirmation\n * logic loads the nonce account from an old slot and assumes the mismatch in\n * nonce value implies that the nonce has been advanced.\n */\n minNonceContextSlot?: number;\n\n /**\n * @internal\n */\n _message?: Message;\n\n /**\n * @internal\n */\n _json?: TransactionJSON;\n\n // Construct a transaction with a blockhash and lastValidBlockHeight\n constructor(opts?: TransactionBlockhashCtor);\n\n // Construct a transaction using a durable nonce\n constructor(opts?: TransactionNonceCtor);\n\n /**\n * @deprecated `TransactionCtorFields` has been deprecated and will be removed in a future version.\n * Please supply a `TransactionBlockhashCtor` instead.\n */\n constructor(opts?: TransactionCtorFields_DEPRECATED);\n\n /**\n * Construct an empty Transaction\n */\n constructor(\n opts?:\n | TransactionBlockhashCtor\n | TransactionNonceCtor\n | TransactionCtorFields_DEPRECATED,\n ) {\n if (!opts) {\n return;\n }\n if (opts.feePayer) {\n this.feePayer = opts.feePayer;\n }\n if (opts.signatures) {\n this.signatures = opts.signatures;\n }\n if (Object.prototype.hasOwnProperty.call(opts, 'nonceInfo')) {\n const {minContextSlot, nonceInfo} = opts as TransactionNonceCtor;\n this.minNonceContextSlot = minContextSlot;\n this.nonceInfo = nonceInfo;\n } else if (\n Object.prototype.hasOwnProperty.call(opts, 'lastValidBlockHeight')\n ) {\n const {blockhash, lastValidBlockHeight} =\n opts as TransactionBlockhashCtor;\n this.recentBlockhash = blockhash;\n this.lastValidBlockHeight = lastValidBlockHeight;\n } else {\n const {recentBlockhash, nonceInfo} =\n opts as TransactionCtorFields_DEPRECATED;\n if (nonceInfo) {\n this.nonceInfo = nonceInfo;\n }\n this.recentBlockhash = recentBlockhash;\n }\n }\n\n /**\n * @internal\n */\n toJSON(): TransactionJSON {\n return {\n recentBlockhash: this.recentBlockhash || null,\n feePayer: this.feePayer ? this.feePayer.toJSON() : null,\n nonceInfo: this.nonceInfo\n ? {\n nonce: this.nonceInfo.nonce,\n nonceInstruction: this.nonceInfo.nonceInstruction.toJSON(),\n }\n : null,\n instructions: this.instructions.map(instruction => instruction.toJSON()),\n signers: this.signatures.map(({publicKey}) => {\n return publicKey.toJSON();\n }),\n };\n }\n\n /**\n * Add one or more instructions to this Transaction\n *\n * @param {Array< Transaction | TransactionInstruction | TransactionInstructionCtorFields >} items - Instructions to add to the Transaction\n */\n add(\n ...items: Array<\n Transaction | TransactionInstruction | TransactionInstructionCtorFields\n >\n ): Transaction {\n if (items.length === 0) {\n throw new Error('No instructions');\n }\n\n items.forEach((item: any) => {\n if ('instructions' in item) {\n this.instructions = this.instructions.concat(item.instructions);\n } else if ('data' in item && 'programId' in item && 'keys' in item) {\n this.instructions.push(item);\n } else {\n this.instructions.push(new TransactionInstruction(item));\n }\n });\n return this;\n }\n\n /**\n * Compile transaction data\n */\n compileMessage(): Message {\n if (\n this._message &&\n JSON.stringify(this.toJSON()) === JSON.stringify(this._json)\n ) {\n return this._message;\n }\n\n let recentBlockhash;\n let instructions: TransactionInstruction[];\n if (this.nonceInfo) {\n recentBlockhash = this.nonceInfo.nonce;\n if (this.instructions[0] != this.nonceInfo.nonceInstruction) {\n instructions = [this.nonceInfo.nonceInstruction, ...this.instructions];\n } else {\n instructions = this.instructions;\n }\n } else {\n recentBlockhash = this.recentBlockhash;\n instructions = this.instructions;\n }\n if (!recentBlockhash) {\n throw new Error('Transaction recentBlockhash required');\n }\n\n if (instructions.length < 1) {\n console.warn('No instructions provided');\n }\n\n let feePayer: PublicKey;\n if (this.feePayer) {\n feePayer = this.feePayer;\n } else if (this.signatures.length > 0 && this.signatures[0].publicKey) {\n // Use implicit fee payer\n feePayer = this.signatures[0].publicKey;\n } else {\n throw new Error('Transaction fee payer required');\n }\n\n for (let i = 0; i < instructions.length; i++) {\n if (instructions[i].programId === undefined) {\n throw new Error(\n `Transaction instruction index ${i} has undefined program id`,\n );\n }\n }\n\n const programIds: string[] = [];\n const accountMetas: AccountMeta[] = [];\n instructions.forEach(instruction => {\n instruction.keys.forEach(accountMeta => {\n accountMetas.push({...accountMeta});\n });\n\n const programId = instruction.programId.toString();\n if (!programIds.includes(programId)) {\n programIds.push(programId);\n }\n });\n\n // Append programID account metas\n programIds.forEach(programId => {\n accountMetas.push({\n pubkey: new PublicKey(programId),\n isSigner: false,\n isWritable: false,\n });\n });\n\n // Cull duplicate account metas\n const uniqueMetas: AccountMeta[] = [];\n accountMetas.forEach(accountMeta => {\n const pubkeyString = accountMeta.pubkey.toString();\n const uniqueIndex = uniqueMetas.findIndex(x => {\n return x.pubkey.toString() === pubkeyString;\n });\n if (uniqueIndex > -1) {\n uniqueMetas[uniqueIndex].isWritable =\n uniqueMetas[uniqueIndex].isWritable || accountMeta.isWritable;\n uniqueMetas[uniqueIndex].isSigner =\n uniqueMetas[uniqueIndex].isSigner || accountMeta.isSigner;\n } else {\n uniqueMetas.push(accountMeta);\n }\n });\n\n // Sort. Prioritizing first by signer, then by writable\n uniqueMetas.sort(function (x, y) {\n if (x.isSigner !== y.isSigner) {\n // Signers always come before non-signers\n return x.isSigner ? -1 : 1;\n }\n if (x.isWritable !== y.isWritable) {\n // Writable accounts always come before read-only accounts\n return x.isWritable ? -1 : 1;\n }\n // Otherwise, sort by pubkey, stringwise.\n const options = {\n localeMatcher: 'best fit',\n usage: 'sort',\n sensitivity: 'variant',\n ignorePunctuation: false,\n numeric: false,\n caseFirst: 'lower',\n } as Intl.CollatorOptions;\n return x.pubkey\n .toBase58()\n .localeCompare(y.pubkey.toBase58(), 'en', options);\n });\n\n // Move fee payer to the front\n const feePayerIndex = uniqueMetas.findIndex(x => {\n return x.pubkey.equals(feePayer);\n });\n if (feePayerIndex > -1) {\n const [payerMeta] = uniqueMetas.splice(feePayerIndex, 1);\n payerMeta.isSigner = true;\n payerMeta.isWritable = true;\n uniqueMetas.unshift(payerMeta);\n } else {\n uniqueMetas.unshift({\n pubkey: feePayer,\n isSigner: true,\n isWritable: true,\n });\n }\n\n // Disallow unknown signers\n for (const signature of this.signatures) {\n const uniqueIndex = uniqueMetas.findIndex(x => {\n return x.pubkey.equals(signature.publicKey);\n });\n if (uniqueIndex > -1) {\n if (!uniqueMetas[uniqueIndex].isSigner) {\n uniqueMetas[uniqueIndex].isSigner = true;\n console.warn(\n 'Transaction references a signature that is unnecessary, ' +\n 'only the fee payer and instruction signer accounts should sign a transaction. ' +\n 'This behavior is deprecated and will throw an error in the next major version release.',\n );\n }\n } else {\n throw new Error(`unknown signer: ${signature.publicKey.toString()}`);\n }\n }\n\n let numRequiredSignatures = 0;\n let numReadonlySignedAccounts = 0;\n let numReadonlyUnsignedAccounts = 0;\n\n // Split out signing from non-signing keys and count header values\n const signedKeys: string[] = [];\n const unsignedKeys: string[] = [];\n uniqueMetas.forEach(({pubkey, isSigner, isWritable}) => {\n if (isSigner) {\n signedKeys.push(pubkey.toString());\n numRequiredSignatures += 1;\n if (!isWritable) {\n numReadonlySignedAccounts += 1;\n }\n } else {\n unsignedKeys.push(pubkey.toString());\n if (!isWritable) {\n numReadonlyUnsignedAccounts += 1;\n }\n }\n });\n\n const accountKeys = signedKeys.concat(unsignedKeys);\n const compiledInstructions: CompiledInstruction[] = instructions.map(\n instruction => {\n const {data, programId} = instruction;\n return {\n programIdIndex: accountKeys.indexOf(programId.toString()),\n accounts: instruction.keys.map(meta =>\n accountKeys.indexOf(meta.pubkey.toString()),\n ),\n data: bs58.encode(data),\n };\n },\n );\n\n compiledInstructions.forEach(instruction => {\n invariant(instruction.programIdIndex >= 0);\n instruction.accounts.forEach(keyIndex => invariant(keyIndex >= 0));\n });\n\n return new Message({\n header: {\n numRequiredSignatures,\n numReadonlySignedAccounts,\n numReadonlyUnsignedAccounts,\n },\n accountKeys,\n recentBlockhash,\n instructions: compiledInstructions,\n });\n }\n\n /**\n * @internal\n */\n _compile(): Message {\n const message = this.compileMessage();\n const signedKeys = message.accountKeys.slice(\n 0,\n message.header.numRequiredSignatures,\n );\n\n if (this.signatures.length === signedKeys.length) {\n const valid = this.signatures.every((pair, index) => {\n return signedKeys[index].equals(pair.publicKey);\n });\n\n if (valid) return message;\n }\n\n this.signatures = signedKeys.map(publicKey => ({\n signature: null,\n publicKey,\n }));\n\n return message;\n }\n\n /**\n * Get a buffer of the Transaction data that need to be covered by signatures\n */\n serializeMessage(): Buffer {\n return this._compile().serialize();\n }\n\n /**\n * Get the estimated fee associated with a transaction\n *\n * @param {Connection} connection Connection to RPC Endpoint.\n *\n * @returns {Promise} The estimated fee for the transaction\n */\n async getEstimatedFee(connection: Connection): Promise {\n return (await connection.getFeeForMessage(this.compileMessage())).value;\n }\n\n /**\n * Specify the public keys which will be used to sign the Transaction.\n * The first signer will be used as the transaction fee payer account.\n *\n * Signatures can be added with either `partialSign` or `addSignature`\n *\n * @deprecated Deprecated since v0.84.0. Only the fee payer needs to be\n * specified and it can be set in the Transaction constructor or with the\n * `feePayer` property.\n */\n setSigners(...signers: Array) {\n if (signers.length === 0) {\n throw new Error('No signers');\n }\n\n const seen = new Set();\n this.signatures = signers\n .filter(publicKey => {\n const key = publicKey.toString();\n if (seen.has(key)) {\n return false;\n } else {\n seen.add(key);\n return true;\n }\n })\n .map(publicKey => ({signature: null, publicKey}));\n }\n\n /**\n * Sign the Transaction with the specified signers. Multiple signatures may\n * be applied to a Transaction. The first signature is considered \"primary\"\n * and is used identify and confirm transactions.\n *\n * If the Transaction `feePayer` is not set, the first signer will be used\n * as the transaction fee payer account.\n *\n * Transaction fields should not be modified after the first call to `sign`,\n * as doing so may invalidate the signature and cause the Transaction to be\n * rejected.\n *\n * The Transaction must be assigned a valid `recentBlockhash` before invoking this method\n *\n * @param {Array} signers Array of signers that will sign the transaction\n */\n sign(...signers: Array) {\n if (signers.length === 0) {\n throw new Error('No signers');\n }\n\n // Dedupe signers\n const seen = new Set();\n const uniqueSigners = [];\n for (const signer of signers) {\n const key = signer.publicKey.toString();\n if (seen.has(key)) {\n continue;\n } else {\n seen.add(key);\n uniqueSigners.push(signer);\n }\n }\n\n this.signatures = uniqueSigners.map(signer => ({\n signature: null,\n publicKey: signer.publicKey,\n }));\n\n const message = this._compile();\n this._partialSign(message, ...uniqueSigners);\n }\n\n /**\n * Partially sign a transaction with the specified accounts. All accounts must\n * correspond to either the fee payer or a signer account in the transaction\n * instructions.\n *\n * All the caveats from the `sign` method apply to `partialSign`\n *\n * @param {Array} signers Array of signers that will sign the transaction\n */\n partialSign(...signers: Array) {\n if (signers.length === 0) {\n throw new Error('No signers');\n }\n\n // Dedupe signers\n const seen = new Set();\n const uniqueSigners = [];\n for (const signer of signers) {\n const key = signer.publicKey.toString();\n if (seen.has(key)) {\n continue;\n } else {\n seen.add(key);\n uniqueSigners.push(signer);\n }\n }\n\n const message = this._compile();\n this._partialSign(message, ...uniqueSigners);\n }\n\n /**\n * @internal\n */\n _partialSign(message: Message, ...signers: Array) {\n const signData = message.serialize();\n signers.forEach(signer => {\n const signature = sign(signData, signer.secretKey);\n this._addSignature(signer.publicKey, toBuffer(signature));\n });\n }\n\n /**\n * Add an externally created signature to a transaction. The public key\n * must correspond to either the fee payer or a signer account in the transaction\n * instructions.\n *\n * @param {PublicKey} pubkey Public key that will be added to the transaction.\n * @param {Buffer} signature An externally created signature to add to the transaction.\n */\n addSignature(pubkey: PublicKey, signature: Buffer) {\n this._compile(); // Ensure signatures array is populated\n this._addSignature(pubkey, signature);\n }\n\n /**\n * @internal\n */\n _addSignature(pubkey: PublicKey, signature: Buffer) {\n invariant(signature.length === 64);\n\n const index = this.signatures.findIndex(sigpair =>\n pubkey.equals(sigpair.publicKey),\n );\n if (index < 0) {\n throw new Error(`unknown signer: ${pubkey.toString()}`);\n }\n\n this.signatures[index].signature = Buffer.from(signature);\n }\n\n /**\n * Verify signatures of a Transaction\n * Optional parameter specifies if we're expecting a fully signed Transaction or a partially signed one.\n * If no boolean is provided, we expect a fully signed Transaction by default.\n *\n * @param {boolean} [requireAllSignatures=true] Require a fully signed Transaction\n */\n verifySignatures(requireAllSignatures: boolean = true): boolean {\n const signatureErrors = this._getMessageSignednessErrors(\n this.serializeMessage(),\n requireAllSignatures,\n );\n return !signatureErrors;\n }\n\n /**\n * @internal\n */\n _getMessageSignednessErrors(\n message: Uint8Array,\n requireAllSignatures: boolean,\n ): MessageSignednessErrors | undefined {\n const errors: MessageSignednessErrors = {};\n for (const {signature, publicKey} of this.signatures) {\n if (signature === null) {\n if (requireAllSignatures) {\n (errors.missing ||= []).push(publicKey);\n }\n } else {\n if (!verify(signature, message, publicKey.toBytes())) {\n (errors.invalid ||= []).push(publicKey);\n }\n }\n }\n return errors.invalid || errors.missing ? errors : undefined;\n }\n\n /**\n * Serialize the Transaction in the wire format.\n *\n * @param {Buffer} [config] Config of transaction.\n *\n * @returns {Buffer} Signature of transaction in wire format.\n */\n serialize(config?: SerializeConfig): Buffer {\n const {requireAllSignatures, verifySignatures} = Object.assign(\n {requireAllSignatures: true, verifySignatures: true},\n config,\n );\n\n const signData = this.serializeMessage();\n if (verifySignatures) {\n const sigErrors = this._getMessageSignednessErrors(\n signData,\n requireAllSignatures,\n );\n if (sigErrors) {\n let errorMessage = 'Signature verification failed.';\n if (sigErrors.invalid) {\n errorMessage += `\\nInvalid signature for public key${\n sigErrors.invalid.length === 1 ? '' : '(s)'\n } [\\`${sigErrors.invalid.map(p => p.toBase58()).join('`, `')}\\`].`;\n }\n if (sigErrors.missing) {\n errorMessage += `\\nMissing signature for public key${\n sigErrors.missing.length === 1 ? '' : '(s)'\n } [\\`${sigErrors.missing.map(p => p.toBase58()).join('`, `')}\\`].`;\n }\n throw new Error(errorMessage);\n }\n }\n\n return this._serialize(signData);\n }\n\n /**\n * @internal\n */\n _serialize(signData: Buffer): Buffer {\n const {signatures} = this;\n const signatureCount: number[] = [];\n shortvec.encodeLength(signatureCount, signatures.length);\n const transactionLength =\n signatureCount.length + signatures.length * 64 + signData.length;\n const wireTransaction = Buffer.alloc(transactionLength);\n invariant(signatures.length < 256);\n Buffer.from(signatureCount).copy(wireTransaction, 0);\n signatures.forEach(({signature}, index) => {\n if (signature !== null) {\n invariant(signature.length === 64, `signature has invalid length`);\n Buffer.from(signature).copy(\n wireTransaction,\n signatureCount.length + index * 64,\n );\n }\n });\n signData.copy(\n wireTransaction,\n signatureCount.length + signatures.length * 64,\n );\n invariant(\n wireTransaction.length <= PACKET_DATA_SIZE,\n `Transaction too large: ${wireTransaction.length} > ${PACKET_DATA_SIZE}`,\n );\n return wireTransaction;\n }\n\n /**\n * Deprecated method\n * @internal\n */\n get keys(): Array {\n invariant(this.instructions.length === 1);\n return this.instructions[0].keys.map(keyObj => keyObj.pubkey);\n }\n\n /**\n * Deprecated method\n * @internal\n */\n get programId(): PublicKey {\n invariant(this.instructions.length === 1);\n return this.instructions[0].programId;\n }\n\n /**\n * Deprecated method\n * @internal\n */\n get data(): Buffer {\n invariant(this.instructions.length === 1);\n return this.instructions[0].data;\n }\n\n /**\n * Parse a wire transaction into a Transaction object.\n *\n * @param {Buffer | Uint8Array | Array} buffer Signature of wire Transaction\n *\n * @returns {Transaction} Transaction associated with the signature\n */\n static from(buffer: Buffer | Uint8Array | Array): Transaction {\n // Slice up wire data\n let byteArray = [...buffer];\n\n const signatureCount = shortvec.decodeLength(byteArray);\n let signatures = [];\n for (let i = 0; i < signatureCount; i++) {\n const signature = guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES);\n signatures.push(bs58.encode(Buffer.from(signature)));\n }\n\n return Transaction.populate(Message.from(byteArray), signatures);\n }\n\n /**\n * Populate Transaction object from message and signatures\n *\n * @param {Message} message Message of transaction\n * @param {Array} signatures List of signatures to assign to the transaction\n *\n * @returns {Transaction} The populated Transaction\n */\n static populate(\n message: Message,\n signatures: Array = [],\n ): Transaction {\n const transaction = new Transaction();\n transaction.recentBlockhash = message.recentBlockhash;\n if (message.header.numRequiredSignatures > 0) {\n transaction.feePayer = message.accountKeys[0];\n }\n signatures.forEach((signature, index) => {\n const sigPubkeyPair = {\n signature:\n signature == bs58.encode(DEFAULT_SIGNATURE)\n ? null\n : bs58.decode(signature),\n publicKey: message.accountKeys[index],\n };\n transaction.signatures.push(sigPubkeyPair);\n });\n\n message.instructions.forEach(instruction => {\n const keys = instruction.accounts.map(account => {\n const pubkey = message.accountKeys[account];\n return {\n pubkey,\n isSigner:\n transaction.signatures.some(\n keyObj => keyObj.publicKey.toString() === pubkey.toString(),\n ) || message.isAccountSigner(account),\n isWritable: message.isAccountWritable(account),\n };\n });\n\n transaction.instructions.push(\n new TransactionInstruction({\n keys,\n programId: message.accountKeys[instruction.programIdIndex],\n data: bs58.decode(instruction.data),\n }),\n );\n });\n\n transaction._message = message;\n transaction._json = transaction.toJSON();\n\n return transaction;\n }\n}\n","import {AccountKeysFromLookups} from '../message/account-keys';\nimport assert from '../utils/assert';\nimport {toBuffer} from '../utils/to-buffer';\nimport {Blockhash} from '../blockhash';\nimport {Message, MessageV0, VersionedMessage} from '../message';\nimport {PublicKey} from '../publickey';\nimport {AddressLookupTableAccount} from '../programs';\nimport {AccountMeta, TransactionInstruction} from './legacy';\n\nexport type TransactionMessageArgs = {\n payerKey: PublicKey;\n instructions: Array;\n recentBlockhash: Blockhash;\n};\n\nexport type DecompileArgs =\n | {\n accountKeysFromLookups: AccountKeysFromLookups;\n }\n | {\n addressLookupTableAccounts: AddressLookupTableAccount[];\n };\n\nexport class TransactionMessage {\n payerKey: PublicKey;\n instructions: Array;\n recentBlockhash: Blockhash;\n\n constructor(args: TransactionMessageArgs) {\n this.payerKey = args.payerKey;\n this.instructions = args.instructions;\n this.recentBlockhash = args.recentBlockhash;\n }\n\n static decompile(\n message: VersionedMessage,\n args?: DecompileArgs,\n ): TransactionMessage {\n const {header, compiledInstructions, recentBlockhash} = message;\n\n const {\n numRequiredSignatures,\n numReadonlySignedAccounts,\n numReadonlyUnsignedAccounts,\n } = header;\n\n const numWritableSignedAccounts =\n numRequiredSignatures - numReadonlySignedAccounts;\n assert(numWritableSignedAccounts > 0, 'Message header is invalid');\n\n const numWritableUnsignedAccounts =\n message.staticAccountKeys.length -\n numRequiredSignatures -\n numReadonlyUnsignedAccounts;\n assert(numWritableUnsignedAccounts >= 0, 'Message header is invalid');\n\n const accountKeys = message.getAccountKeys(args);\n const payerKey = accountKeys.get(0);\n if (payerKey === undefined) {\n throw new Error(\n 'Failed to decompile message because no account keys were found',\n );\n }\n\n const instructions: TransactionInstruction[] = [];\n for (const compiledIx of compiledInstructions) {\n const keys: AccountMeta[] = [];\n\n for (const keyIndex of compiledIx.accountKeyIndexes) {\n const pubkey = accountKeys.get(keyIndex);\n if (pubkey === undefined) {\n throw new Error(\n `Failed to find key for account key index ${keyIndex}`,\n );\n }\n\n const isSigner = keyIndex < numRequiredSignatures;\n\n let isWritable;\n if (isSigner) {\n isWritable = keyIndex < numWritableSignedAccounts;\n } else if (keyIndex < accountKeys.staticAccountKeys.length) {\n isWritable =\n keyIndex - numRequiredSignatures < numWritableUnsignedAccounts;\n } else {\n isWritable =\n keyIndex - accountKeys.staticAccountKeys.length <\n // accountKeysFromLookups cannot be undefined because we already found a pubkey for this index above\n accountKeys.accountKeysFromLookups!.writable.length;\n }\n\n keys.push({\n pubkey,\n isSigner: keyIndex < header.numRequiredSignatures,\n isWritable,\n });\n }\n\n const programId = accountKeys.get(compiledIx.programIdIndex);\n if (programId === undefined) {\n throw new Error(\n `Failed to find program id for program id index ${compiledIx.programIdIndex}`,\n );\n }\n\n instructions.push(\n new TransactionInstruction({\n programId,\n data: toBuffer(compiledIx.data),\n keys,\n }),\n );\n }\n\n return new TransactionMessage({\n payerKey,\n instructions,\n recentBlockhash,\n });\n }\n\n compileToLegacyMessage(): Message {\n return Message.compile({\n payerKey: this.payerKey,\n recentBlockhash: this.recentBlockhash,\n instructions: this.instructions,\n });\n }\n\n compileToV0Message(\n addressLookupTableAccounts?: AddressLookupTableAccount[],\n ): MessageV0 {\n return MessageV0.compile({\n payerKey: this.payerKey,\n recentBlockhash: this.recentBlockhash,\n instructions: this.instructions,\n addressLookupTableAccounts,\n });\n }\n}\n","import * as BufferLayout from '@solana/buffer-layout';\n\nimport {Signer} from '../keypair';\nimport assert from '../utils/assert';\nimport {VersionedMessage} from '../message/versioned';\nimport {SIGNATURE_LENGTH_IN_BYTES} from './constants';\nimport * as shortvec from '../utils/shortvec-encoding';\nimport * as Layout from '../layout';\nimport {sign} from '../utils/ed25519';\nimport {PublicKey} from '../publickey';\nimport {guardedSplice} from '../utils/guarded-array-utils';\n\nexport type TransactionVersion = 'legacy' | 0;\n\n/**\n * Versioned transaction class\n */\nexport class VersionedTransaction {\n signatures: Array;\n message: VersionedMessage;\n\n get version(): TransactionVersion {\n return this.message.version;\n }\n\n constructor(message: VersionedMessage, signatures?: Array) {\n if (signatures !== undefined) {\n assert(\n signatures.length === message.header.numRequiredSignatures,\n 'Expected signatures length to be equal to the number of required signatures',\n );\n this.signatures = signatures;\n } else {\n const defaultSignatures = [];\n for (let i = 0; i < message.header.numRequiredSignatures; i++) {\n defaultSignatures.push(new Uint8Array(SIGNATURE_LENGTH_IN_BYTES));\n }\n this.signatures = defaultSignatures;\n }\n this.message = message;\n }\n\n serialize(): Uint8Array {\n const serializedMessage = this.message.serialize();\n\n const encodedSignaturesLength = Array();\n shortvec.encodeLength(encodedSignaturesLength, this.signatures.length);\n\n const transactionLayout = BufferLayout.struct<{\n encodedSignaturesLength: Uint8Array;\n signatures: Array;\n serializedMessage: Uint8Array;\n }>([\n BufferLayout.blob(\n encodedSignaturesLength.length,\n 'encodedSignaturesLength',\n ),\n BufferLayout.seq(\n Layout.signature(),\n this.signatures.length,\n 'signatures',\n ),\n BufferLayout.blob(serializedMessage.length, 'serializedMessage'),\n ]);\n\n const serializedTransaction = new Uint8Array(2048);\n const serializedTransactionLength = transactionLayout.encode(\n {\n encodedSignaturesLength: new Uint8Array(encodedSignaturesLength),\n signatures: this.signatures,\n serializedMessage,\n },\n serializedTransaction,\n );\n\n return serializedTransaction.slice(0, serializedTransactionLength);\n }\n\n static deserialize(serializedTransaction: Uint8Array): VersionedTransaction {\n let byteArray = [...serializedTransaction];\n\n const signatures = [];\n const signaturesLength = shortvec.decodeLength(byteArray);\n for (let i = 0; i < signaturesLength; i++) {\n signatures.push(\n new Uint8Array(guardedSplice(byteArray, 0, SIGNATURE_LENGTH_IN_BYTES)),\n );\n }\n\n const message = VersionedMessage.deserialize(new Uint8Array(byteArray));\n return new VersionedTransaction(message, signatures);\n }\n\n sign(signers: Array) {\n const messageData = this.message.serialize();\n const signerPubkeys = this.message.staticAccountKeys.slice(\n 0,\n this.message.header.numRequiredSignatures,\n );\n for (const signer of signers) {\n const signerIndex = signerPubkeys.findIndex(pubkey =>\n pubkey.equals(signer.publicKey),\n );\n assert(\n signerIndex >= 0,\n `Cannot sign with non signer key ${signer.publicKey.toBase58()}`,\n );\n this.signatures[signerIndex] = sign(messageData, signer.secretKey);\n }\n }\n\n addSignature(publicKey: PublicKey, signature: Uint8Array) {\n assert(signature.byteLength === 64, 'Signature must be 64 bytes long');\n const signerPubkeys = this.message.staticAccountKeys.slice(\n 0,\n this.message.header.numRequiredSignatures,\n );\n const signerIndex = signerPubkeys.findIndex(pubkey =>\n pubkey.equals(publicKey),\n );\n assert(\n signerIndex >= 0,\n `Can not add signature; \\`${publicKey.toBase58()}\\` is not required to sign this transaction`,\n );\n this.signatures[signerIndex] = signature;\n }\n}\n","// TODO: These constants should be removed in favor of reading them out of a\n// Syscall account\n\n/**\n * @internal\n */\nexport const NUM_TICKS_PER_SECOND = 160;\n\n/**\n * @internal\n */\nexport const DEFAULT_TICKS_PER_SLOT = 64;\n\n/**\n * @internal\n */\nexport const NUM_SLOTS_PER_SECOND =\n NUM_TICKS_PER_SECOND / DEFAULT_TICKS_PER_SLOT;\n\n/**\n * @internal\n */\nexport const MS_PER_SLOT = 1000 / NUM_SLOTS_PER_SECOND;\n","import {PublicKey} from './publickey';\n\nexport const SYSVAR_CLOCK_PUBKEY = new PublicKey(\n 'SysvarC1ock11111111111111111111111111111111',\n);\n\nexport const SYSVAR_EPOCH_SCHEDULE_PUBKEY = new PublicKey(\n 'SysvarEpochSchedu1e111111111111111111111111',\n);\n\nexport const SYSVAR_INSTRUCTIONS_PUBKEY = new PublicKey(\n 'Sysvar1nstructions1111111111111111111111111',\n);\n\nexport const SYSVAR_RECENT_BLOCKHASHES_PUBKEY = new PublicKey(\n 'SysvarRecentB1ockHashes11111111111111111111',\n);\n\nexport const SYSVAR_RENT_PUBKEY = new PublicKey(\n 'SysvarRent111111111111111111111111111111111',\n);\n\nexport const SYSVAR_REWARDS_PUBKEY = new PublicKey(\n 'SysvarRewards111111111111111111111111111111',\n);\n\nexport const SYSVAR_SLOT_HASHES_PUBKEY = new PublicKey(\n 'SysvarS1otHashes111111111111111111111111111',\n);\n\nexport const SYSVAR_SLOT_HISTORY_PUBKEY = new PublicKey(\n 'SysvarS1otHistory11111111111111111111111111',\n);\n\nexport const SYSVAR_STAKE_HISTORY_PUBKEY = new PublicKey(\n 'SysvarStakeHistory1111111111111111111111111',\n);\n","import {Connection} from './connection';\nimport {TransactionSignature} from './transaction';\n\nexport class SendTransactionError extends Error {\n private signature: TransactionSignature;\n private transactionMessage: string;\n private transactionLogs: string[] | Promise | undefined;\n\n constructor({\n action,\n signature,\n transactionMessage,\n logs,\n }: {\n action: 'send' | 'simulate';\n signature: TransactionSignature;\n transactionMessage: string;\n logs?: string[];\n }) {\n const maybeLogsOutput = logs\n ? `Logs: \\n${JSON.stringify(logs.slice(-10), null, 2)}. `\n : '';\n const guideText =\n '\\nCatch the `SendTransactionError` and call `getLogs()` on it for full details.';\n let message: string;\n switch (action) {\n case 'send':\n message =\n `Transaction ${signature} resulted in an error. \\n` +\n `${transactionMessage}. ` +\n maybeLogsOutput +\n guideText;\n break;\n case 'simulate':\n message =\n `Simulation failed. \\nMessage: ${transactionMessage}. \\n` +\n maybeLogsOutput +\n guideText;\n break;\n default: {\n message = `Unknown action '${((a: never) => a)(action)}'`;\n }\n }\n super(message);\n\n this.signature = signature;\n this.transactionMessage = transactionMessage;\n this.transactionLogs = logs ? logs : undefined;\n }\n\n get transactionError(): {message: string; logs?: string[]} {\n return {\n message: this.transactionMessage,\n logs: Array.isArray(this.transactionLogs)\n ? this.transactionLogs\n : undefined,\n };\n }\n\n /* @deprecated Use `await getLogs()` instead */\n get logs(): string[] | undefined {\n const cachedLogs = this.transactionLogs;\n if (\n cachedLogs != null &&\n typeof cachedLogs === 'object' &&\n 'then' in cachedLogs\n ) {\n return undefined;\n }\n return cachedLogs;\n }\n\n async getLogs(connection: Connection): Promise {\n if (!Array.isArray(this.transactionLogs)) {\n this.transactionLogs = new Promise((resolve, reject) => {\n connection\n .getTransaction(this.signature)\n .then(tx => {\n if (tx && tx.meta && tx.meta.logMessages) {\n const logs = tx.meta.logMessages;\n this.transactionLogs = logs;\n resolve(logs);\n } else {\n reject(new Error('Log messages not found'));\n }\n })\n .catch(reject);\n });\n }\n return await this.transactionLogs;\n }\n}\n\n// Keep in sync with client/src/rpc_custom_errors.rs\n// Typescript `enums` thwart tree-shaking. See https://bargsten.org/jsts/enums/\nexport const SolanaJSONRPCErrorCode = {\n JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001,\n JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002,\n JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003,\n JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004,\n JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005,\n JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006,\n JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007,\n JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008,\n JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009,\n JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010,\n JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011,\n JSON_RPC_SCAN_ERROR: -32012,\n JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013,\n JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014,\n JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015,\n JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016,\n} as const;\nexport type SolanaJSONRPCErrorCodeEnum =\n (typeof SolanaJSONRPCErrorCode)[keyof typeof SolanaJSONRPCErrorCode];\n\nexport class SolanaJSONRPCError extends Error {\n code: SolanaJSONRPCErrorCodeEnum | unknown;\n data?: any;\n constructor(\n {\n code,\n message,\n data,\n }: Readonly<{code: unknown; message: string; data?: any}>,\n customMessage?: string,\n ) {\n super(customMessage != null ? `${customMessage}: ${message}` : message);\n this.code = code;\n this.data = data;\n this.name = 'SolanaJSONRPCError';\n }\n}\n","import {Connection, SignatureResult} from '../connection';\nimport {Transaction} from '../transaction';\nimport type {ConfirmOptions} from '../connection';\nimport type {Signer} from '../keypair';\nimport type {TransactionSignature} from '../transaction';\nimport {SendTransactionError} from '../errors';\n\n/**\n * Sign, send and confirm a transaction.\n *\n * If `commitment` option is not specified, defaults to 'max' commitment.\n *\n * @param {Connection} connection\n * @param {Transaction} transaction\n * @param {Array} signers\n * @param {ConfirmOptions} [options]\n * @returns {Promise}\n */\nexport async function sendAndConfirmTransaction(\n connection: Connection,\n transaction: Transaction,\n signers: Array,\n options?: ConfirmOptions &\n Readonly<{\n // A signal that, when aborted, cancels any outstanding transaction confirmation operations\n abortSignal?: AbortSignal;\n }>,\n): Promise {\n const sendOptions = options && {\n skipPreflight: options.skipPreflight,\n preflightCommitment: options.preflightCommitment || options.commitment,\n maxRetries: options.maxRetries,\n minContextSlot: options.minContextSlot,\n };\n\n const signature = await connection.sendTransaction(\n transaction,\n signers,\n sendOptions,\n );\n\n let status: SignatureResult;\n if (\n transaction.recentBlockhash != null &&\n transaction.lastValidBlockHeight != null\n ) {\n status = (\n await connection.confirmTransaction(\n {\n abortSignal: options?.abortSignal,\n signature: signature,\n blockhash: transaction.recentBlockhash,\n lastValidBlockHeight: transaction.lastValidBlockHeight,\n },\n options && options.commitment,\n )\n ).value;\n } else if (\n transaction.minNonceContextSlot != null &&\n transaction.nonceInfo != null\n ) {\n const {nonceInstruction} = transaction.nonceInfo;\n const nonceAccountPubkey = nonceInstruction.keys[0].pubkey;\n status = (\n await connection.confirmTransaction(\n {\n abortSignal: options?.abortSignal,\n minContextSlot: transaction.minNonceContextSlot,\n nonceAccountPubkey,\n nonceValue: transaction.nonceInfo.nonce,\n signature,\n },\n options && options.commitment,\n )\n ).value;\n } else {\n if (options?.abortSignal != null) {\n console.warn(\n 'sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was ' +\n 'supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` ' +\n 'or a combination of `nonceInfo` and `minNonceContextSlot` are abortable.',\n );\n }\n status = (\n await connection.confirmTransaction(\n signature,\n options && options.commitment,\n )\n ).value;\n }\n\n if (status.err) {\n if (signature != null) {\n throw new SendTransactionError({\n action: 'send',\n signature: signature,\n transactionMessage: `Status: (${JSON.stringify(status)})`,\n });\n }\n throw new Error(\n `Transaction ${signature} failed (${JSON.stringify(status)})`,\n );\n }\n\n return signature;\n}\n","// zzz\nexport function sleep(ms: number): Promise {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n","import {Buffer} from 'buffer';\nimport * as BufferLayout from '@solana/buffer-layout';\n\nimport * as Layout from './layout';\n\nexport interface IInstructionInputData {\n readonly instruction: number;\n}\n\n/**\n * @internal\n */\nexport type InstructionType = {\n /** The Instruction index (from solana upstream program) */\n index: number;\n /** The BufferLayout to use to build data */\n layout: BufferLayout.Layout;\n};\n\n/**\n * Populate a buffer of instruction data using an InstructionType\n * @internal\n */\nexport function encodeData(\n type: InstructionType,\n fields?: any,\n): Buffer {\n const allocLength =\n type.layout.span >= 0 ? type.layout.span : Layout.getAlloc(type, fields);\n const data = Buffer.alloc(allocLength);\n const layoutFields = Object.assign({instruction: type.index}, fields);\n type.layout.encode(layoutFields, data);\n return data;\n}\n\n/**\n * Decode instruction data buffer using an InstructionType\n * @internal\n */\nexport function decodeData(\n type: InstructionType,\n buffer: Buffer,\n): TInputData {\n let data: TInputData;\n try {\n data = type.layout.decode(buffer);\n } catch (err) {\n throw new Error('invalid instruction; ' + err);\n }\n\n if (data.instruction !== type.index) {\n throw new Error(\n `invalid instruction; instruction index mismatch ${data.instruction} != ${type.index}`,\n );\n }\n\n return data;\n}\n","import * as BufferLayout from '@solana/buffer-layout';\n\n/**\n * https://github.com/solana-labs/solana/blob/90bedd7e067b5b8f3ddbb45da00a4e9cabb22c62/sdk/src/fee_calculator.rs#L7-L11\n *\n * @internal\n */\nexport const FeeCalculatorLayout = BufferLayout.nu64('lamportsPerSignature');\n\n/**\n * Calculator for transaction fees.\n *\n * @deprecated Deprecated since Solana v1.8.0.\n */\nexport interface FeeCalculator {\n /** Cost in lamports to validate a signature. */\n lamportsPerSignature: number;\n}\n","import * as BufferLayout from '@solana/buffer-layout';\nimport {Buffer} from 'buffer';\n\nimport * as Layout from './layout';\nimport {PublicKey} from './publickey';\nimport type {FeeCalculator} from './fee-calculator';\nimport {FeeCalculatorLayout} from './fee-calculator';\nimport {toBuffer} from './utils/to-buffer';\n\n/**\n * See https://github.com/solana-labs/solana/blob/0ea2843ec9cdc517572b8e62c959f41b55cf4453/sdk/src/nonce_state.rs#L29-L32\n *\n * @internal\n */\nconst NonceAccountLayout = BufferLayout.struct<\n Readonly<{\n authorizedPubkey: Uint8Array;\n feeCalculator: Readonly<{\n lamportsPerSignature: number;\n }>;\n nonce: Uint8Array;\n state: number;\n version: number;\n }>\n>([\n BufferLayout.u32('version'),\n BufferLayout.u32('state'),\n Layout.publicKey('authorizedPubkey'),\n Layout.publicKey('nonce'),\n BufferLayout.struct>(\n [FeeCalculatorLayout],\n 'feeCalculator',\n ),\n]);\n\nexport const NONCE_ACCOUNT_LENGTH = NonceAccountLayout.span;\n\n/**\n * A durable nonce is a 32 byte value encoded as a base58 string.\n */\nexport type DurableNonce = string;\n\ntype NonceAccountArgs = {\n authorizedPubkey: PublicKey;\n nonce: DurableNonce;\n feeCalculator: FeeCalculator;\n};\n\n/**\n * NonceAccount class\n */\nexport class NonceAccount {\n authorizedPubkey: PublicKey;\n nonce: DurableNonce;\n feeCalculator: FeeCalculator;\n\n /**\n * @internal\n */\n constructor(args: NonceAccountArgs) {\n this.authorizedPubkey = args.authorizedPubkey;\n this.nonce = args.nonce;\n this.feeCalculator = args.feeCalculator;\n }\n\n /**\n * Deserialize NonceAccount from the account data.\n *\n * @param buffer account data\n * @return NonceAccount\n */\n static fromAccountData(\n buffer: Buffer | Uint8Array | Array,\n ): NonceAccount {\n const nonceAccount = NonceAccountLayout.decode(toBuffer(buffer), 0);\n return new NonceAccount({\n authorizedPubkey: new PublicKey(nonceAccount.authorizedPubkey),\n nonce: new PublicKey(nonceAccount.nonce).toString(),\n feeCalculator: nonceAccount.feeCalculator,\n });\n }\n}\n","import {Buffer} from 'buffer';\nimport {blob, Layout} from '@solana/buffer-layout';\nimport {toBigIntLE, toBufferLE} from 'bigint-buffer';\n\ninterface EncodeDecode {\n decode(buffer: Buffer, offset?: number): T;\n encode(src: T, buffer: Buffer, offset?: number): number;\n}\n\nconst encodeDecode = (layout: Layout): EncodeDecode => {\n const decode = layout.decode.bind(layout);\n const encode = layout.encode.bind(layout);\n return {decode, encode};\n};\n\nconst bigInt =\n (length: number) =>\n (property?: string): Layout => {\n const layout = blob(length, property);\n const {encode, decode} = encodeDecode(layout);\n\n const bigIntLayout = layout as Layout as Layout;\n\n bigIntLayout.decode = (buffer: Buffer, offset: number) => {\n const src = decode(buffer, offset);\n return toBigIntLE(Buffer.from(src));\n };\n\n bigIntLayout.encode = (bigInt: bigint, buffer: Buffer, offset: number) => {\n const src = toBufferLE(bigInt, length);\n return encode(src, buffer, offset);\n };\n\n return bigIntLayout;\n };\n\nexport const u64 = bigInt(8);\n\nexport const u128 = bigInt(16);\n\nexport const u192 = bigInt(24);\n\nexport const u256 = bigInt(32);\n","import * as BufferLayout from '@solana/buffer-layout';\n\nimport {\n encodeData,\n decodeData,\n InstructionType,\n IInstructionInputData,\n} from '../instruction';\nimport * as Layout from '../layout';\nimport {NONCE_ACCOUNT_LENGTH} from '../nonce-account';\nimport {PublicKey} from '../publickey';\nimport {SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY} from '../sysvar';\nimport {Transaction, TransactionInstruction} from '../transaction';\nimport {toBuffer} from '../utils/to-buffer';\nimport {u64} from '../utils/bigint';\n\n/**\n * Create account system transaction params\n */\nexport type CreateAccountParams = {\n /** The account that will transfer lamports to the created account */\n fromPubkey: PublicKey;\n /** Public key of the created account */\n newAccountPubkey: PublicKey;\n /** Amount of lamports to transfer to the created account */\n lamports: number;\n /** Amount of space in bytes to allocate to the created account */\n space: number;\n /** Public key of the program to assign as the owner of the created account */\n programId: PublicKey;\n};\n\n/**\n * Transfer system transaction params\n */\nexport type TransferParams = {\n /** Account that will transfer lamports */\n fromPubkey: PublicKey;\n /** Account that will receive transferred lamports */\n toPubkey: PublicKey;\n /** Amount of lamports to transfer */\n lamports: number | bigint;\n};\n\n/**\n * Assign system transaction params\n */\nexport type AssignParams = {\n /** Public key of the account which will be assigned a new owner */\n accountPubkey: PublicKey;\n /** Public key of the program to assign as the owner */\n programId: PublicKey;\n};\n\n/**\n * Create account with seed system transaction params\n */\nexport type CreateAccountWithSeedParams = {\n /** The account that will transfer lamports to the created account */\n fromPubkey: PublicKey;\n /** Public key of the created account. Must be pre-calculated with PublicKey.createWithSeed() */\n newAccountPubkey: PublicKey;\n /** Base public key to use to derive the address of the created account. Must be the same as the base key used to create `newAccountPubkey` */\n basePubkey: PublicKey;\n /** Seed to use to derive the address of the created account. Must be the same as the seed used to create `newAccountPubkey` */\n seed: string;\n /** Amount of lamports to transfer to the created account */\n lamports: number;\n /** Amount of space in bytes to allocate to the created account */\n space: number;\n /** Public key of the program to assign as the owner of the created account */\n programId: PublicKey;\n};\n\n/**\n * Create nonce account system transaction params\n */\nexport type CreateNonceAccountParams = {\n /** The account that will transfer lamports to the created nonce account */\n fromPubkey: PublicKey;\n /** Public key of the created nonce account */\n noncePubkey: PublicKey;\n /** Public key to set as authority of the created nonce account */\n authorizedPubkey: PublicKey;\n /** Amount of lamports to transfer to the created nonce account */\n lamports: number;\n};\n\n/**\n * Create nonce account with seed system transaction params\n */\nexport type CreateNonceAccountWithSeedParams = {\n /** The account that will transfer lamports to the created nonce account */\n fromPubkey: PublicKey;\n /** Public key of the created nonce account */\n noncePubkey: PublicKey;\n /** Public key to set as authority of the created nonce account */\n authorizedPubkey: PublicKey;\n /** Amount of lamports to transfer to the created nonce account */\n lamports: number;\n /** Base public key to use to derive the address of the nonce account */\n basePubkey: PublicKey;\n /** Seed to use to derive the address of the nonce account */\n seed: string;\n};\n\n/**\n * Initialize nonce account system instruction params\n */\nexport type InitializeNonceParams = {\n /** Nonce account which will be initialized */\n noncePubkey: PublicKey;\n /** Public key to set as authority of the initialized nonce account */\n authorizedPubkey: PublicKey;\n};\n\n/**\n * Advance nonce account system instruction params\n */\nexport type AdvanceNonceParams = {\n /** Nonce account */\n noncePubkey: PublicKey;\n /** Public key of the nonce authority */\n authorizedPubkey: PublicKey;\n};\n\n/**\n * Withdraw nonce account system transaction params\n */\nexport type WithdrawNonceParams = {\n /** Nonce account */\n noncePubkey: PublicKey;\n /** Public key of the nonce authority */\n authorizedPubkey: PublicKey;\n /** Public key of the account which will receive the withdrawn nonce account balance */\n toPubkey: PublicKey;\n /** Amount of lamports to withdraw from the nonce account */\n lamports: number;\n};\n\n/**\n * Authorize nonce account system transaction params\n */\nexport type AuthorizeNonceParams = {\n /** Nonce account */\n noncePubkey: PublicKey;\n /** Public key of the current nonce authority */\n authorizedPubkey: PublicKey;\n /** Public key to set as the new nonce authority */\n newAuthorizedPubkey: PublicKey;\n};\n\n/**\n * Allocate account system transaction params\n */\nexport type AllocateParams = {\n /** Account to allocate */\n accountPubkey: PublicKey;\n /** Amount of space in bytes to allocate */\n space: number;\n};\n\n/**\n * Allocate account with seed system transaction params\n */\nexport type AllocateWithSeedParams = {\n /** Account to allocate */\n accountPubkey: PublicKey;\n /** Base public key to use to derive the address of the allocated account */\n basePubkey: PublicKey;\n /** Seed to use to derive the address of the allocated account */\n seed: string;\n /** Amount of space in bytes to allocate */\n space: number;\n /** Public key of the program to assign as the owner of the allocated account */\n programId: PublicKey;\n};\n\n/**\n * Assign account with seed system transaction params\n */\nexport type AssignWithSeedParams = {\n /** Public key of the account which will be assigned a new owner */\n accountPubkey: PublicKey;\n /** Base public key to use to derive the address of the assigned account */\n basePubkey: PublicKey;\n /** Seed to use to derive the address of the assigned account */\n seed: string;\n /** Public key of the program to assign as the owner */\n programId: PublicKey;\n};\n\n/**\n * Transfer with seed system transaction params\n */\nexport type TransferWithSeedParams = {\n /** Account that will transfer lamports */\n fromPubkey: PublicKey;\n /** Base public key to use to derive the funding account address */\n basePubkey: PublicKey;\n /** Account that will receive transferred lamports */\n toPubkey: PublicKey;\n /** Amount of lamports to transfer */\n lamports: number | bigint;\n /** Seed to use to derive the funding account address */\n seed: string;\n /** Program id to use to derive the funding account address */\n programId: PublicKey;\n};\n\n/** Decoded transfer system transaction instruction */\nexport type DecodedTransferInstruction = {\n /** Account that will transfer lamports */\n fromPubkey: PublicKey;\n /** Account that will receive transferred lamports */\n toPubkey: PublicKey;\n /** Amount of lamports to transfer */\n lamports: bigint;\n};\n\n/** Decoded transferWithSeed system transaction instruction */\nexport type DecodedTransferWithSeedInstruction = {\n /** Account that will transfer lamports */\n fromPubkey: PublicKey;\n /** Base public key to use to derive the funding account address */\n basePubkey: PublicKey;\n /** Account that will receive transferred lamports */\n toPubkey: PublicKey;\n /** Amount of lamports to transfer */\n lamports: bigint;\n /** Seed to use to derive the funding account address */\n seed: string;\n /** Program id to use to derive the funding account address */\n programId: PublicKey;\n};\n\n/**\n * System Instruction class\n */\nexport class SystemInstruction {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Decode a system instruction and retrieve the instruction type.\n */\n static decodeInstructionType(\n instruction: TransactionInstruction,\n ): SystemInstructionType {\n this.checkProgramId(instruction.programId);\n\n const instructionTypeLayout = BufferLayout.u32('instruction');\n const typeIndex = instructionTypeLayout.decode(instruction.data);\n\n let type: SystemInstructionType | undefined;\n for (const [ixType, layout] of Object.entries(SYSTEM_INSTRUCTION_LAYOUTS)) {\n if (layout.index == typeIndex) {\n type = ixType as SystemInstructionType;\n break;\n }\n }\n\n if (!type) {\n throw new Error('Instruction type incorrect; not a SystemInstruction');\n }\n\n return type;\n }\n\n /**\n * Decode a create account system instruction and retrieve the instruction params.\n */\n static decodeCreateAccount(\n instruction: TransactionInstruction,\n ): CreateAccountParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n\n const {lamports, space, programId} = decodeData(\n SYSTEM_INSTRUCTION_LAYOUTS.Create,\n instruction.data,\n );\n\n return {\n fromPubkey: instruction.keys[0].pubkey,\n newAccountPubkey: instruction.keys[1].pubkey,\n lamports,\n space,\n programId: new PublicKey(programId),\n };\n }\n\n /**\n * Decode a transfer system instruction and retrieve the instruction params.\n */\n static decodeTransfer(\n instruction: TransactionInstruction,\n ): DecodedTransferInstruction {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n\n const {lamports} = decodeData(\n SYSTEM_INSTRUCTION_LAYOUTS.Transfer,\n instruction.data,\n );\n\n return {\n fromPubkey: instruction.keys[0].pubkey,\n toPubkey: instruction.keys[1].pubkey,\n lamports,\n };\n }\n\n /**\n * Decode a transfer with seed system instruction and retrieve the instruction params.\n */\n static decodeTransferWithSeed(\n instruction: TransactionInstruction,\n ): DecodedTransferWithSeedInstruction {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n\n const {lamports, seed, programId} = decodeData(\n SYSTEM_INSTRUCTION_LAYOUTS.TransferWithSeed,\n instruction.data,\n );\n\n return {\n fromPubkey: instruction.keys[0].pubkey,\n basePubkey: instruction.keys[1].pubkey,\n toPubkey: instruction.keys[2].pubkey,\n lamports,\n seed,\n programId: new PublicKey(programId),\n };\n }\n\n /**\n * Decode an allocate system instruction and retrieve the instruction params.\n */\n static decodeAllocate(instruction: TransactionInstruction): AllocateParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 1);\n\n const {space} = decodeData(\n SYSTEM_INSTRUCTION_LAYOUTS.Allocate,\n instruction.data,\n );\n\n return {\n accountPubkey: instruction.keys[0].pubkey,\n space,\n };\n }\n\n /**\n * Decode an allocate with seed system instruction and retrieve the instruction params.\n */\n static decodeAllocateWithSeed(\n instruction: TransactionInstruction,\n ): AllocateWithSeedParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 1);\n\n const {base, seed, space, programId} = decodeData(\n SYSTEM_INSTRUCTION_LAYOUTS.AllocateWithSeed,\n instruction.data,\n );\n\n return {\n accountPubkey: instruction.keys[0].pubkey,\n basePubkey: new PublicKey(base),\n seed,\n space,\n programId: new PublicKey(programId),\n };\n }\n\n /**\n * Decode an assign system instruction and retrieve the instruction params.\n */\n static decodeAssign(instruction: TransactionInstruction): AssignParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 1);\n\n const {programId} = decodeData(\n SYSTEM_INSTRUCTION_LAYOUTS.Assign,\n instruction.data,\n );\n\n return {\n accountPubkey: instruction.keys[0].pubkey,\n programId: new PublicKey(programId),\n };\n }\n\n /**\n * Decode an assign with seed system instruction and retrieve the instruction params.\n */\n static decodeAssignWithSeed(\n instruction: TransactionInstruction,\n ): AssignWithSeedParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 1);\n\n const {base, seed, programId} = decodeData(\n SYSTEM_INSTRUCTION_LAYOUTS.AssignWithSeed,\n instruction.data,\n );\n\n return {\n accountPubkey: instruction.keys[0].pubkey,\n basePubkey: new PublicKey(base),\n seed,\n programId: new PublicKey(programId),\n };\n }\n\n /**\n * Decode a create account with seed system instruction and retrieve the instruction params.\n */\n static decodeCreateWithSeed(\n instruction: TransactionInstruction,\n ): CreateAccountWithSeedParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n\n const {base, seed, lamports, space, programId} = decodeData(\n SYSTEM_INSTRUCTION_LAYOUTS.CreateWithSeed,\n instruction.data,\n );\n\n return {\n fromPubkey: instruction.keys[0].pubkey,\n newAccountPubkey: instruction.keys[1].pubkey,\n basePubkey: new PublicKey(base),\n seed,\n lamports,\n space,\n programId: new PublicKey(programId),\n };\n }\n\n /**\n * Decode a nonce initialize system instruction and retrieve the instruction params.\n */\n static decodeNonceInitialize(\n instruction: TransactionInstruction,\n ): InitializeNonceParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n\n const {authorized} = decodeData(\n SYSTEM_INSTRUCTION_LAYOUTS.InitializeNonceAccount,\n instruction.data,\n );\n\n return {\n noncePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: new PublicKey(authorized),\n };\n }\n\n /**\n * Decode a nonce advance system instruction and retrieve the instruction params.\n */\n static decodeNonceAdvance(\n instruction: TransactionInstruction,\n ): AdvanceNonceParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n\n decodeData(\n SYSTEM_INSTRUCTION_LAYOUTS.AdvanceNonceAccount,\n instruction.data,\n );\n\n return {\n noncePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: instruction.keys[2].pubkey,\n };\n }\n\n /**\n * Decode a nonce withdraw system instruction and retrieve the instruction params.\n */\n static decodeNonceWithdraw(\n instruction: TransactionInstruction,\n ): WithdrawNonceParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 5);\n\n const {lamports} = decodeData(\n SYSTEM_INSTRUCTION_LAYOUTS.WithdrawNonceAccount,\n instruction.data,\n );\n\n return {\n noncePubkey: instruction.keys[0].pubkey,\n toPubkey: instruction.keys[1].pubkey,\n authorizedPubkey: instruction.keys[4].pubkey,\n lamports,\n };\n }\n\n /**\n * Decode a nonce authorize system instruction and retrieve the instruction params.\n */\n static decodeNonceAuthorize(\n instruction: TransactionInstruction,\n ): AuthorizeNonceParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n\n const {authorized} = decodeData(\n SYSTEM_INSTRUCTION_LAYOUTS.AuthorizeNonceAccount,\n instruction.data,\n );\n\n return {\n noncePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: instruction.keys[1].pubkey,\n newAuthorizedPubkey: new PublicKey(authorized),\n };\n }\n\n /**\n * @internal\n */\n static checkProgramId(programId: PublicKey) {\n if (!programId.equals(SystemProgram.programId)) {\n throw new Error('invalid instruction; programId is not SystemProgram');\n }\n }\n\n /**\n * @internal\n */\n static checkKeyLength(keys: Array, expectedLength: number) {\n if (keys.length < expectedLength) {\n throw new Error(\n `invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`,\n );\n }\n }\n}\n\n/**\n * An enumeration of valid SystemInstructionType's\n */\nexport type SystemInstructionType =\n // FIXME\n // It would be preferable for this type to be `keyof SystemInstructionInputData`\n // but Typedoc does not transpile `keyof` expressions.\n // See https://github.com/TypeStrong/typedoc/issues/1894\n | 'AdvanceNonceAccount'\n | 'Allocate'\n | 'AllocateWithSeed'\n | 'Assign'\n | 'AssignWithSeed'\n | 'AuthorizeNonceAccount'\n | 'Create'\n | 'CreateWithSeed'\n | 'InitializeNonceAccount'\n | 'Transfer'\n | 'TransferWithSeed'\n | 'WithdrawNonceAccount'\n | 'UpgradeNonceAccount';\n\ntype SystemInstructionInputData = {\n AdvanceNonceAccount: IInstructionInputData;\n Allocate: IInstructionInputData & {\n space: number;\n };\n AllocateWithSeed: IInstructionInputData & {\n base: Uint8Array;\n programId: Uint8Array;\n seed: string;\n space: number;\n };\n Assign: IInstructionInputData & {\n programId: Uint8Array;\n };\n AssignWithSeed: IInstructionInputData & {\n base: Uint8Array;\n seed: string;\n programId: Uint8Array;\n };\n AuthorizeNonceAccount: IInstructionInputData & {\n authorized: Uint8Array;\n };\n Create: IInstructionInputData & {\n lamports: number;\n programId: Uint8Array;\n space: number;\n };\n CreateWithSeed: IInstructionInputData & {\n base: Uint8Array;\n lamports: number;\n programId: Uint8Array;\n seed: string;\n space: number;\n };\n InitializeNonceAccount: IInstructionInputData & {\n authorized: Uint8Array;\n };\n Transfer: IInstructionInputData & {\n lamports: bigint;\n };\n TransferWithSeed: IInstructionInputData & {\n lamports: bigint;\n programId: Uint8Array;\n seed: string;\n };\n WithdrawNonceAccount: IInstructionInputData & {\n lamports: number;\n };\n UpgradeNonceAccount: IInstructionInputData;\n};\n\n/**\n * An enumeration of valid system InstructionType's\n * @internal\n */\nexport const SYSTEM_INSTRUCTION_LAYOUTS = Object.freeze<{\n [Instruction in SystemInstructionType]: InstructionType<\n SystemInstructionInputData[Instruction]\n >;\n}>({\n Create: {\n index: 0,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n BufferLayout.ns64('lamports'),\n BufferLayout.ns64('space'),\n Layout.publicKey('programId'),\n ]),\n },\n Assign: {\n index: 1,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n Layout.publicKey('programId'),\n ]),\n },\n Transfer: {\n index: 2,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n u64('lamports'),\n ]),\n },\n CreateWithSeed: {\n index: 3,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n Layout.publicKey('base'),\n Layout.rustString('seed'),\n BufferLayout.ns64('lamports'),\n BufferLayout.ns64('space'),\n Layout.publicKey('programId'),\n ]),\n },\n AdvanceNonceAccount: {\n index: 4,\n layout: BufferLayout.struct<\n SystemInstructionInputData['AdvanceNonceAccount']\n >([BufferLayout.u32('instruction')]),\n },\n WithdrawNonceAccount: {\n index: 5,\n layout: BufferLayout.struct<\n SystemInstructionInputData['WithdrawNonceAccount']\n >([BufferLayout.u32('instruction'), BufferLayout.ns64('lamports')]),\n },\n InitializeNonceAccount: {\n index: 6,\n layout: BufferLayout.struct<\n SystemInstructionInputData['InitializeNonceAccount']\n >([BufferLayout.u32('instruction'), Layout.publicKey('authorized')]),\n },\n AuthorizeNonceAccount: {\n index: 7,\n layout: BufferLayout.struct<\n SystemInstructionInputData['AuthorizeNonceAccount']\n >([BufferLayout.u32('instruction'), Layout.publicKey('authorized')]),\n },\n Allocate: {\n index: 8,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n BufferLayout.ns64('space'),\n ]),\n },\n AllocateWithSeed: {\n index: 9,\n layout: BufferLayout.struct(\n [\n BufferLayout.u32('instruction'),\n Layout.publicKey('base'),\n Layout.rustString('seed'),\n BufferLayout.ns64('space'),\n Layout.publicKey('programId'),\n ],\n ),\n },\n AssignWithSeed: {\n index: 10,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n Layout.publicKey('base'),\n Layout.rustString('seed'),\n Layout.publicKey('programId'),\n ]),\n },\n TransferWithSeed: {\n index: 11,\n layout: BufferLayout.struct(\n [\n BufferLayout.u32('instruction'),\n u64('lamports'),\n Layout.rustString('seed'),\n Layout.publicKey('programId'),\n ],\n ),\n },\n UpgradeNonceAccount: {\n index: 12,\n layout: BufferLayout.struct<\n SystemInstructionInputData['UpgradeNonceAccount']\n >([BufferLayout.u32('instruction')]),\n },\n});\n\n/**\n * Factory class for transactions to interact with the System program\n */\nexport class SystemProgram {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Public key that identifies the System program\n */\n static programId: PublicKey = new PublicKey(\n '11111111111111111111111111111111',\n );\n\n /**\n * Generate a transaction instruction that creates a new account\n */\n static createAccount(params: CreateAccountParams): TransactionInstruction {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.Create;\n const data = encodeData(type, {\n lamports: params.lamports,\n space: params.space,\n programId: toBuffer(params.programId.toBuffer()),\n });\n\n return new TransactionInstruction({\n keys: [\n {pubkey: params.fromPubkey, isSigner: true, isWritable: true},\n {pubkey: params.newAccountPubkey, isSigner: true, isWritable: true},\n ],\n programId: this.programId,\n data,\n });\n }\n\n /**\n * Generate a transaction instruction that transfers lamports from one account to another\n */\n static transfer(\n params: TransferParams | TransferWithSeedParams,\n ): TransactionInstruction {\n let data;\n let keys;\n if ('basePubkey' in params) {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.TransferWithSeed;\n data = encodeData(type, {\n lamports: BigInt(params.lamports),\n seed: params.seed,\n programId: toBuffer(params.programId.toBuffer()),\n });\n keys = [\n {pubkey: params.fromPubkey, isSigner: false, isWritable: true},\n {pubkey: params.basePubkey, isSigner: true, isWritable: false},\n {pubkey: params.toPubkey, isSigner: false, isWritable: true},\n ];\n } else {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.Transfer;\n data = encodeData(type, {lamports: BigInt(params.lamports)});\n keys = [\n {pubkey: params.fromPubkey, isSigner: true, isWritable: true},\n {pubkey: params.toPubkey, isSigner: false, isWritable: true},\n ];\n }\n\n return new TransactionInstruction({\n keys,\n programId: this.programId,\n data,\n });\n }\n\n /**\n * Generate a transaction instruction that assigns an account to a program\n */\n static assign(\n params: AssignParams | AssignWithSeedParams,\n ): TransactionInstruction {\n let data;\n let keys;\n if ('basePubkey' in params) {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.AssignWithSeed;\n data = encodeData(type, {\n base: toBuffer(params.basePubkey.toBuffer()),\n seed: params.seed,\n programId: toBuffer(params.programId.toBuffer()),\n });\n keys = [\n {pubkey: params.accountPubkey, isSigner: false, isWritable: true},\n {pubkey: params.basePubkey, isSigner: true, isWritable: false},\n ];\n } else {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.Assign;\n data = encodeData(type, {\n programId: toBuffer(params.programId.toBuffer()),\n });\n keys = [{pubkey: params.accountPubkey, isSigner: true, isWritable: true}];\n }\n\n return new TransactionInstruction({\n keys,\n programId: this.programId,\n data,\n });\n }\n\n /**\n * Generate a transaction instruction that creates a new account at\n * an address generated with `from`, a seed, and programId\n */\n static createAccountWithSeed(\n params: CreateAccountWithSeedParams,\n ): TransactionInstruction {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.CreateWithSeed;\n const data = encodeData(type, {\n base: toBuffer(params.basePubkey.toBuffer()),\n seed: params.seed,\n lamports: params.lamports,\n space: params.space,\n programId: toBuffer(params.programId.toBuffer()),\n });\n let keys = [\n {pubkey: params.fromPubkey, isSigner: true, isWritable: true},\n {pubkey: params.newAccountPubkey, isSigner: false, isWritable: true},\n ];\n if (!params.basePubkey.equals(params.fromPubkey)) {\n keys.push({\n pubkey: params.basePubkey,\n isSigner: true,\n isWritable: false,\n });\n }\n\n return new TransactionInstruction({\n keys,\n programId: this.programId,\n data,\n });\n }\n\n /**\n * Generate a transaction that creates a new Nonce account\n */\n static createNonceAccount(\n params: CreateNonceAccountParams | CreateNonceAccountWithSeedParams,\n ): Transaction {\n const transaction = new Transaction();\n if ('basePubkey' in params && 'seed' in params) {\n transaction.add(\n SystemProgram.createAccountWithSeed({\n fromPubkey: params.fromPubkey,\n newAccountPubkey: params.noncePubkey,\n basePubkey: params.basePubkey,\n seed: params.seed,\n lamports: params.lamports,\n space: NONCE_ACCOUNT_LENGTH,\n programId: this.programId,\n }),\n );\n } else {\n transaction.add(\n SystemProgram.createAccount({\n fromPubkey: params.fromPubkey,\n newAccountPubkey: params.noncePubkey,\n lamports: params.lamports,\n space: NONCE_ACCOUNT_LENGTH,\n programId: this.programId,\n }),\n );\n }\n\n const initParams = {\n noncePubkey: params.noncePubkey,\n authorizedPubkey: params.authorizedPubkey,\n };\n\n transaction.add(this.nonceInitialize(initParams));\n return transaction;\n }\n\n /**\n * Generate an instruction to initialize a Nonce account\n */\n static nonceInitialize(\n params: InitializeNonceParams,\n ): TransactionInstruction {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.InitializeNonceAccount;\n const data = encodeData(type, {\n authorized: toBuffer(params.authorizedPubkey.toBuffer()),\n });\n const instructionData = {\n keys: [\n {pubkey: params.noncePubkey, isSigner: false, isWritable: true},\n {\n pubkey: SYSVAR_RECENT_BLOCKHASHES_PUBKEY,\n isSigner: false,\n isWritable: false,\n },\n {pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false},\n ],\n programId: this.programId,\n data,\n };\n return new TransactionInstruction(instructionData);\n }\n\n /**\n * Generate an instruction to advance the nonce in a Nonce account\n */\n static nonceAdvance(params: AdvanceNonceParams): TransactionInstruction {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.AdvanceNonceAccount;\n const data = encodeData(type);\n const instructionData = {\n keys: [\n {pubkey: params.noncePubkey, isSigner: false, isWritable: true},\n {\n pubkey: SYSVAR_RECENT_BLOCKHASHES_PUBKEY,\n isSigner: false,\n isWritable: false,\n },\n {pubkey: params.authorizedPubkey, isSigner: true, isWritable: false},\n ],\n programId: this.programId,\n data,\n };\n return new TransactionInstruction(instructionData);\n }\n\n /**\n * Generate a transaction instruction that withdraws lamports from a Nonce account\n */\n static nonceWithdraw(params: WithdrawNonceParams): TransactionInstruction {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.WithdrawNonceAccount;\n const data = encodeData(type, {lamports: params.lamports});\n\n return new TransactionInstruction({\n keys: [\n {pubkey: params.noncePubkey, isSigner: false, isWritable: true},\n {pubkey: params.toPubkey, isSigner: false, isWritable: true},\n {\n pubkey: SYSVAR_RECENT_BLOCKHASHES_PUBKEY,\n isSigner: false,\n isWritable: false,\n },\n {\n pubkey: SYSVAR_RENT_PUBKEY,\n isSigner: false,\n isWritable: false,\n },\n {pubkey: params.authorizedPubkey, isSigner: true, isWritable: false},\n ],\n programId: this.programId,\n data,\n });\n }\n\n /**\n * Generate a transaction instruction that authorizes a new PublicKey as the authority\n * on a Nonce account.\n */\n static nonceAuthorize(params: AuthorizeNonceParams): TransactionInstruction {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.AuthorizeNonceAccount;\n const data = encodeData(type, {\n authorized: toBuffer(params.newAuthorizedPubkey.toBuffer()),\n });\n\n return new TransactionInstruction({\n keys: [\n {pubkey: params.noncePubkey, isSigner: false, isWritable: true},\n {pubkey: params.authorizedPubkey, isSigner: true, isWritable: false},\n ],\n programId: this.programId,\n data,\n });\n }\n\n /**\n * Generate a transaction instruction that allocates space in an account without funding\n */\n static allocate(\n params: AllocateParams | AllocateWithSeedParams,\n ): TransactionInstruction {\n let data;\n let keys;\n if ('basePubkey' in params) {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.AllocateWithSeed;\n data = encodeData(type, {\n base: toBuffer(params.basePubkey.toBuffer()),\n seed: params.seed,\n space: params.space,\n programId: toBuffer(params.programId.toBuffer()),\n });\n keys = [\n {pubkey: params.accountPubkey, isSigner: false, isWritable: true},\n {pubkey: params.basePubkey, isSigner: true, isWritable: false},\n ];\n } else {\n const type = SYSTEM_INSTRUCTION_LAYOUTS.Allocate;\n data = encodeData(type, {\n space: params.space,\n });\n keys = [{pubkey: params.accountPubkey, isSigner: true, isWritable: true}];\n }\n\n return new TransactionInstruction({\n keys,\n programId: this.programId,\n data,\n });\n }\n}\n","import {Buffer} from 'buffer';\nimport * as BufferLayout from '@solana/buffer-layout';\n\nimport {PublicKey} from './publickey';\nimport {Transaction, PACKET_DATA_SIZE} from './transaction';\nimport {MS_PER_SLOT} from './timing';\nimport {SYSVAR_RENT_PUBKEY} from './sysvar';\nimport {sendAndConfirmTransaction} from './utils/send-and-confirm-transaction';\nimport {sleep} from './utils/sleep';\nimport type {Connection} from './connection';\nimport type {Signer} from './keypair';\nimport {SystemProgram} from './programs/system';\nimport {IInstructionInputData} from './instruction';\n\n// Keep program chunks under PACKET_DATA_SIZE, leaving enough room for the\n// rest of the Transaction fields\n//\n// TODO: replace 300 with a proper constant for the size of the other\n// Transaction fields\nconst CHUNK_SIZE = PACKET_DATA_SIZE - 300;\n\n/**\n * Program loader interface\n */\nexport class Loader {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Amount of program data placed in each load Transaction\n */\n static chunkSize: number = CHUNK_SIZE;\n\n /**\n * Minimum number of signatures required to load a program not including\n * retries\n *\n * Can be used to calculate transaction fees\n */\n static getMinNumSignatures(dataLength: number): number {\n return (\n 2 * // Every transaction requires two signatures (payer + program)\n (Math.ceil(dataLength / Loader.chunkSize) +\n 1 + // Add one for Create transaction\n 1) // Add one for Finalize transaction\n );\n }\n\n /**\n * Loads a generic program\n *\n * @param connection The connection to use\n * @param payer System account that pays to load the program\n * @param program Account to load the program into\n * @param programId Public key that identifies the loader\n * @param data Program octets\n * @return true if program was loaded successfully, false if program was already loaded\n */\n static async load(\n connection: Connection,\n payer: Signer,\n program: Signer,\n programId: PublicKey,\n data: Buffer | Uint8Array | Array,\n ): Promise {\n {\n const balanceNeeded = await connection.getMinimumBalanceForRentExemption(\n data.length,\n );\n\n // Fetch program account info to check if it has already been created\n const programInfo = await connection.getAccountInfo(\n program.publicKey,\n 'confirmed',\n );\n\n let transaction: Transaction | null = null;\n if (programInfo !== null) {\n if (programInfo.executable) {\n console.error('Program load failed, account is already executable');\n return false;\n }\n\n if (programInfo.data.length !== data.length) {\n transaction = transaction || new Transaction();\n transaction.add(\n SystemProgram.allocate({\n accountPubkey: program.publicKey,\n space: data.length,\n }),\n );\n }\n\n if (!programInfo.owner.equals(programId)) {\n transaction = transaction || new Transaction();\n transaction.add(\n SystemProgram.assign({\n accountPubkey: program.publicKey,\n programId,\n }),\n );\n }\n\n if (programInfo.lamports < balanceNeeded) {\n transaction = transaction || new Transaction();\n transaction.add(\n SystemProgram.transfer({\n fromPubkey: payer.publicKey,\n toPubkey: program.publicKey,\n lamports: balanceNeeded - programInfo.lamports,\n }),\n );\n }\n } else {\n transaction = new Transaction().add(\n SystemProgram.createAccount({\n fromPubkey: payer.publicKey,\n newAccountPubkey: program.publicKey,\n lamports: balanceNeeded > 0 ? balanceNeeded : 1,\n space: data.length,\n programId,\n }),\n );\n }\n\n // If the account is already created correctly, skip this step\n // and proceed directly to loading instructions\n if (transaction !== null) {\n await sendAndConfirmTransaction(\n connection,\n transaction,\n [payer, program],\n {\n commitment: 'confirmed',\n },\n );\n }\n }\n\n const dataLayout = BufferLayout.struct<\n Readonly<{\n bytes: number[];\n bytesLength: number;\n bytesLengthPadding: number;\n instruction: number;\n offset: number;\n }>\n >([\n BufferLayout.u32('instruction'),\n BufferLayout.u32('offset'),\n BufferLayout.u32('bytesLength'),\n BufferLayout.u32('bytesLengthPadding'),\n BufferLayout.seq(\n BufferLayout.u8('byte'),\n BufferLayout.offset(BufferLayout.u32(), -8),\n 'bytes',\n ),\n ]);\n\n const chunkSize = Loader.chunkSize;\n let offset = 0;\n let array = data;\n let transactions = [];\n while (array.length > 0) {\n const bytes = array.slice(0, chunkSize);\n const data = Buffer.alloc(chunkSize + 16);\n dataLayout.encode(\n {\n instruction: 0, // Load instruction\n offset,\n bytes: bytes as number[],\n bytesLength: 0,\n bytesLengthPadding: 0,\n },\n data,\n );\n\n const transaction = new Transaction().add({\n keys: [{pubkey: program.publicKey, isSigner: true, isWritable: true}],\n programId,\n data,\n });\n transactions.push(\n sendAndConfirmTransaction(connection, transaction, [payer, program], {\n commitment: 'confirmed',\n }),\n );\n\n // Delay between sends in an attempt to reduce rate limit errors\n if (connection._rpcEndpoint.includes('solana.com')) {\n const REQUESTS_PER_SECOND = 4;\n await sleep(1000 / REQUESTS_PER_SECOND);\n }\n\n offset += chunkSize;\n array = array.slice(chunkSize);\n }\n await Promise.all(transactions);\n\n // Finalize the account loaded with program data for execution\n {\n const dataLayout = BufferLayout.struct([\n BufferLayout.u32('instruction'),\n ]);\n\n const data = Buffer.alloc(dataLayout.span);\n dataLayout.encode(\n {\n instruction: 1, // Finalize instruction\n },\n data,\n );\n\n const transaction = new Transaction().add({\n keys: [\n {pubkey: program.publicKey, isSigner: true, isWritable: true},\n {pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false},\n ],\n programId,\n data,\n });\n const deployCommitment = 'processed';\n const finalizeSignature = await connection.sendTransaction(\n transaction,\n [payer, program],\n {preflightCommitment: deployCommitment},\n );\n const {context, value} = await connection.confirmTransaction(\n {\n signature: finalizeSignature,\n lastValidBlockHeight: transaction.lastValidBlockHeight!,\n blockhash: transaction.recentBlockhash!,\n },\n deployCommitment,\n );\n if (value.err) {\n throw new Error(\n `Transaction ${finalizeSignature} failed (${JSON.stringify(value)})`,\n );\n }\n // We prevent programs from being usable until the slot after their deployment.\n // See https://github.com/solana-labs/solana/pull/29654\n while (\n true // eslint-disable-line no-constant-condition\n ) {\n try {\n const currentSlot = await connection.getSlot({\n commitment: deployCommitment,\n });\n if (currentSlot > context.slot) {\n break;\n }\n } catch {\n /* empty */\n }\n await new Promise(resolve =>\n setTimeout(resolve, Math.round(MS_PER_SLOT / 2)),\n );\n }\n }\n\n // success\n return true;\n }\n}\n","import type {Buffer} from 'buffer';\n\nimport {PublicKey} from './publickey';\nimport {Loader} from './loader';\nimport type {Connection} from './connection';\nimport type {Signer} from './keypair';\n\n/**\n * @deprecated Deprecated since Solana v1.17.20.\n */\nexport const BPF_LOADER_PROGRAM_ID = new PublicKey(\n 'BPFLoader2111111111111111111111111111111111',\n);\n\n/**\n * Factory class for transactions to interact with a program loader\n *\n * @deprecated Deprecated since Solana v1.17.20.\n */\nexport class BpfLoader {\n /**\n * Minimum number of signatures required to load a program not including\n * retries\n *\n * Can be used to calculate transaction fees\n */\n static getMinNumSignatures(dataLength: number): number {\n return Loader.getMinNumSignatures(dataLength);\n }\n\n /**\n * Load a SBF program\n *\n * @param connection The connection to use\n * @param payer Account that will pay program loading fees\n * @param program Account to load the program into\n * @param elf The entire ELF containing the SBF program\n * @param loaderProgramId The program id of the BPF loader to use\n * @return true if program was loaded successfully, false if program was already loaded\n */\n static load(\n connection: Connection,\n payer: Signer,\n program: Signer,\n elf: Buffer | Uint8Array | Array,\n loaderProgramId: PublicKey,\n ): Promise {\n return Loader.load(connection, payer, program, loaderProgramId, elf);\n }\n}\n","var objToString = Object.prototype.toString;\nvar objKeys = Object.keys || function(obj) {\n\t\tvar keys = [];\n\t\tfor (var name in obj) {\n\t\t\tkeys.push(name);\n\t\t}\n\t\treturn keys;\n\t};\n\nfunction stringify(val, isArrayProp) {\n\tvar i, max, str, keys, key, propVal, toStr;\n\tif (val === true) {\n\t\treturn \"true\";\n\t}\n\tif (val === false) {\n\t\treturn \"false\";\n\t}\n\tswitch (typeof val) {\n\t\tcase \"object\":\n\t\t\tif (val === null) {\n\t\t\t\treturn null;\n\t\t\t} else if (val.toJSON && typeof val.toJSON === \"function\") {\n\t\t\t\treturn stringify(val.toJSON(), isArrayProp);\n\t\t\t} else {\n\t\t\t\ttoStr = objToString.call(val);\n\t\t\t\tif (toStr === \"[object Array]\") {\n\t\t\t\t\tstr = '[';\n\t\t\t\t\tmax = val.length - 1;\n\t\t\t\t\tfor(i = 0; i < max; i++) {\n\t\t\t\t\t\tstr += stringify(val[i], true) + ',';\n\t\t\t\t\t}\n\t\t\t\t\tif (max > -1) {\n\t\t\t\t\t\tstr += stringify(val[i], true);\n\t\t\t\t\t}\n\t\t\t\t\treturn str + ']';\n\t\t\t\t} else if (toStr === \"[object Object]\") {\n\t\t\t\t\t// only object is left\n\t\t\t\t\tkeys = objKeys(val).sort();\n\t\t\t\t\tmax = keys.length;\n\t\t\t\t\tstr = \"\";\n\t\t\t\t\ti = 0;\n\t\t\t\t\twhile (i < max) {\n\t\t\t\t\t\tkey = keys[i];\n\t\t\t\t\t\tpropVal = stringify(val[key], false);\n\t\t\t\t\t\tif (propVal !== undefined) {\n\t\t\t\t\t\t\tif (str) {\n\t\t\t\t\t\t\t\tstr += ',';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tstr += JSON.stringify(key) + ':' + propVal;\n\t\t\t\t\t\t}\n\t\t\t\t\t\ti++;\n\t\t\t\t\t}\n\t\t\t\t\treturn '{' + str + '}';\n\t\t\t\t} else {\n\t\t\t\t\treturn JSON.stringify(val);\n\t\t\t\t}\n\t\t\t}\n\t\tcase \"function\":\n\t\tcase \"undefined\":\n\t\t\treturn isArrayProp ? null : undefined;\n\t\tcase \"string\":\n\t\t\treturn JSON.stringify(val);\n\t\tdefault:\n\t\t\treturn isFinite(val) ? val : null;\n\t}\n}\n\nmodule.exports = function(val) {\n\tvar returnVal = stringify(val, false);\n\tif (returnVal !== undefined) {\n\t\treturn ''+ returnVal;\n\t}\n};\n","const MINIMUM_SLOT_PER_EPOCH = 32;\n\n// Returns the number of trailing zeros in the binary representation of self.\nfunction trailingZeros(n: number) {\n let trailingZeros = 0;\n while (n > 1) {\n n /= 2;\n trailingZeros++;\n }\n return trailingZeros;\n}\n\n// Returns the smallest power of two greater than or equal to n\nfunction nextPowerOfTwo(n: number) {\n if (n === 0) return 1;\n n--;\n n |= n >> 1;\n n |= n >> 2;\n n |= n >> 4;\n n |= n >> 8;\n n |= n >> 16;\n n |= n >> 32;\n return n + 1;\n}\n\n/**\n * Epoch schedule\n * (see https://docs.solana.com/terminology#epoch)\n * Can be retrieved with the {@link Connection.getEpochSchedule} method\n */\nexport class EpochSchedule {\n /** The maximum number of slots in each epoch */\n public slotsPerEpoch: number;\n /** The number of slots before beginning of an epoch to calculate a leader schedule for that epoch */\n public leaderScheduleSlotOffset: number;\n /** Indicates whether epochs start short and grow */\n public warmup: boolean;\n /** The first epoch with `slotsPerEpoch` slots */\n public firstNormalEpoch: number;\n /** The first slot of `firstNormalEpoch` */\n public firstNormalSlot: number;\n\n constructor(\n slotsPerEpoch: number,\n leaderScheduleSlotOffset: number,\n warmup: boolean,\n firstNormalEpoch: number,\n firstNormalSlot: number,\n ) {\n this.slotsPerEpoch = slotsPerEpoch;\n this.leaderScheduleSlotOffset = leaderScheduleSlotOffset;\n this.warmup = warmup;\n this.firstNormalEpoch = firstNormalEpoch;\n this.firstNormalSlot = firstNormalSlot;\n }\n\n getEpoch(slot: number): number {\n return this.getEpochAndSlotIndex(slot)[0];\n }\n\n getEpochAndSlotIndex(slot: number): [number, number] {\n if (slot < this.firstNormalSlot) {\n const epoch =\n trailingZeros(nextPowerOfTwo(slot + MINIMUM_SLOT_PER_EPOCH + 1)) -\n trailingZeros(MINIMUM_SLOT_PER_EPOCH) -\n 1;\n\n const epochLen = this.getSlotsInEpoch(epoch);\n const slotIndex = slot - (epochLen - MINIMUM_SLOT_PER_EPOCH);\n return [epoch, slotIndex];\n } else {\n const normalSlotIndex = slot - this.firstNormalSlot;\n const normalEpochIndex = Math.floor(normalSlotIndex / this.slotsPerEpoch);\n const epoch = this.firstNormalEpoch + normalEpochIndex;\n const slotIndex = normalSlotIndex % this.slotsPerEpoch;\n return [epoch, slotIndex];\n }\n }\n\n getFirstSlotInEpoch(epoch: number): number {\n if (epoch <= this.firstNormalEpoch) {\n return (Math.pow(2, epoch) - 1) * MINIMUM_SLOT_PER_EPOCH;\n } else {\n return (\n (epoch - this.firstNormalEpoch) * this.slotsPerEpoch +\n this.firstNormalSlot\n );\n }\n }\n\n getLastSlotInEpoch(epoch: number): number {\n return this.getFirstSlotInEpoch(epoch) + this.getSlotsInEpoch(epoch) - 1;\n }\n\n getSlotsInEpoch(epoch: number) {\n if (epoch < this.firstNormalEpoch) {\n return Math.pow(2, epoch + trailingZeros(MINIMUM_SLOT_PER_EPOCH));\n } else {\n return this.slotsPerEpoch;\n }\n }\n}\n","export const Headers: typeof globalThis.Headers = globalThis.Headers;\nexport const Request: typeof globalThis.Request = globalThis.Request;\nexport const Response: typeof globalThis.Response = globalThis.Response;\nexport default globalThis.fetch;\n","import {\n CommonClient,\n ICommonWebSocket,\n IWSClientAdditionalOptions,\n NodeWebSocketType,\n NodeWebSocketTypeOptions,\n WebSocket as createRpc,\n} from 'rpc-websockets';\n\ninterface IHasReadyState {\n readyState: WebSocket['readyState'];\n}\n\nexport default class RpcWebSocketClient extends CommonClient {\n private underlyingSocket: IHasReadyState | undefined;\n constructor(\n address?: string,\n options?: IWSClientAdditionalOptions & NodeWebSocketTypeOptions,\n generate_request_id?: (\n method: string,\n params: object | Array,\n ) => number,\n ) {\n const webSocketFactory = (url: string) => {\n const rpc = createRpc(url, {\n autoconnect: true,\n max_reconnects: 5,\n reconnect: true,\n reconnect_interval: 1000,\n ...options,\n });\n if ('socket' in rpc) {\n this.underlyingSocket = rpc.socket as ReturnType;\n } else {\n this.underlyingSocket = rpc as NodeWebSocketType;\n }\n return rpc as ICommonWebSocket;\n };\n super(webSocketFactory, address, options, generate_request_id);\n }\n call(\n ...args: Parameters\n ): ReturnType {\n const readyState = this.underlyingSocket?.readyState;\n if (readyState === 1 /* WebSocket.OPEN */) {\n return super.call(...args);\n }\n return Promise.reject(\n new Error(\n 'Tried to call a JSON-RPC method `' +\n args[0] +\n '` but the socket was not `CONNECTING` or `OPEN` (`readyState` was ' +\n readyState +\n ')',\n ),\n );\n }\n notify(\n ...args: Parameters\n ): ReturnType {\n const readyState = this.underlyingSocket?.readyState;\n if (readyState === 1 /* WebSocket.OPEN */) {\n return super.notify(...args);\n }\n return Promise.reject(\n new Error(\n 'Tried to send a JSON-RPC notification `' +\n args[0] +\n '` but the socket was not `CONNECTING` or `OPEN` (`readyState` was ' +\n readyState +\n ')',\n ),\n );\n }\n}\n","import * as BufferLayout from '@solana/buffer-layout';\n\nexport interface IAccountStateData {\n readonly typeIndex: number;\n}\n\n/**\n * @internal\n */\nexport type AccountType = {\n /** The account type index (from solana upstream program) */\n index: number;\n /** The BufferLayout to use to build data */\n layout: BufferLayout.Layout;\n};\n\n/**\n * Decode account data buffer using an AccountType\n * @internal\n */\nexport function decodeData(\n type: AccountType,\n data: Uint8Array,\n): TAccountStateData {\n let decoded: TAccountStateData;\n try {\n decoded = type.layout.decode(data);\n } catch (err) {\n throw new Error('invalid instruction; ' + err);\n }\n\n if (decoded.typeIndex !== type.index) {\n throw new Error(\n `invalid account data; account type mismatch ${decoded.typeIndex} != ${type.index}`,\n );\n }\n\n return decoded;\n}\n","import * as BufferLayout from '@solana/buffer-layout';\n\nimport assert from '../../utils/assert';\nimport * as Layout from '../../layout';\nimport {PublicKey} from '../../publickey';\nimport {u64} from '../../utils/bigint';\nimport {decodeData} from '../../account-data';\n\nexport type AddressLookupTableState = {\n deactivationSlot: bigint;\n lastExtendedSlot: number;\n lastExtendedSlotStartIndex: number;\n authority?: PublicKey;\n addresses: Array;\n};\n\nexport type AddressLookupTableAccountArgs = {\n key: PublicKey;\n state: AddressLookupTableState;\n};\n\n/// The serialized size of lookup table metadata\nconst LOOKUP_TABLE_META_SIZE = 56;\n\nexport class AddressLookupTableAccount {\n key: PublicKey;\n state: AddressLookupTableState;\n\n constructor(args: AddressLookupTableAccountArgs) {\n this.key = args.key;\n this.state = args.state;\n }\n\n isActive(): boolean {\n const U64_MAX = BigInt('0xffffffffffffffff');\n return this.state.deactivationSlot === U64_MAX;\n }\n\n static deserialize(accountData: Uint8Array): AddressLookupTableState {\n const meta = decodeData(LookupTableMetaLayout, accountData);\n\n const serializedAddressesLen = accountData.length - LOOKUP_TABLE_META_SIZE;\n assert(serializedAddressesLen >= 0, 'lookup table is invalid');\n assert(serializedAddressesLen % 32 === 0, 'lookup table is invalid');\n\n const numSerializedAddresses = serializedAddressesLen / 32;\n const {addresses} = BufferLayout.struct<{addresses: Array}>([\n BufferLayout.seq(Layout.publicKey(), numSerializedAddresses, 'addresses'),\n ]).decode(accountData.slice(LOOKUP_TABLE_META_SIZE));\n\n return {\n deactivationSlot: meta.deactivationSlot,\n lastExtendedSlot: meta.lastExtendedSlot,\n lastExtendedSlotStartIndex: meta.lastExtendedStartIndex,\n authority:\n meta.authority.length !== 0\n ? new PublicKey(meta.authority[0])\n : undefined,\n addresses: addresses.map(address => new PublicKey(address)),\n };\n }\n}\n\nconst LookupTableMetaLayout = {\n index: 1,\n layout: BufferLayout.struct<{\n typeIndex: number;\n deactivationSlot: bigint;\n lastExtendedSlot: number;\n lastExtendedStartIndex: number;\n authority: Array;\n }>([\n BufferLayout.u32('typeIndex'),\n u64('deactivationSlot'),\n BufferLayout.nu64('lastExtendedSlot'),\n BufferLayout.u8('lastExtendedStartIndex'),\n BufferLayout.u8(), // option\n BufferLayout.seq(\n Layout.publicKey(),\n BufferLayout.offset(BufferLayout.u8(), -1),\n 'authority',\n ),\n ]),\n};\n","const URL_RE = /^[^:]+:\\/\\/([^:[]+|\\[[^\\]]+\\])(:\\d+)?(.*)/i;\n\nexport function makeWebsocketUrl(endpoint: string) {\n const matches = endpoint.match(URL_RE);\n if (matches == null) {\n throw TypeError(`Failed to validate endpoint URL \\`${endpoint}\\``);\n }\n const [\n _, // eslint-disable-line @typescript-eslint/no-unused-vars\n hostish,\n portWithColon,\n rest,\n ] = matches;\n const protocol = endpoint.startsWith('https:') ? 'wss:' : 'ws:';\n const startPort =\n portWithColon == null ? null : parseInt(portWithColon.slice(1), 10);\n const websocketPort =\n // Only shift the port by +1 as a convention for ws(s) only if given endpoint\n // is explicitly specifying the endpoint port (HTTP-based RPC), assuming\n // we're directly trying to connect to agave-validator's ws listening port.\n // When the endpoint omits the port, we're connecting to the protocol\n // default ports: http(80) or https(443) and it's assumed we're behind a reverse\n // proxy which manages WebSocket upgrade and backend port redirection.\n startPort == null ? '' : `:${startPort + 1}`;\n return `${protocol}//${hostish}${websocketPort}${rest}`;\n}\n","import HttpKeepAliveAgent, {\n HttpsAgent as HttpsKeepAliveAgent,\n} from 'agentkeepalive';\nimport bs58 from 'bs58';\nimport {Buffer} from 'buffer';\n// @ts-ignore\nimport fastStableStringify from 'fast-stable-stringify';\nimport type {Agent as NodeHttpAgent} from 'http';\nimport {Agent as NodeHttpsAgent} from 'https';\nimport {\n type as pick,\n number,\n string,\n array,\n boolean,\n literal,\n record,\n union,\n optional,\n nullable,\n coerce,\n instance,\n create,\n tuple,\n unknown,\n any,\n} from 'superstruct';\nimport type {Struct} from 'superstruct';\nimport RpcClient from 'jayson/lib/client/browser';\nimport {JSONRPCError} from 'jayson';\n\nimport {EpochSchedule} from './epoch-schedule';\nimport {SendTransactionError, SolanaJSONRPCError} from './errors';\nimport fetchImpl from './fetch-impl';\nimport {DurableNonce, NonceAccount} from './nonce-account';\nimport {PublicKey} from './publickey';\nimport {Signer} from './keypair';\nimport RpcWebSocketClient from './rpc-websocket';\nimport {MS_PER_SLOT} from './timing';\nimport {\n Transaction,\n TransactionStatus,\n TransactionVersion,\n VersionedTransaction,\n} from './transaction';\nimport {Message, MessageHeader, MessageV0, VersionedMessage} from './message';\nimport {AddressLookupTableAccount} from './programs/address-lookup-table/state';\nimport assert from './utils/assert';\nimport {sleep} from './utils/sleep';\nimport {toBuffer} from './utils/to-buffer';\nimport {\n TransactionExpiredBlockheightExceededError,\n TransactionExpiredNonceInvalidError,\n TransactionExpiredTimeoutError,\n} from './transaction/expiry-custom-errors';\nimport {makeWebsocketUrl} from './utils/makeWebsocketUrl';\nimport type {Blockhash} from './blockhash';\nimport type {FeeCalculator} from './fee-calculator';\nimport type {TransactionSignature} from './transaction';\nimport type {CompiledInstruction} from './message';\n\nconst PublicKeyFromString = coerce(\n instance(PublicKey),\n string(),\n value => new PublicKey(value),\n);\n\nconst RawAccountDataResult = tuple([string(), literal('base64')]);\n\nconst BufferFromRawAccountData = coerce(\n instance(Buffer),\n RawAccountDataResult,\n value => Buffer.from(value[0], 'base64'),\n);\n\n/**\n * Attempt to use a recent blockhash for up to 30 seconds\n * @internal\n */\nexport const BLOCKHASH_CACHE_TIMEOUT_MS = 30 * 1000;\n\n/**\n * HACK.\n * Copied from rpc-websockets/dist/lib/client.\n * Otherwise, `yarn build` fails with:\n * https://gist.github.com/steveluscher/c057eca81d479ef705cdb53162f9971d\n */\ninterface IWSRequestParams {\n [x: string]: any;\n [x: number]: any;\n}\n\ntype ClientSubscriptionId = number;\n/** @internal */ type ServerSubscriptionId = number;\n/** @internal */ type SubscriptionConfigHash = string;\n/** @internal */ type SubscriptionDisposeFn = () => Promise;\n/** @internal */ type SubscriptionStateChangeCallback = (\n nextState: StatefulSubscription['state'],\n) => void;\n/** @internal */ type SubscriptionStateChangeDisposeFn = () => void;\n/**\n * @internal\n * Every subscription contains the args used to open the subscription with\n * the server, and a list of callers interested in notifications.\n */\ntype BaseSubscription = Readonly<{\n args: IWSRequestParams;\n callbacks: Set['callback']>;\n}>;\n/**\n * @internal\n * A subscription may be in various states of connectedness. Only when it is\n * fully connected will it have a server subscription id associated with it.\n * This id can be returned to the server to unsubscribe the client entirely.\n */\ntype StatefulSubscription = Readonly<\n // New subscriptions that have not yet been\n // sent to the server start in this state.\n | {\n state: 'pending';\n }\n // These subscriptions have been sent to the server\n // and are waiting for the server to acknowledge them.\n | {\n state: 'subscribing';\n }\n // These subscriptions have been acknowledged by the\n // server and have been assigned server subscription ids.\n | {\n serverSubscriptionId: ServerSubscriptionId;\n state: 'subscribed';\n }\n // These subscriptions are intended to be torn down and\n // are waiting on an acknowledgement from the server.\n | {\n serverSubscriptionId: ServerSubscriptionId;\n state: 'unsubscribing';\n }\n // The request to tear down these subscriptions has been\n // acknowledged by the server. The `serverSubscriptionId`\n // is the id of the now-dead subscription.\n | {\n serverSubscriptionId: ServerSubscriptionId;\n state: 'unsubscribed';\n }\n>;\n/**\n * A type that encapsulates a subscription's RPC method\n * names and notification (callback) signature.\n */\ntype SubscriptionConfig = Readonly<\n | {\n callback: AccountChangeCallback;\n method: 'accountSubscribe';\n unsubscribeMethod: 'accountUnsubscribe';\n }\n | {\n callback: LogsCallback;\n method: 'logsSubscribe';\n unsubscribeMethod: 'logsUnsubscribe';\n }\n | {\n callback: ProgramAccountChangeCallback;\n method: 'programSubscribe';\n unsubscribeMethod: 'programUnsubscribe';\n }\n | {\n callback: RootChangeCallback;\n method: 'rootSubscribe';\n unsubscribeMethod: 'rootUnsubscribe';\n }\n | {\n callback: SignatureSubscriptionCallback;\n method: 'signatureSubscribe';\n unsubscribeMethod: 'signatureUnsubscribe';\n }\n | {\n callback: SlotChangeCallback;\n method: 'slotSubscribe';\n unsubscribeMethod: 'slotUnsubscribe';\n }\n | {\n callback: SlotUpdateCallback;\n method: 'slotsUpdatesSubscribe';\n unsubscribeMethod: 'slotsUpdatesUnsubscribe';\n }\n>;\n/**\n * @internal\n * Utility type that keeps tagged unions intact while omitting properties.\n */\ntype DistributiveOmit = T extends unknown\n ? Omit\n : never;\n/**\n * @internal\n * This type represents a single subscribable 'topic.' It's made up of:\n *\n * - The args used to open the subscription with the server,\n * - The state of the subscription, in terms of its connectedness, and\n * - The set of callbacks to call when the server publishes notifications\n *\n * This record gets indexed by `SubscriptionConfigHash` and is used to\n * set up subscriptions, fan out notifications, and track subscription state.\n */\ntype Subscription = BaseSubscription &\n StatefulSubscription &\n DistributiveOmit;\n\ntype RpcRequest = (methodName: string, args: Array) => Promise;\n\ntype RpcBatchRequest = (requests: RpcParams[]) => Promise;\n\n/**\n * @internal\n */\nexport type RpcParams = {\n methodName: string;\n args: Array;\n};\n\nexport type TokenAccountsFilter =\n | {\n mint: PublicKey;\n }\n | {\n programId: PublicKey;\n };\n\n/**\n * Extra contextual information for RPC responses\n */\nexport type Context = {\n slot: number;\n};\n\n/**\n * Options for sending transactions\n */\nexport type SendOptions = {\n /** disable transaction verification step */\n skipPreflight?: boolean;\n /** preflight commitment level */\n preflightCommitment?: Commitment;\n /** Maximum number of times for the RPC node to retry sending the transaction to the leader. */\n maxRetries?: number;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * Options for confirming transactions\n */\nexport type ConfirmOptions = {\n /** disable transaction verification step */\n skipPreflight?: boolean;\n /** desired commitment level */\n commitment?: Commitment;\n /** preflight commitment level */\n preflightCommitment?: Commitment;\n /** Maximum number of times for the RPC node to retry sending the transaction to the leader. */\n maxRetries?: number;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * Options for getConfirmedSignaturesForAddress2\n */\nexport type ConfirmedSignaturesForAddress2Options = {\n /**\n * Start searching backwards from this transaction signature.\n * @remarks If not provided the search starts from the highest max confirmed block.\n */\n before?: TransactionSignature;\n /** Search until this transaction signature is reached, if found before `limit`. */\n until?: TransactionSignature;\n /** Maximum transaction signatures to return (between 1 and 1,000, default: 1,000). */\n limit?: number;\n};\n\n/**\n * Options for getSignaturesForAddress\n */\nexport type SignaturesForAddressOptions = {\n /**\n * Start searching backwards from this transaction signature.\n * @remarks If not provided the search starts from the highest max confirmed block.\n */\n before?: TransactionSignature;\n /** Search until this transaction signature is reached, if found before `limit`. */\n until?: TransactionSignature;\n /** Maximum transaction signatures to return (between 1 and 1,000, default: 1,000). */\n limit?: number;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * RPC Response with extra contextual information\n */\nexport type RpcResponseAndContext = {\n /** response context */\n context: Context;\n /** response value */\n value: T;\n};\n\nexport type BlockhashWithExpiryBlockHeight = Readonly<{\n blockhash: Blockhash;\n lastValidBlockHeight: number;\n}>;\n\n/**\n * A strategy for confirming transactions that uses the last valid\n * block height for a given blockhash to check for transaction expiration.\n */\nexport type BlockheightBasedTransactionConfirmationStrategy =\n BaseTransactionConfirmationStrategy & BlockhashWithExpiryBlockHeight;\n\n/**\n * A strategy for confirming durable nonce transactions.\n */\nexport type DurableNonceTransactionConfirmationStrategy =\n BaseTransactionConfirmationStrategy & {\n /**\n * The lowest slot at which to fetch the nonce value from the\n * nonce account. This should be no lower than the slot at\n * which the last-known value of the nonce was fetched.\n */\n minContextSlot: number;\n /**\n * The account where the current value of the nonce is stored.\n */\n nonceAccountPubkey: PublicKey;\n /**\n * The nonce value that was used to sign the transaction\n * for which confirmation is being sought.\n */\n nonceValue: DurableNonce;\n };\n\n/**\n * Properties shared by all transaction confirmation strategies\n */\nexport type BaseTransactionConfirmationStrategy = Readonly<{\n /** A signal that, when aborted, cancels any outstanding transaction confirmation operations */\n abortSignal?: AbortSignal;\n signature: TransactionSignature;\n}>;\n\n/**\n * This type represents all transaction confirmation strategies\n */\nexport type TransactionConfirmationStrategy =\n | BlockheightBasedTransactionConfirmationStrategy\n | DurableNonceTransactionConfirmationStrategy;\n\n/* @internal */\nfunction assertEndpointUrl(putativeUrl: string) {\n if (/^https?:/.test(putativeUrl) === false) {\n throw new TypeError('Endpoint URL must start with `http:` or `https:`.');\n }\n return putativeUrl;\n}\n\n/** @internal */\nfunction extractCommitmentFromConfig(\n commitmentOrConfig?: Commitment | ({commitment?: Commitment} & TConfig),\n) {\n let commitment: Commitment | undefined;\n let config: Omit | undefined;\n if (typeof commitmentOrConfig === 'string') {\n commitment = commitmentOrConfig;\n } else if (commitmentOrConfig) {\n const {commitment: specifiedCommitment, ...specifiedConfig} =\n commitmentOrConfig;\n commitment = specifiedCommitment;\n config = specifiedConfig;\n }\n return {commitment, config};\n}\n\n/**\n * @internal\n */\nfunction applyDefaultMemcmpEncodingToFilters(\n filters: GetProgramAccountsFilter[],\n): GetProgramAccountsFilter[] {\n return filters.map(filter =>\n 'memcmp' in filter\n ? {\n ...filter,\n memcmp: {\n ...filter.memcmp,\n encoding: filter.memcmp.encoding ?? 'base58',\n },\n }\n : filter,\n );\n}\n\n/**\n * @internal\n */\nfunction createRpcResult(result: Struct) {\n return union([\n pick({\n jsonrpc: literal('2.0'),\n id: string(),\n result,\n }),\n pick({\n jsonrpc: literal('2.0'),\n id: string(),\n error: pick({\n code: unknown(),\n message: string(),\n data: optional(any()),\n }),\n }),\n ]);\n}\n\nconst UnknownRpcResult = createRpcResult(unknown());\n\n/**\n * @internal\n */\nfunction jsonRpcResult(schema: Struct) {\n return coerce(createRpcResult(schema), UnknownRpcResult, value => {\n if ('error' in value) {\n return value;\n } else {\n return {\n ...value,\n result: create(value.result, schema),\n };\n }\n });\n}\n\n/**\n * @internal\n */\nfunction jsonRpcResultAndContext(value: Struct) {\n return jsonRpcResult(\n pick({\n context: pick({\n slot: number(),\n }),\n value,\n }),\n );\n}\n\n/**\n * @internal\n */\nfunction notificationResultAndContext(value: Struct) {\n return pick({\n context: pick({\n slot: number(),\n }),\n value,\n });\n}\n\n/**\n * @internal\n */\nfunction versionedMessageFromResponse(\n version: TransactionVersion | undefined,\n response: MessageResponse,\n): VersionedMessage {\n if (version === 0) {\n return new MessageV0({\n header: response.header,\n staticAccountKeys: response.accountKeys.map(\n accountKey => new PublicKey(accountKey),\n ),\n recentBlockhash: response.recentBlockhash,\n compiledInstructions: response.instructions.map(ix => ({\n programIdIndex: ix.programIdIndex,\n accountKeyIndexes: ix.accounts,\n data: bs58.decode(ix.data),\n })),\n addressTableLookups: response.addressTableLookups!,\n });\n } else {\n return new Message(response);\n }\n}\n\n/**\n * The level of commitment desired when querying state\n *
\n *   'processed': Query the most recent block which has reached 1 confirmation by the connected node\n *   'confirmed': Query the most recent block which has reached 1 confirmation by the cluster\n *   'finalized': Query the most recent block which has been finalized by the cluster\n * 
\n */\nexport type Commitment =\n | 'processed'\n | 'confirmed'\n | 'finalized'\n | 'recent' // Deprecated as of v1.5.5\n | 'single' // Deprecated as of v1.5.5\n | 'singleGossip' // Deprecated as of v1.5.5\n | 'root' // Deprecated as of v1.5.5\n | 'max'; // Deprecated as of v1.5.5\n\n/**\n * A subset of Commitment levels, which are at least optimistically confirmed\n *
\n *   'confirmed': Query the most recent block which has reached 1 confirmation by the cluster\n *   'finalized': Query the most recent block which has been finalized by the cluster\n * 
\n */\nexport type Finality = 'confirmed' | 'finalized';\n\n/**\n * Filter for largest accounts query\n *
\n *   'circulating':    Return the largest accounts that are part of the circulating supply\n *   'nonCirculating': Return the largest accounts that are not part of the circulating supply\n * 
\n */\nexport type LargestAccountsFilter = 'circulating' | 'nonCirculating';\n\n/**\n * Configuration object for changing `getAccountInfo` query behavior\n */\nexport type GetAccountInfoConfig = {\n /** The level of commitment desired */\n commitment?: Commitment;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n /** Optional data slice to limit the returned account data */\n dataSlice?: DataSlice;\n};\n\n/**\n * Configuration object for changing `getBalance` query behavior\n */\nexport type GetBalanceConfig = {\n /** The level of commitment desired */\n commitment?: Commitment;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * Configuration object for changing `getBlock` query behavior\n */\nexport type GetBlockConfig = {\n /** The level of finality desired */\n commitment?: Finality;\n /**\n * Whether to populate the rewards array. If parameter not provided, the default includes rewards.\n */\n rewards?: boolean;\n /**\n * Level of transaction detail to return, either \"full\", \"accounts\", \"signatures\", or \"none\". If\n * parameter not provided, the default detail level is \"full\". If \"accounts\" are requested,\n * transaction details only include signatures and an annotated list of accounts in each\n * transaction. Transaction metadata is limited to only: fee, err, pre_balances, post_balances,\n * pre_token_balances, and post_token_balances.\n */\n transactionDetails?: 'accounts' | 'full' | 'none' | 'signatures';\n};\n\n/**\n * Configuration object for changing `getBlock` query behavior\n */\nexport type GetVersionedBlockConfig = {\n /** The level of finality desired */\n commitment?: Finality;\n /** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */\n maxSupportedTransactionVersion?: number;\n /**\n * Whether to populate the rewards array. If parameter not provided, the default includes rewards.\n */\n rewards?: boolean;\n /**\n * Level of transaction detail to return, either \"full\", \"accounts\", \"signatures\", or \"none\". If\n * parameter not provided, the default detail level is \"full\". If \"accounts\" are requested,\n * transaction details only include signatures and an annotated list of accounts in each\n * transaction. Transaction metadata is limited to only: fee, err, pre_balances, post_balances,\n * pre_token_balances, and post_token_balances.\n */\n transactionDetails?: 'accounts' | 'full' | 'none' | 'signatures';\n};\n\n/**\n * Configuration object for changing `getStakeMinimumDelegation` query behavior\n */\nexport type GetStakeMinimumDelegationConfig = {\n /** The level of commitment desired */\n commitment?: Commitment;\n};\n\n/**\n * Configuration object for changing `getBlockHeight` query behavior\n */\nexport type GetBlockHeightConfig = {\n /** The level of commitment desired */\n commitment?: Commitment;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * Configuration object for changing `getEpochInfo` query behavior\n */\nexport type GetEpochInfoConfig = {\n /** The level of commitment desired */\n commitment?: Commitment;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * Configuration object for changing `getInflationReward` query behavior\n */\nexport type GetInflationRewardConfig = {\n /** The level of commitment desired */\n commitment?: Commitment;\n /** An epoch for which the reward occurs. If omitted, the previous epoch will be used */\n epoch?: number;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * Configuration object for changing `getLatestBlockhash` query behavior\n */\nexport type GetLatestBlockhashConfig = {\n /** The level of commitment desired */\n commitment?: Commitment;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * Configuration object for changing `isBlockhashValid` query behavior\n */\nexport type IsBlockhashValidConfig = {\n /** The level of commitment desired */\n commitment?: Commitment;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * Configuration object for changing `getSlot` query behavior\n */\nexport type GetSlotConfig = {\n /** The level of commitment desired */\n commitment?: Commitment;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * Configuration object for changing `getSlotLeader` query behavior\n */\nexport type GetSlotLeaderConfig = {\n /** The level of commitment desired */\n commitment?: Commitment;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * Configuration object for changing `getTransaction` query behavior\n */\nexport type GetTransactionConfig = {\n /** The level of finality desired */\n commitment?: Finality;\n};\n\n/**\n * Configuration object for changing `getTransaction` query behavior\n */\nexport type GetVersionedTransactionConfig = {\n /** The level of finality desired */\n commitment?: Finality;\n /** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */\n maxSupportedTransactionVersion?: number;\n};\n\n/**\n * Configuration object for changing `getLargestAccounts` query behavior\n */\nexport type GetLargestAccountsConfig = {\n /** The level of commitment desired */\n commitment?: Commitment;\n /** Filter largest accounts by whether they are part of the circulating supply */\n filter?: LargestAccountsFilter;\n};\n\n/**\n * Configuration object for changing `getSupply` request behavior\n */\nexport type GetSupplyConfig = {\n /** The level of commitment desired */\n commitment?: Commitment;\n /** Exclude non circulating accounts list from response */\n excludeNonCirculatingAccountsList?: boolean;\n};\n\n/**\n * Configuration object for changing query behavior\n */\nexport type SignatureStatusConfig = {\n /** enable searching status history, not needed for recent transactions */\n searchTransactionHistory: boolean;\n};\n\n/**\n * Information describing a cluster node\n */\nexport type ContactInfo = {\n /** Identity public key of the node */\n pubkey: string;\n /** Gossip network address for the node */\n gossip: string | null;\n /** TPU network address for the node (null if not available) */\n tpu: string | null;\n /** JSON RPC network address for the node (null if not available) */\n rpc: string | null;\n /** Software version of the node (null if not available) */\n version: string | null;\n};\n\n/**\n * Information describing a vote account\n */\nexport type VoteAccountInfo = {\n /** Public key of the vote account */\n votePubkey: string;\n /** Identity public key of the node voting with this account */\n nodePubkey: string;\n /** The stake, in lamports, delegated to this vote account and activated */\n activatedStake: number;\n /** Whether the vote account is staked for this epoch */\n epochVoteAccount: boolean;\n /** Recent epoch voting credit history for this voter */\n epochCredits: Array<[number, number, number]>;\n /** A percentage (0-100) of rewards payout owed to the voter */\n commission: number;\n /** Most recent slot voted on by this vote account */\n lastVote: number;\n};\n\n/**\n * A collection of cluster vote accounts\n */\nexport type VoteAccountStatus = {\n /** Active vote accounts */\n current: Array;\n /** Inactive vote accounts */\n delinquent: Array;\n};\n\n/**\n * Network Inflation\n * (see https://docs.solana.com/implemented-proposals/ed_overview)\n */\nexport type InflationGovernor = {\n foundation: number;\n foundationTerm: number;\n initial: number;\n taper: number;\n terminal: number;\n};\n\nconst GetInflationGovernorResult = pick({\n foundation: number(),\n foundationTerm: number(),\n initial: number(),\n taper: number(),\n terminal: number(),\n});\n\n/**\n * The inflation reward for an epoch\n */\nexport type InflationReward = {\n /** epoch for which the reward occurs */\n epoch: number;\n /** the slot in which the rewards are effective */\n effectiveSlot: number;\n /** reward amount in lamports */\n amount: number;\n /** post balance of the account in lamports */\n postBalance: number;\n /** vote account commission when the reward was credited */\n commission?: number | null;\n};\n\n/**\n * Expected JSON RPC response for the \"getInflationReward\" message\n */\nconst GetInflationRewardResult = jsonRpcResult(\n array(\n nullable(\n pick({\n epoch: number(),\n effectiveSlot: number(),\n amount: number(),\n postBalance: number(),\n commission: optional(nullable(number())),\n }),\n ),\n ),\n);\n\nexport type RecentPrioritizationFees = {\n /** slot in which the fee was observed */\n slot: number;\n /** the per-compute-unit fee paid by at least one successfully landed transaction, specified in increments of 0.000001 lamports*/\n prioritizationFee: number;\n};\n\n/**\n * Configuration object for changing `getRecentPrioritizationFees` query behavior\n */\nexport type GetRecentPrioritizationFeesConfig = {\n /**\n * If this parameter is provided, the response will reflect a fee to land a transaction locking\n * all of the provided accounts as writable.\n */\n lockedWritableAccounts?: PublicKey[];\n};\n\n/**\n * Expected JSON RPC response for the \"getRecentPrioritizationFees\" message\n */\nconst GetRecentPrioritizationFeesResult = array(\n pick({\n slot: number(),\n prioritizationFee: number(),\n }),\n);\n\nexport type InflationRate = {\n /** total inflation */\n total: number;\n /** inflation allocated to validators */\n validator: number;\n /** inflation allocated to the foundation */\n foundation: number;\n /** epoch for which these values are valid */\n epoch: number;\n};\n\n/**\n * Expected JSON RPC response for the \"getInflationRate\" message\n */\nconst GetInflationRateResult = pick({\n total: number(),\n validator: number(),\n foundation: number(),\n epoch: number(),\n});\n\n/**\n * Information about the current epoch\n */\nexport type EpochInfo = {\n epoch: number;\n slotIndex: number;\n slotsInEpoch: number;\n absoluteSlot: number;\n blockHeight?: number;\n transactionCount?: number;\n};\n\nconst GetEpochInfoResult = pick({\n epoch: number(),\n slotIndex: number(),\n slotsInEpoch: number(),\n absoluteSlot: number(),\n blockHeight: optional(number()),\n transactionCount: optional(number()),\n});\n\nconst GetEpochScheduleResult = pick({\n slotsPerEpoch: number(),\n leaderScheduleSlotOffset: number(),\n warmup: boolean(),\n firstNormalEpoch: number(),\n firstNormalSlot: number(),\n});\n\n/**\n * Leader schedule\n * (see https://docs.solana.com/terminology#leader-schedule)\n */\nexport type LeaderSchedule = {\n [address: string]: number[];\n};\n\nconst GetLeaderScheduleResult = record(string(), array(number()));\n\n/**\n * Transaction error or null\n */\nconst TransactionErrorResult = nullable(union([pick({}), string()]));\n\n/**\n * Signature status for a transaction\n */\nconst SignatureStatusResult = pick({\n err: TransactionErrorResult,\n});\n\n/**\n * Transaction signature received notification\n */\nconst SignatureReceivedResult = literal('receivedSignature');\n\n/**\n * Version info for a node\n */\nexport type Version = {\n /** Version of solana-core */\n 'solana-core': string;\n 'feature-set'?: number;\n};\n\nconst VersionResult = pick({\n 'solana-core': string(),\n 'feature-set': optional(number()),\n});\n\nexport type SimulatedTransactionAccountInfo = {\n /** `true` if this account's data contains a loaded program */\n executable: boolean;\n /** Identifier of the program that owns the account */\n owner: string;\n /** Number of lamports assigned to the account */\n lamports: number;\n /** Optional data assigned to the account */\n data: string[];\n /** Optional rent epoch info for account */\n rentEpoch?: number;\n};\n\nexport type TransactionReturnDataEncoding = 'base64';\n\nexport type TransactionReturnData = {\n programId: string;\n data: [string, TransactionReturnDataEncoding];\n};\n\nexport type SimulateTransactionConfig = {\n /** Optional parameter used to enable signature verification before simulation */\n sigVerify?: boolean;\n /** Optional parameter used to replace the simulated transaction's recent blockhash with the latest blockhash */\n replaceRecentBlockhash?: boolean;\n /** Optional parameter used to set the commitment level when selecting the latest block */\n commitment?: Commitment;\n /** Optional parameter used to specify a list of base58-encoded account addresses to return post simulation state for */\n accounts?: {\n /** The encoding of the returned account's data */\n encoding: 'base64';\n addresses: string[];\n };\n /** Optional parameter used to specify the minimum block slot that can be used for simulation */\n minContextSlot?: number;\n /** Optional parameter used to include inner instructions in the simulation */\n innerInstructions?: boolean;\n};\n\nexport type SimulatedTransactionResponse = {\n err: TransactionError | string | null;\n logs: Array | null;\n accounts?: (SimulatedTransactionAccountInfo | null)[] | null;\n unitsConsumed?: number;\n returnData?: TransactionReturnData | null;\n innerInstructions?: ParsedInnerInstruction[] | null;\n};\nconst ParsedInstructionStruct = pick({\n program: string(),\n programId: PublicKeyFromString,\n parsed: unknown(),\n});\n\nconst PartiallyDecodedInstructionStruct = pick({\n programId: PublicKeyFromString,\n accounts: array(PublicKeyFromString),\n data: string(),\n});\n\nconst SimulatedTransactionResponseStruct = jsonRpcResultAndContext(\n pick({\n err: nullable(union([pick({}), string()])),\n logs: nullable(array(string())),\n accounts: optional(\n nullable(\n array(\n nullable(\n pick({\n executable: boolean(),\n owner: string(),\n lamports: number(),\n data: array(string()),\n rentEpoch: optional(number()),\n }),\n ),\n ),\n ),\n ),\n unitsConsumed: optional(number()),\n returnData: optional(\n nullable(\n pick({\n programId: string(),\n data: tuple([string(), literal('base64')]),\n }),\n ),\n ),\n innerInstructions: optional(\n nullable(\n array(\n pick({\n index: number(),\n instructions: array(\n union([\n ParsedInstructionStruct,\n PartiallyDecodedInstructionStruct,\n ]),\n ),\n }),\n ),\n ),\n ),\n }),\n);\n\nexport type ParsedInnerInstruction = {\n index: number;\n instructions: (ParsedInstruction | PartiallyDecodedInstruction)[];\n};\n\nexport type TokenBalance = {\n accountIndex: number;\n mint: string;\n owner?: string;\n programId?: string;\n uiTokenAmount: TokenAmount;\n};\n\n/**\n * Metadata for a parsed confirmed transaction on the ledger\n *\n * @deprecated Deprecated since RPC v1.8.0. Please use {@link ParsedTransactionMeta} instead.\n */\nexport type ParsedConfirmedTransactionMeta = ParsedTransactionMeta;\n\n/**\n * Collection of addresses loaded by a transaction using address table lookups\n */\nexport type LoadedAddresses = {\n writable: Array;\n readonly: Array;\n};\n\n/**\n * Metadata for a parsed transaction on the ledger\n */\nexport type ParsedTransactionMeta = {\n /** The fee charged for processing the transaction */\n fee: number;\n /** An array of cross program invoked parsed instructions */\n innerInstructions?: ParsedInnerInstruction[] | null;\n /** The balances of the transaction accounts before processing */\n preBalances: Array;\n /** The balances of the transaction accounts after processing */\n postBalances: Array;\n /** An array of program log messages emitted during a transaction */\n logMessages?: Array | null;\n /** The token balances of the transaction accounts before processing */\n preTokenBalances?: Array | null;\n /** The token balances of the transaction accounts after processing */\n postTokenBalances?: Array | null;\n /** The error result of transaction processing */\n err: TransactionError | null;\n /** The collection of addresses loaded using address lookup tables */\n loadedAddresses?: LoadedAddresses;\n /** The compute units consumed after processing the transaction */\n computeUnitsConsumed?: number;\n};\n\nexport type CompiledInnerInstruction = {\n index: number;\n instructions: CompiledInstruction[];\n};\n\n/**\n * Metadata for a confirmed transaction on the ledger\n */\nexport type ConfirmedTransactionMeta = {\n /** The fee charged for processing the transaction */\n fee: number;\n /** An array of cross program invoked instructions */\n innerInstructions?: CompiledInnerInstruction[] | null;\n /** The balances of the transaction accounts before processing */\n preBalances: Array;\n /** The balances of the transaction accounts after processing */\n postBalances: Array;\n /** An array of program log messages emitted during a transaction */\n logMessages?: Array | null;\n /** The token balances of the transaction accounts before processing */\n preTokenBalances?: Array | null;\n /** The token balances of the transaction accounts after processing */\n postTokenBalances?: Array | null;\n /** The error result of transaction processing */\n err: TransactionError | null;\n /** The collection of addresses loaded using address lookup tables */\n loadedAddresses?: LoadedAddresses;\n /** The compute units consumed after processing the transaction */\n computeUnitsConsumed?: number;\n};\n\n/**\n * A processed transaction from the RPC API\n */\nexport type TransactionResponse = {\n /** The slot during which the transaction was processed */\n slot: number;\n /** The transaction */\n transaction: {\n /** The transaction message */\n message: Message;\n /** The transaction signatures */\n signatures: string[];\n };\n /** Metadata produced from the transaction */\n meta: ConfirmedTransactionMeta | null;\n /** The unix timestamp of when the transaction was processed */\n blockTime?: number | null;\n};\n\n/**\n * A processed transaction from the RPC API\n */\nexport type VersionedTransactionResponse = {\n /** The slot during which the transaction was processed */\n slot: number;\n /** The transaction */\n transaction: {\n /** The transaction message */\n message: VersionedMessage;\n /** The transaction signatures */\n signatures: string[];\n };\n /** Metadata produced from the transaction */\n meta: ConfirmedTransactionMeta | null;\n /** The unix timestamp of when the transaction was processed */\n blockTime?: number | null;\n /** The transaction version */\n version?: TransactionVersion;\n};\n\n/**\n * A processed transaction message from the RPC API\n */\ntype MessageResponse = {\n accountKeys: string[];\n header: MessageHeader;\n instructions: CompiledInstruction[];\n recentBlockhash: string;\n addressTableLookups?: ParsedAddressTableLookup[];\n};\n\n/**\n * A confirmed transaction on the ledger\n *\n * @deprecated Deprecated since RPC v1.8.0.\n */\nexport type ConfirmedTransaction = {\n /** The slot during which the transaction was processed */\n slot: number;\n /** The details of the transaction */\n transaction: Transaction;\n /** Metadata produced from the transaction */\n meta: ConfirmedTransactionMeta | null;\n /** The unix timestamp of when the transaction was processed */\n blockTime?: number | null;\n};\n\n/**\n * A partially decoded transaction instruction\n */\nexport type PartiallyDecodedInstruction = {\n /** Program id called by this instruction */\n programId: PublicKey;\n /** Public keys of accounts passed to this instruction */\n accounts: Array;\n /** Raw base-58 instruction data */\n data: string;\n};\n\n/**\n * A parsed transaction message account\n */\nexport type ParsedMessageAccount = {\n /** Public key of the account */\n pubkey: PublicKey;\n /** Indicates if the account signed the transaction */\n signer: boolean;\n /** Indicates if the account is writable for this transaction */\n writable: boolean;\n /** Indicates if the account key came from the transaction or a lookup table */\n source?: 'transaction' | 'lookupTable';\n};\n\n/**\n * A parsed transaction instruction\n */\nexport type ParsedInstruction = {\n /** Name of the program for this instruction */\n program: string;\n /** ID of the program for this instruction */\n programId: PublicKey;\n /** Parsed instruction info */\n parsed: any;\n};\n\n/**\n * A parsed address table lookup\n */\nexport type ParsedAddressTableLookup = {\n /** Address lookup table account key */\n accountKey: PublicKey;\n /** Parsed instruction info */\n writableIndexes: number[];\n /** Parsed instruction info */\n readonlyIndexes: number[];\n};\n\n/**\n * A parsed transaction message\n */\nexport type ParsedMessage = {\n /** Accounts used in the instructions */\n accountKeys: ParsedMessageAccount[];\n /** The atomically executed instructions for the transaction */\n instructions: (ParsedInstruction | PartiallyDecodedInstruction)[];\n /** Recent blockhash */\n recentBlockhash: string;\n /** Address table lookups used to load additional accounts */\n addressTableLookups?: ParsedAddressTableLookup[] | null;\n};\n\n/**\n * A parsed transaction\n */\nexport type ParsedTransaction = {\n /** Signatures for the transaction */\n signatures: Array;\n /** Message of the transaction */\n message: ParsedMessage;\n};\n\n/**\n * A parsed and confirmed transaction on the ledger\n *\n * @deprecated Deprecated since RPC v1.8.0. Please use {@link ParsedTransactionWithMeta} instead.\n */\nexport type ParsedConfirmedTransaction = ParsedTransactionWithMeta;\n\n/**\n * A parsed transaction on the ledger with meta\n */\nexport type ParsedTransactionWithMeta = {\n /** The slot during which the transaction was processed */\n slot: number;\n /** The details of the transaction */\n transaction: ParsedTransaction;\n /** Metadata produced from the transaction */\n meta: ParsedTransactionMeta | null;\n /** The unix timestamp of when the transaction was processed */\n blockTime?: number | null;\n /** The version of the transaction message */\n version?: TransactionVersion;\n};\n\n/**\n * A processed block fetched from the RPC API\n */\nexport type BlockResponse = {\n /** Blockhash of this block */\n blockhash: Blockhash;\n /** Blockhash of this block's parent */\n previousBlockhash: Blockhash;\n /** Slot index of this block's parent */\n parentSlot: number;\n /** Vector of transactions with status meta and original message */\n transactions: Array<{\n /** The transaction */\n transaction: {\n /** The transaction message */\n message: Message;\n /** The transaction signatures */\n signatures: string[];\n };\n /** Metadata produced from the transaction */\n meta: ConfirmedTransactionMeta | null;\n /** The transaction version */\n version?: TransactionVersion;\n }>;\n /** Vector of block rewards */\n rewards?: Array<{\n /** Public key of reward recipient */\n pubkey: string;\n /** Reward value in lamports */\n lamports: number;\n /** Account balance after reward is applied */\n postBalance: number | null;\n /** Type of reward received */\n rewardType: string | null;\n /** Vote account commission when the reward was credited, only present for voting and staking rewards */\n commission?: number | null;\n }>;\n /** The unix timestamp of when the block was processed */\n blockTime: number | null;\n};\n\n/**\n * A processed block fetched from the RPC API where the `transactionDetails` mode is `accounts`\n */\nexport type AccountsModeBlockResponse = VersionedAccountsModeBlockResponse;\n\n/**\n * A processed block fetched from the RPC API where the `transactionDetails` mode is `none`\n */\nexport type NoneModeBlockResponse = VersionedNoneModeBlockResponse;\n\n/**\n * A block with parsed transactions\n */\nexport type ParsedBlockResponse = {\n /** Blockhash of this block */\n blockhash: Blockhash;\n /** Blockhash of this block's parent */\n previousBlockhash: Blockhash;\n /** Slot index of this block's parent */\n parentSlot: number;\n /** Vector of transactions with status meta and original message */\n transactions: Array<{\n /** The details of the transaction */\n transaction: ParsedTransaction;\n /** Metadata produced from the transaction */\n meta: ParsedTransactionMeta | null;\n /** The transaction version */\n version?: TransactionVersion;\n }>;\n /** Vector of block rewards */\n rewards?: Array<{\n /** Public key of reward recipient */\n pubkey: string;\n /** Reward value in lamports */\n lamports: number;\n /** Account balance after reward is applied */\n postBalance: number | null;\n /** Type of reward received */\n rewardType: string | null;\n /** Vote account commission when the reward was credited, only present for voting and staking rewards */\n commission?: number | null;\n }>;\n /** The unix timestamp of when the block was processed */\n blockTime: number | null;\n /** The number of blocks beneath this block */\n blockHeight: number | null;\n};\n\n/**\n * A block with parsed transactions where the `transactionDetails` mode is `accounts`\n */\nexport type ParsedAccountsModeBlockResponse = Omit<\n ParsedBlockResponse,\n 'transactions'\n> & {\n transactions: Array<\n Omit & {\n transaction: Pick<\n ParsedBlockResponse['transactions'][number]['transaction'],\n 'signatures'\n > & {\n accountKeys: ParsedMessageAccount[];\n };\n }\n >;\n};\n\n/**\n * A block with parsed transactions where the `transactionDetails` mode is `none`\n */\nexport type ParsedNoneModeBlockResponse = Omit<\n ParsedBlockResponse,\n 'transactions'\n>;\n\n/**\n * A processed block fetched from the RPC API\n */\nexport type VersionedBlockResponse = {\n /** Blockhash of this block */\n blockhash: Blockhash;\n /** Blockhash of this block's parent */\n previousBlockhash: Blockhash;\n /** Slot index of this block's parent */\n parentSlot: number;\n /** Vector of transactions with status meta and original message */\n transactions: Array<{\n /** The transaction */\n transaction: {\n /** The transaction message */\n message: VersionedMessage;\n /** The transaction signatures */\n signatures: string[];\n };\n /** Metadata produced from the transaction */\n meta: ConfirmedTransactionMeta | null;\n /** The transaction version */\n version?: TransactionVersion;\n }>;\n /** Vector of block rewards */\n rewards?: Array<{\n /** Public key of reward recipient */\n pubkey: string;\n /** Reward value in lamports */\n lamports: number;\n /** Account balance after reward is applied */\n postBalance: number | null;\n /** Type of reward received */\n rewardType: string | null;\n /** Vote account commission when the reward was credited, only present for voting and staking rewards */\n commission?: number | null;\n }>;\n /** The unix timestamp of when the block was processed */\n blockTime: number | null;\n};\n\n/**\n * A processed block fetched from the RPC API where the `transactionDetails` mode is `accounts`\n */\nexport type VersionedAccountsModeBlockResponse = Omit<\n VersionedBlockResponse,\n 'transactions'\n> & {\n transactions: Array<\n Omit & {\n transaction: Pick<\n VersionedBlockResponse['transactions'][number]['transaction'],\n 'signatures'\n > & {\n accountKeys: ParsedMessageAccount[];\n };\n }\n >;\n};\n\n/**\n * A processed block fetched from the RPC API where the `transactionDetails` mode is `none`\n */\nexport type VersionedNoneModeBlockResponse = Omit<\n VersionedBlockResponse,\n 'transactions'\n>;\n\n/**\n * A confirmed block on the ledger\n *\n * @deprecated Deprecated since RPC v1.8.0.\n */\nexport type ConfirmedBlock = {\n /** Blockhash of this block */\n blockhash: Blockhash;\n /** Blockhash of this block's parent */\n previousBlockhash: Blockhash;\n /** Slot index of this block's parent */\n parentSlot: number;\n /** Vector of transactions and status metas */\n transactions: Array<{\n transaction: Transaction;\n meta: ConfirmedTransactionMeta | null;\n }>;\n /** Vector of block rewards */\n rewards?: Array<{\n pubkey: string;\n lamports: number;\n postBalance: number | null;\n rewardType: string | null;\n commission?: number | null;\n }>;\n /** The unix timestamp of when the block was processed */\n blockTime: number | null;\n};\n\n/**\n * A Block on the ledger with signatures only\n */\nexport type BlockSignatures = {\n /** Blockhash of this block */\n blockhash: Blockhash;\n /** Blockhash of this block's parent */\n previousBlockhash: Blockhash;\n /** Slot index of this block's parent */\n parentSlot: number;\n /** Vector of signatures */\n signatures: Array;\n /** The unix timestamp of when the block was processed */\n blockTime: number | null;\n};\n\n/**\n * recent block production information\n */\nexport type BlockProduction = Readonly<{\n /** a dictionary of validator identities, as base-58 encoded strings. Value is a two element array containing the number of leader slots and the number of blocks produced */\n byIdentity: Readonly>>;\n /** Block production slot range */\n range: Readonly<{\n /** first slot of the block production information (inclusive) */\n firstSlot: number;\n /** last slot of block production information (inclusive) */\n lastSlot: number;\n }>;\n}>;\n\nexport type GetBlockProductionConfig = {\n /** Optional commitment level */\n commitment?: Commitment;\n /** Slot range to return block production for. If parameter not provided, defaults to current epoch. */\n range?: {\n /** first slot to return block production information for (inclusive) */\n firstSlot: number;\n /** last slot to return block production information for (inclusive). If parameter not provided, defaults to the highest slot */\n lastSlot?: number;\n };\n /** Only return results for this validator identity (base-58 encoded) */\n identity?: string;\n};\n\n/**\n * Expected JSON RPC response for the \"getBlockProduction\" message\n */\nconst BlockProductionResponseStruct = jsonRpcResultAndContext(\n pick({\n byIdentity: record(string(), array(number())),\n range: pick({\n firstSlot: number(),\n lastSlot: number(),\n }),\n }),\n);\n\n/**\n * A performance sample\n */\nexport type PerfSample = {\n /** Slot number of sample */\n slot: number;\n /** Number of transactions in a sample window */\n numTransactions: number;\n /** Number of slots in a sample window */\n numSlots: number;\n /** Sample window in seconds */\n samplePeriodSecs: number;\n};\n\nfunction createRpcClient(\n url: string,\n httpHeaders?: HttpHeaders,\n customFetch?: FetchFn,\n fetchMiddleware?: FetchMiddleware,\n disableRetryOnRateLimit?: boolean,\n httpAgent?: NodeHttpAgent | NodeHttpsAgent | false,\n): RpcClient {\n const fetch = customFetch ? customFetch : fetchImpl;\n let agent: NodeHttpAgent | NodeHttpsAgent | undefined;\n if (process.env.BROWSER) {\n if (httpAgent != null) {\n console.warn(\n 'You have supplied an `httpAgent` when creating a `Connection` in a browser environment.' +\n 'It has been ignored; `httpAgent` is only used in Node environments.',\n );\n }\n } else {\n if (httpAgent == null) {\n if (process.env.NODE_ENV !== 'test') {\n const agentOptions = {\n // One second fewer than the Solana RPC's keepalive timeout.\n // Read more: https://github.com/solana-labs/solana/issues/27859#issuecomment-1340097889\n freeSocketTimeout: 19000,\n keepAlive: true,\n maxSockets: 25,\n };\n if (url.startsWith('https:')) {\n agent = new HttpsKeepAliveAgent(agentOptions);\n } else {\n agent = new HttpKeepAliveAgent(agentOptions);\n }\n }\n } else {\n if (httpAgent !== false) {\n const isHttps = url.startsWith('https:');\n if (isHttps && !(httpAgent instanceof NodeHttpsAgent)) {\n throw new Error(\n 'The endpoint `' +\n url +\n '` can only be paired with an `https.Agent`. You have, instead, supplied an ' +\n '`http.Agent` through `httpAgent`.',\n );\n } else if (!isHttps && httpAgent instanceof NodeHttpsAgent) {\n throw new Error(\n 'The endpoint `' +\n url +\n '` can only be paired with an `http.Agent`. You have, instead, supplied an ' +\n '`https.Agent` through `httpAgent`.',\n );\n }\n agent = httpAgent;\n }\n }\n }\n\n let fetchWithMiddleware: FetchFn | undefined;\n\n if (fetchMiddleware) {\n fetchWithMiddleware = async (info, init) => {\n const modifiedFetchArgs = await new Promise>(\n (resolve, reject) => {\n try {\n fetchMiddleware(info, init, (modifiedInfo, modifiedInit) =>\n resolve([modifiedInfo, modifiedInit]),\n );\n } catch (error) {\n reject(error);\n }\n },\n );\n return await fetch(...modifiedFetchArgs);\n };\n }\n\n const clientBrowser = new RpcClient(async (request, callback) => {\n const options = {\n method: 'POST',\n body: request,\n agent,\n headers: Object.assign(\n {\n 'Content-Type': 'application/json',\n },\n httpHeaders || {},\n COMMON_HTTP_HEADERS,\n ),\n };\n\n try {\n let too_many_requests_retries = 5;\n let res: Response;\n let waitTime = 500;\n for (;;) {\n if (fetchWithMiddleware) {\n res = await fetchWithMiddleware(url, options);\n } else {\n res = await fetch(url, options);\n }\n\n if (res.status !== 429 /* Too many requests */) {\n break;\n }\n if (disableRetryOnRateLimit === true) {\n break;\n }\n too_many_requests_retries -= 1;\n if (too_many_requests_retries === 0) {\n break;\n }\n console.error(\n `Server responded with ${res.status} ${res.statusText}. Retrying after ${waitTime}ms delay...`,\n );\n await sleep(waitTime);\n waitTime *= 2;\n }\n\n const text = await res.text();\n if (res.ok) {\n callback(null, text);\n } else {\n callback(new Error(`${res.status} ${res.statusText}: ${text}`));\n }\n } catch (err) {\n if (err instanceof Error) callback(err);\n }\n }, {});\n\n return clientBrowser;\n}\n\nfunction createRpcRequest(client: RpcClient): RpcRequest {\n return (method, args) => {\n return new Promise((resolve, reject) => {\n client.request(method, args, (err: any, response: any) => {\n if (err) {\n reject(err);\n return;\n }\n resolve(response);\n });\n });\n };\n}\n\nfunction createRpcBatchRequest(client: RpcClient): RpcBatchRequest {\n return (requests: RpcParams[]) => {\n return new Promise((resolve, reject) => {\n // Do nothing if requests is empty\n if (requests.length === 0) resolve([]);\n\n const batch = requests.map((params: RpcParams) => {\n return client.request(params.methodName, params.args);\n });\n\n client.request(batch, (err: any, response: any) => {\n if (err) {\n reject(err);\n return;\n }\n resolve(response);\n });\n });\n };\n}\n\n/**\n * Expected JSON RPC response for the \"getInflationGovernor\" message\n */\nconst GetInflationGovernorRpcResult = jsonRpcResult(GetInflationGovernorResult);\n\n/**\n * Expected JSON RPC response for the \"getInflationRate\" message\n */\nconst GetInflationRateRpcResult = jsonRpcResult(GetInflationRateResult);\n\n/**\n * Expected JSON RPC response for the \"getRecentPrioritizationFees\" message\n */\nconst GetRecentPrioritizationFeesRpcResult = jsonRpcResult(\n GetRecentPrioritizationFeesResult,\n);\n\n/**\n * Expected JSON RPC response for the \"getEpochInfo\" message\n */\nconst GetEpochInfoRpcResult = jsonRpcResult(GetEpochInfoResult);\n\n/**\n * Expected JSON RPC response for the \"getEpochSchedule\" message\n */\nconst GetEpochScheduleRpcResult = jsonRpcResult(GetEpochScheduleResult);\n\n/**\n * Expected JSON RPC response for the \"getLeaderSchedule\" message\n */\nconst GetLeaderScheduleRpcResult = jsonRpcResult(GetLeaderScheduleResult);\n\n/**\n * Expected JSON RPC response for the \"minimumLedgerSlot\" and \"getFirstAvailableBlock\" messages\n */\nconst SlotRpcResult = jsonRpcResult(number());\n\n/**\n * Supply\n */\nexport type Supply = {\n /** Total supply in lamports */\n total: number;\n /** Circulating supply in lamports */\n circulating: number;\n /** Non-circulating supply in lamports */\n nonCirculating: number;\n /** List of non-circulating account addresses */\n nonCirculatingAccounts: Array;\n};\n\n/**\n * Expected JSON RPC response for the \"getSupply\" message\n */\nconst GetSupplyRpcResult = jsonRpcResultAndContext(\n pick({\n total: number(),\n circulating: number(),\n nonCirculating: number(),\n nonCirculatingAccounts: array(PublicKeyFromString),\n }),\n);\n\n/**\n * Token amount object which returns a token amount in different formats\n * for various client use cases.\n */\nexport type TokenAmount = {\n /** Raw amount of tokens as string ignoring decimals */\n amount: string;\n /** Number of decimals configured for token's mint */\n decimals: number;\n /** Token amount as float, accounts for decimals */\n uiAmount: number | null;\n /** Token amount as string, accounts for decimals */\n uiAmountString?: string;\n};\n\n/**\n * Expected JSON RPC structure for token amounts\n */\nconst TokenAmountResult = pick({\n amount: string(),\n uiAmount: nullable(number()),\n decimals: number(),\n uiAmountString: optional(string()),\n});\n\n/**\n * Token address and balance.\n */\nexport type TokenAccountBalancePair = {\n /** Address of the token account */\n address: PublicKey;\n /** Raw amount of tokens as string ignoring decimals */\n amount: string;\n /** Number of decimals configured for token's mint */\n decimals: number;\n /** Token amount as float, accounts for decimals */\n uiAmount: number | null;\n /** Token amount as string, accounts for decimals */\n uiAmountString?: string;\n};\n\n/**\n * Expected JSON RPC response for the \"getTokenLargestAccounts\" message\n */\nconst GetTokenLargestAccountsResult = jsonRpcResultAndContext(\n array(\n pick({\n address: PublicKeyFromString,\n amount: string(),\n uiAmount: nullable(number()),\n decimals: number(),\n uiAmountString: optional(string()),\n }),\n ),\n);\n\n/**\n * Expected JSON RPC response for the \"getTokenAccountsByOwner\" message\n */\nconst GetTokenAccountsByOwner = jsonRpcResultAndContext(\n array(\n pick({\n pubkey: PublicKeyFromString,\n account: pick({\n executable: boolean(),\n owner: PublicKeyFromString,\n lamports: number(),\n data: BufferFromRawAccountData,\n rentEpoch: number(),\n }),\n }),\n ),\n);\n\nconst ParsedAccountDataResult = pick({\n program: string(),\n parsed: unknown(),\n space: number(),\n});\n\n/**\n * Expected JSON RPC response for the \"getTokenAccountsByOwner\" message with parsed data\n */\nconst GetParsedTokenAccountsByOwner = jsonRpcResultAndContext(\n array(\n pick({\n pubkey: PublicKeyFromString,\n account: pick({\n executable: boolean(),\n owner: PublicKeyFromString,\n lamports: number(),\n data: ParsedAccountDataResult,\n rentEpoch: number(),\n }),\n }),\n ),\n);\n\n/**\n * Pair of an account address and its balance\n */\nexport type AccountBalancePair = {\n address: PublicKey;\n lamports: number;\n};\n\n/**\n * Expected JSON RPC response for the \"getLargestAccounts\" message\n */\nconst GetLargestAccountsRpcResult = jsonRpcResultAndContext(\n array(\n pick({\n lamports: number(),\n address: PublicKeyFromString,\n }),\n ),\n);\n\n/**\n * @internal\n */\nconst AccountInfoResult = pick({\n executable: boolean(),\n owner: PublicKeyFromString,\n lamports: number(),\n data: BufferFromRawAccountData,\n rentEpoch: number(),\n});\n\n/**\n * @internal\n */\nconst KeyedAccountInfoResult = pick({\n pubkey: PublicKeyFromString,\n account: AccountInfoResult,\n});\n\nconst ParsedOrRawAccountData = coerce(\n union([instance(Buffer), ParsedAccountDataResult]),\n union([RawAccountDataResult, ParsedAccountDataResult]),\n value => {\n if (Array.isArray(value)) {\n return create(value, BufferFromRawAccountData);\n } else {\n return value;\n }\n },\n);\n\n/**\n * @internal\n */\nconst ParsedAccountInfoResult = pick({\n executable: boolean(),\n owner: PublicKeyFromString,\n lamports: number(),\n data: ParsedOrRawAccountData,\n rentEpoch: number(),\n});\n\nconst KeyedParsedAccountInfoResult = pick({\n pubkey: PublicKeyFromString,\n account: ParsedAccountInfoResult,\n});\n\n/**\n * @internal\n */\nconst StakeActivationResult = pick({\n state: union([\n literal('active'),\n literal('inactive'),\n literal('activating'),\n literal('deactivating'),\n ]),\n active: number(),\n inactive: number(),\n});\n\n/**\n * Expected JSON RPC response for the \"getConfirmedSignaturesForAddress2\" message\n */\n\nconst GetConfirmedSignaturesForAddress2RpcResult = jsonRpcResult(\n array(\n pick({\n signature: string(),\n slot: number(),\n err: TransactionErrorResult,\n memo: nullable(string()),\n blockTime: optional(nullable(number())),\n }),\n ),\n);\n\n/**\n * Expected JSON RPC response for the \"getSignaturesForAddress\" message\n */\nconst GetSignaturesForAddressRpcResult = jsonRpcResult(\n array(\n pick({\n signature: string(),\n slot: number(),\n err: TransactionErrorResult,\n memo: nullable(string()),\n blockTime: optional(nullable(number())),\n }),\n ),\n);\n\n/***\n * Expected JSON RPC response for the \"accountNotification\" message\n */\nconst AccountNotificationResult = pick({\n subscription: number(),\n result: notificationResultAndContext(AccountInfoResult),\n});\n\n/**\n * @internal\n */\nconst ProgramAccountInfoResult = pick({\n pubkey: PublicKeyFromString,\n account: AccountInfoResult,\n});\n\n/***\n * Expected JSON RPC response for the \"programNotification\" message\n */\nconst ProgramAccountNotificationResult = pick({\n subscription: number(),\n result: notificationResultAndContext(ProgramAccountInfoResult),\n});\n\n/**\n * @internal\n */\nconst SlotInfoResult = pick({\n parent: number(),\n slot: number(),\n root: number(),\n});\n\n/**\n * Expected JSON RPC response for the \"slotNotification\" message\n */\nconst SlotNotificationResult = pick({\n subscription: number(),\n result: SlotInfoResult,\n});\n\n/**\n * Slot updates which can be used for tracking the live progress of a cluster.\n * - `\"firstShredReceived\"`: connected node received the first shred of a block.\n * Indicates that a new block that is being produced.\n * - `\"completed\"`: connected node has received all shreds of a block. Indicates\n * a block was recently produced.\n * - `\"optimisticConfirmation\"`: block was optimistically confirmed by the\n * cluster. It is not guaranteed that an optimistic confirmation notification\n * will be sent for every finalized blocks.\n * - `\"root\"`: the connected node rooted this block.\n * - `\"createdBank\"`: the connected node has started validating this block.\n * - `\"frozen\"`: the connected node has validated this block.\n * - `\"dead\"`: the connected node failed to validate this block.\n */\nexport type SlotUpdate =\n | {\n type: 'firstShredReceived';\n slot: number;\n timestamp: number;\n }\n | {\n type: 'completed';\n slot: number;\n timestamp: number;\n }\n | {\n type: 'createdBank';\n slot: number;\n timestamp: number;\n parent: number;\n }\n | {\n type: 'frozen';\n slot: number;\n timestamp: number;\n stats: {\n numTransactionEntries: number;\n numSuccessfulTransactions: number;\n numFailedTransactions: number;\n maxTransactionsPerEntry: number;\n };\n }\n | {\n type: 'dead';\n slot: number;\n timestamp: number;\n err: string;\n }\n | {\n type: 'optimisticConfirmation';\n slot: number;\n timestamp: number;\n }\n | {\n type: 'root';\n slot: number;\n timestamp: number;\n };\n\n/**\n * @internal\n */\nconst SlotUpdateResult = union([\n pick({\n type: union([\n literal('firstShredReceived'),\n literal('completed'),\n literal('optimisticConfirmation'),\n literal('root'),\n ]),\n slot: number(),\n timestamp: number(),\n }),\n pick({\n type: literal('createdBank'),\n parent: number(),\n slot: number(),\n timestamp: number(),\n }),\n pick({\n type: literal('frozen'),\n slot: number(),\n timestamp: number(),\n stats: pick({\n numTransactionEntries: number(),\n numSuccessfulTransactions: number(),\n numFailedTransactions: number(),\n maxTransactionsPerEntry: number(),\n }),\n }),\n pick({\n type: literal('dead'),\n slot: number(),\n timestamp: number(),\n err: string(),\n }),\n]);\n\n/**\n * Expected JSON RPC response for the \"slotsUpdatesNotification\" message\n */\nconst SlotUpdateNotificationResult = pick({\n subscription: number(),\n result: SlotUpdateResult,\n});\n\n/**\n * Expected JSON RPC response for the \"signatureNotification\" message\n */\nconst SignatureNotificationResult = pick({\n subscription: number(),\n result: notificationResultAndContext(\n union([SignatureStatusResult, SignatureReceivedResult]),\n ),\n});\n\n/**\n * Expected JSON RPC response for the \"rootNotification\" message\n */\nconst RootNotificationResult = pick({\n subscription: number(),\n result: number(),\n});\n\nconst ContactInfoResult = pick({\n pubkey: string(),\n gossip: nullable(string()),\n tpu: nullable(string()),\n rpc: nullable(string()),\n version: nullable(string()),\n});\n\nconst VoteAccountInfoResult = pick({\n votePubkey: string(),\n nodePubkey: string(),\n activatedStake: number(),\n epochVoteAccount: boolean(),\n epochCredits: array(tuple([number(), number(), number()])),\n commission: number(),\n lastVote: number(),\n rootSlot: nullable(number()),\n});\n\n/**\n * Expected JSON RPC response for the \"getVoteAccounts\" message\n */\nconst GetVoteAccounts = jsonRpcResult(\n pick({\n current: array(VoteAccountInfoResult),\n delinquent: array(VoteAccountInfoResult),\n }),\n);\n\nconst ConfirmationStatus = union([\n literal('processed'),\n literal('confirmed'),\n literal('finalized'),\n]);\n\nconst SignatureStatusResponse = pick({\n slot: number(),\n confirmations: nullable(number()),\n err: TransactionErrorResult,\n confirmationStatus: optional(ConfirmationStatus),\n});\n\n/**\n * Expected JSON RPC response for the \"getSignatureStatuses\" message\n */\nconst GetSignatureStatusesRpcResult = jsonRpcResultAndContext(\n array(nullable(SignatureStatusResponse)),\n);\n\n/**\n * Expected JSON RPC response for the \"getMinimumBalanceForRentExemption\" message\n */\nconst GetMinimumBalanceForRentExemptionRpcResult = jsonRpcResult(number());\n\nconst AddressTableLookupStruct = pick({\n accountKey: PublicKeyFromString,\n writableIndexes: array(number()),\n readonlyIndexes: array(number()),\n});\n\nconst ConfirmedTransactionResult = pick({\n signatures: array(string()),\n message: pick({\n accountKeys: array(string()),\n header: pick({\n numRequiredSignatures: number(),\n numReadonlySignedAccounts: number(),\n numReadonlyUnsignedAccounts: number(),\n }),\n instructions: array(\n pick({\n accounts: array(number()),\n data: string(),\n programIdIndex: number(),\n }),\n ),\n recentBlockhash: string(),\n addressTableLookups: optional(array(AddressTableLookupStruct)),\n }),\n});\n\nconst AnnotatedAccountKey = pick({\n pubkey: PublicKeyFromString,\n signer: boolean(),\n writable: boolean(),\n source: optional(union([literal('transaction'), literal('lookupTable')])),\n});\n\nconst ConfirmedTransactionAccountsModeResult = pick({\n accountKeys: array(AnnotatedAccountKey),\n signatures: array(string()),\n});\n\nconst ParsedInstructionResult = pick({\n parsed: unknown(),\n program: string(),\n programId: PublicKeyFromString,\n});\n\nconst RawInstructionResult = pick({\n accounts: array(PublicKeyFromString),\n data: string(),\n programId: PublicKeyFromString,\n});\n\nconst InstructionResult = union([\n RawInstructionResult,\n ParsedInstructionResult,\n]);\n\nconst UnknownInstructionResult = union([\n pick({\n parsed: unknown(),\n program: string(),\n programId: string(),\n }),\n pick({\n accounts: array(string()),\n data: string(),\n programId: string(),\n }),\n]);\n\nconst ParsedOrRawInstruction = coerce(\n InstructionResult,\n UnknownInstructionResult,\n value => {\n if ('accounts' in value) {\n return create(value, RawInstructionResult);\n } else {\n return create(value, ParsedInstructionResult);\n }\n },\n);\n\n/**\n * @internal\n */\nconst ParsedConfirmedTransactionResult = pick({\n signatures: array(string()),\n message: pick({\n accountKeys: array(AnnotatedAccountKey),\n instructions: array(ParsedOrRawInstruction),\n recentBlockhash: string(),\n addressTableLookups: optional(nullable(array(AddressTableLookupStruct))),\n }),\n});\n\nconst TokenBalanceResult = pick({\n accountIndex: number(),\n mint: string(),\n owner: optional(string()),\n programId: optional(string()),\n uiTokenAmount: TokenAmountResult,\n});\n\nconst LoadedAddressesResult = pick({\n writable: array(PublicKeyFromString),\n readonly: array(PublicKeyFromString),\n});\n\n/**\n * @internal\n */\nconst ConfirmedTransactionMetaResult = pick({\n err: TransactionErrorResult,\n fee: number(),\n innerInstructions: optional(\n nullable(\n array(\n pick({\n index: number(),\n instructions: array(\n pick({\n accounts: array(number()),\n data: string(),\n programIdIndex: number(),\n }),\n ),\n }),\n ),\n ),\n ),\n preBalances: array(number()),\n postBalances: array(number()),\n logMessages: optional(nullable(array(string()))),\n preTokenBalances: optional(nullable(array(TokenBalanceResult))),\n postTokenBalances: optional(nullable(array(TokenBalanceResult))),\n loadedAddresses: optional(LoadedAddressesResult),\n computeUnitsConsumed: optional(number()),\n});\n\n/**\n * @internal\n */\nconst ParsedConfirmedTransactionMetaResult = pick({\n err: TransactionErrorResult,\n fee: number(),\n innerInstructions: optional(\n nullable(\n array(\n pick({\n index: number(),\n instructions: array(ParsedOrRawInstruction),\n }),\n ),\n ),\n ),\n preBalances: array(number()),\n postBalances: array(number()),\n logMessages: optional(nullable(array(string()))),\n preTokenBalances: optional(nullable(array(TokenBalanceResult))),\n postTokenBalances: optional(nullable(array(TokenBalanceResult))),\n loadedAddresses: optional(LoadedAddressesResult),\n computeUnitsConsumed: optional(number()),\n});\n\nconst TransactionVersionStruct = union([literal(0), literal('legacy')]);\n\n/** @internal */\nconst RewardsResult = pick({\n pubkey: string(),\n lamports: number(),\n postBalance: nullable(number()),\n rewardType: nullable(string()),\n commission: optional(nullable(number())),\n});\n\n/**\n * Expected JSON RPC response for the \"getBlock\" message\n */\nconst GetBlockRpcResult = jsonRpcResult(\n nullable(\n pick({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n transactions: array(\n pick({\n transaction: ConfirmedTransactionResult,\n meta: nullable(ConfirmedTransactionMetaResult),\n version: optional(TransactionVersionStruct),\n }),\n ),\n rewards: optional(array(RewardsResult)),\n blockTime: nullable(number()),\n blockHeight: nullable(number()),\n }),\n ),\n);\n\n/**\n * Expected JSON RPC response for the \"getBlock\" message when `transactionDetails` is `none`\n */\nconst GetNoneModeBlockRpcResult = jsonRpcResult(\n nullable(\n pick({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n rewards: optional(array(RewardsResult)),\n blockTime: nullable(number()),\n blockHeight: nullable(number()),\n }),\n ),\n);\n\n/**\n * Expected JSON RPC response for the \"getBlock\" message when `transactionDetails` is `accounts`\n */\nconst GetAccountsModeBlockRpcResult = jsonRpcResult(\n nullable(\n pick({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n transactions: array(\n pick({\n transaction: ConfirmedTransactionAccountsModeResult,\n meta: nullable(ConfirmedTransactionMetaResult),\n version: optional(TransactionVersionStruct),\n }),\n ),\n rewards: optional(array(RewardsResult)),\n blockTime: nullable(number()),\n blockHeight: nullable(number()),\n }),\n ),\n);\n\n/**\n * Expected parsed JSON RPC response for the \"getBlock\" message\n */\nconst GetParsedBlockRpcResult = jsonRpcResult(\n nullable(\n pick({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n transactions: array(\n pick({\n transaction: ParsedConfirmedTransactionResult,\n meta: nullable(ParsedConfirmedTransactionMetaResult),\n version: optional(TransactionVersionStruct),\n }),\n ),\n rewards: optional(array(RewardsResult)),\n blockTime: nullable(number()),\n blockHeight: nullable(number()),\n }),\n ),\n);\n\n/**\n * Expected parsed JSON RPC response for the \"getBlock\" message when `transactionDetails` is `accounts`\n */\nconst GetParsedAccountsModeBlockRpcResult = jsonRpcResult(\n nullable(\n pick({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n transactions: array(\n pick({\n transaction: ConfirmedTransactionAccountsModeResult,\n meta: nullable(ParsedConfirmedTransactionMetaResult),\n version: optional(TransactionVersionStruct),\n }),\n ),\n rewards: optional(array(RewardsResult)),\n blockTime: nullable(number()),\n blockHeight: nullable(number()),\n }),\n ),\n);\n\n/**\n * Expected parsed JSON RPC response for the \"getBlock\" message when `transactionDetails` is `none`\n */\nconst GetParsedNoneModeBlockRpcResult = jsonRpcResult(\n nullable(\n pick({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n rewards: optional(array(RewardsResult)),\n blockTime: nullable(number()),\n blockHeight: nullable(number()),\n }),\n ),\n);\n\n/**\n * Expected JSON RPC response for the \"getConfirmedBlock\" message\n *\n * @deprecated Deprecated since RPC v1.8.0. Please use {@link GetBlockRpcResult} instead.\n */\nconst GetConfirmedBlockRpcResult = jsonRpcResult(\n nullable(\n pick({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n transactions: array(\n pick({\n transaction: ConfirmedTransactionResult,\n meta: nullable(ConfirmedTransactionMetaResult),\n }),\n ),\n rewards: optional(array(RewardsResult)),\n blockTime: nullable(number()),\n }),\n ),\n);\n\n/**\n * Expected JSON RPC response for the \"getBlock\" message\n */\nconst GetBlockSignaturesRpcResult = jsonRpcResult(\n nullable(\n pick({\n blockhash: string(),\n previousBlockhash: string(),\n parentSlot: number(),\n signatures: array(string()),\n blockTime: nullable(number()),\n }),\n ),\n);\n\n/**\n * Expected JSON RPC response for the \"getTransaction\" message\n */\nconst GetTransactionRpcResult = jsonRpcResult(\n nullable(\n pick({\n slot: number(),\n meta: nullable(ConfirmedTransactionMetaResult),\n blockTime: optional(nullable(number())),\n transaction: ConfirmedTransactionResult,\n version: optional(TransactionVersionStruct),\n }),\n ),\n);\n\n/**\n * Expected parsed JSON RPC response for the \"getTransaction\" message\n */\nconst GetParsedTransactionRpcResult = jsonRpcResult(\n nullable(\n pick({\n slot: number(),\n transaction: ParsedConfirmedTransactionResult,\n meta: nullable(ParsedConfirmedTransactionMetaResult),\n blockTime: optional(nullable(number())),\n version: optional(TransactionVersionStruct),\n }),\n ),\n);\n\n/**\n * Expected JSON RPC response for the \"getLatestBlockhash\" message\n */\nconst GetLatestBlockhashRpcResult = jsonRpcResultAndContext(\n pick({\n blockhash: string(),\n lastValidBlockHeight: number(),\n }),\n);\n\n/**\n * Expected JSON RPC response for the \"isBlockhashValid\" message\n */\nconst IsBlockhashValidRpcResult = jsonRpcResultAndContext(boolean());\n\nconst PerfSampleResult = pick({\n slot: number(),\n numTransactions: number(),\n numSlots: number(),\n samplePeriodSecs: number(),\n});\n\n/*\n * Expected JSON RPC response for \"getRecentPerformanceSamples\" message\n */\nconst GetRecentPerformanceSamplesRpcResult = jsonRpcResult(\n array(PerfSampleResult),\n);\n\n/**\n * Expected JSON RPC response for the \"getFeeCalculatorForBlockhash\" message\n */\nconst GetFeeCalculatorRpcResult = jsonRpcResultAndContext(\n nullable(\n pick({\n feeCalculator: pick({\n lamportsPerSignature: number(),\n }),\n }),\n ),\n);\n\n/**\n * Expected JSON RPC response for the \"requestAirdrop\" message\n */\nconst RequestAirdropRpcResult = jsonRpcResult(string());\n\n/**\n * Expected JSON RPC response for the \"sendTransaction\" message\n */\nconst SendTransactionRpcResult = jsonRpcResult(string());\n\n/**\n * Information about the latest slot being processed by a node\n */\nexport type SlotInfo = {\n /** Currently processing slot */\n slot: number;\n /** Parent of the current slot */\n parent: number;\n /** The root block of the current slot's fork */\n root: number;\n};\n\n/**\n * Parsed account data\n */\nexport type ParsedAccountData = {\n /** Name of the program that owns this account */\n program: string;\n /** Parsed account data */\n parsed: any;\n /** Space used by account data */\n space: number;\n};\n\n/**\n * Stake Activation data\n */\nexport type StakeActivationData = {\n /** the stake account's activation state */\n state: 'active' | 'inactive' | 'activating' | 'deactivating';\n /** stake active during the epoch */\n active: number;\n /** stake inactive during the epoch */\n inactive: number;\n};\n\n/**\n * Data slice argument for getProgramAccounts\n */\nexport type DataSlice = {\n /** offset of data slice */\n offset: number;\n /** length of data slice */\n length: number;\n};\n\n/**\n * Memory comparison filter for getProgramAccounts\n */\nexport type MemcmpFilter = {\n memcmp: {\n /** offset into program account data to start comparison */\n offset: number;\n } & (\n | {\n encoding?: 'base58'; // Base-58 is the default when not supplied.\n /** data to match, as base-58 encoded string and limited to less than 129 bytes */\n bytes: string;\n }\n | {\n encoding: 'base64';\n /** data to match, as base-64 encoded string */\n bytes: string;\n }\n );\n};\n\n/**\n * Data size comparison filter for getProgramAccounts\n */\nexport type DataSizeFilter = {\n /** Size of data for program account data length comparison */\n dataSize: number;\n};\n\n/**\n * A filter object for getProgramAccounts\n */\nexport type GetProgramAccountsFilter = MemcmpFilter | DataSizeFilter;\n\n/**\n * Configuration object for getProgramAccounts requests\n */\nexport type GetProgramAccountsConfig = {\n /** Optional commitment level */\n commitment?: Commitment;\n /** Optional encoding for account data (default base64)\n * To use \"jsonParsed\" encoding, please refer to `getParsedProgramAccounts` in connection.ts\n * */\n encoding?: 'base64';\n /** Optional data slice to limit the returned account data */\n dataSlice?: DataSlice;\n /** Optional array of filters to apply to accounts */\n filters?: GetProgramAccountsFilter[];\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n /** wrap the result in an RpcResponse JSON object */\n withContext?: boolean;\n};\n\nexport type GetProgramAccountsResponse = readonly Readonly<{\n account: AccountInfo;\n /** the account Pubkey as base-58 encoded string */\n pubkey: PublicKey;\n}>[];\n\n/**\n * Configuration object for getParsedProgramAccounts\n */\nexport type GetParsedProgramAccountsConfig = {\n /** Optional commitment level */\n commitment?: Commitment;\n /** Optional array of filters to apply to accounts */\n filters?: GetProgramAccountsFilter[];\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * Configuration object for getMultipleAccounts\n */\nexport type GetMultipleAccountsConfig = {\n /** Optional commitment level */\n commitment?: Commitment;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n /** Optional data slice to limit the returned account data */\n dataSlice?: DataSlice;\n};\n\n/**\n * Configuration object for `getStakeActivation`\n */\nexport type GetStakeActivationConfig = {\n /** Optional commitment level */\n commitment?: Commitment;\n /** Epoch for which to calculate activation details. If parameter not provided, defaults to current epoch */\n epoch?: number;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * Configuration object for `getStakeActivation`\n */\nexport type GetTokenAccountsByOwnerConfig = {\n /** Optional commitment level */\n commitment?: Commitment;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * Configuration object for `getStakeActivation`\n */\nexport type GetTransactionCountConfig = {\n /** Optional commitment level */\n commitment?: Commitment;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * Configuration object for `getNonce`\n */\nexport type GetNonceConfig = {\n /** Optional commitment level */\n commitment?: Commitment;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\n/**\n * Configuration object for `getNonceAndContext`\n */\nexport type GetNonceAndContextConfig = {\n /** Optional commitment level */\n commitment?: Commitment;\n /** The minimum slot that the request can be evaluated at */\n minContextSlot?: number;\n};\n\nexport type AccountSubscriptionConfig = Readonly<{\n /** Optional commitment level */\n commitment?: Commitment;\n /**\n * Encoding format for Account data\n * - `base58` is slow.\n * - `jsonParsed` encoding attempts to use program-specific state parsers to return more\n * human-readable and explicit account state data\n * - If `jsonParsed` is requested but a parser cannot be found, the field falls back to `base64`\n * encoding, detectable when the `data` field is type `string`.\n */\n encoding?: 'base58' | 'base64' | 'base64+zstd' | 'jsonParsed';\n}>;\n\nexport type ProgramAccountSubscriptionConfig = Readonly<{\n /** Optional commitment level */\n commitment?: Commitment;\n /**\n * Encoding format for Account data\n * - `base58` is slow.\n * - `jsonParsed` encoding attempts to use program-specific state parsers to return more\n * human-readable and explicit account state data\n * - If `jsonParsed` is requested but a parser cannot be found, the field falls back to `base64`\n * encoding, detectable when the `data` field is type `string`.\n */\n encoding?: 'base58' | 'base64' | 'base64+zstd' | 'jsonParsed';\n /**\n * Filter results using various filter objects\n * The resultant account must meet ALL filter criteria to be included in the returned results\n */\n filters?: GetProgramAccountsFilter[];\n}>;\n\n/**\n * Information describing an account\n */\nexport type AccountInfo = {\n /** `true` if this account's data contains a loaded program */\n executable: boolean;\n /** Identifier of the program that owns the account */\n owner: PublicKey;\n /** Number of lamports assigned to the account */\n lamports: number;\n /** Optional data assigned to the account */\n data: T;\n /** Optional rent epoch info for account */\n rentEpoch?: number;\n};\n\n/**\n * Account information identified by pubkey\n */\nexport type KeyedAccountInfo = {\n accountId: PublicKey;\n accountInfo: AccountInfo;\n};\n\n/**\n * Callback function for account change notifications\n */\nexport type AccountChangeCallback = (\n accountInfo: AccountInfo,\n context: Context,\n) => void;\n\n/**\n * Callback function for program account change notifications\n */\nexport type ProgramAccountChangeCallback = (\n keyedAccountInfo: KeyedAccountInfo,\n context: Context,\n) => void;\n\n/**\n * Callback function for slot change notifications\n */\nexport type SlotChangeCallback = (slotInfo: SlotInfo) => void;\n\n/**\n * Callback function for slot update notifications\n */\nexport type SlotUpdateCallback = (slotUpdate: SlotUpdate) => void;\n\n/**\n * Callback function for signature status notifications\n */\nexport type SignatureResultCallback = (\n signatureResult: SignatureResult,\n context: Context,\n) => void;\n\n/**\n * Signature status notification with transaction result\n */\nexport type SignatureStatusNotification = {\n type: 'status';\n result: SignatureResult;\n};\n\n/**\n * Signature received notification\n */\nexport type SignatureReceivedNotification = {\n type: 'received';\n};\n\n/**\n * Callback function for signature notifications\n */\nexport type SignatureSubscriptionCallback = (\n notification: SignatureStatusNotification | SignatureReceivedNotification,\n context: Context,\n) => void;\n\n/**\n * Signature subscription options\n */\nexport type SignatureSubscriptionOptions = {\n commitment?: Commitment;\n enableReceivedNotification?: boolean;\n};\n\n/**\n * Callback function for root change notifications\n */\nexport type RootChangeCallback = (root: number) => void;\n\n/**\n * @internal\n */\nconst LogsResult = pick({\n err: TransactionErrorResult,\n logs: array(string()),\n signature: string(),\n});\n\n/**\n * Logs result.\n */\nexport type Logs = {\n err: TransactionError | null;\n logs: string[];\n signature: string;\n};\n\n/**\n * Expected JSON RPC response for the \"logsNotification\" message.\n */\nconst LogsNotificationResult = pick({\n result: notificationResultAndContext(LogsResult),\n subscription: number(),\n});\n\n/**\n * Filter for log subscriptions.\n */\nexport type LogsFilter = PublicKey | 'all' | 'allWithVotes';\n\n/**\n * Callback function for log notifications.\n */\nexport type LogsCallback = (logs: Logs, ctx: Context) => void;\n\n/**\n * Signature result\n */\nexport type SignatureResult = {\n err: TransactionError | null;\n};\n\n/**\n * Transaction error\n */\nexport type TransactionError = {} | string;\n\n/**\n * Transaction confirmation status\n *
\n *   'processed': Transaction landed in a block which has reached 1 confirmation by the connected node\n *   'confirmed': Transaction landed in a block which has reached 1 confirmation by the cluster\n *   'finalized': Transaction landed in a block which has been finalized by the cluster\n * 
\n */\nexport type TransactionConfirmationStatus =\n | 'processed'\n | 'confirmed'\n | 'finalized';\n\n/**\n * Signature status\n */\nexport type SignatureStatus = {\n /** when the transaction was processed */\n slot: number;\n /** the number of blocks that have been confirmed and voted on in the fork containing `slot` */\n confirmations: number | null;\n /** transaction error, if any */\n err: TransactionError | null;\n /** cluster confirmation status, if data available. Possible responses: `processed`, `confirmed`, `finalized` */\n confirmationStatus?: TransactionConfirmationStatus;\n};\n\n/**\n * A confirmed signature with its status\n */\nexport type ConfirmedSignatureInfo = {\n /** the transaction signature */\n signature: string;\n /** when the transaction was processed */\n slot: number;\n /** error, if any */\n err: TransactionError | null;\n /** memo associated with the transaction, if any */\n memo: string | null;\n /** The unix timestamp of when the transaction was processed */\n blockTime?: number | null;\n /** Cluster confirmation status, if available. Possible values: `processed`, `confirmed`, `finalized` */\n confirmationStatus?: TransactionConfirmationStatus;\n};\n\n/**\n * An object defining headers to be passed to the RPC server\n */\nexport type HttpHeaders = {\n [header: string]: string;\n} & {\n // Prohibited headers; for internal use only.\n 'solana-client'?: never;\n};\n\n/**\n * The type of the JavaScript `fetch()` API\n */\nexport type FetchFn = typeof fetchImpl;\n\n/**\n * A callback used to augment the outgoing HTTP request\n */\nexport type FetchMiddleware = (\n info: Parameters[0],\n init: Parameters[1],\n fetch: (...a: Parameters) => void,\n) => void;\n\n/**\n * Configuration for instantiating a Connection\n */\nexport type ConnectionConfig = {\n /**\n * An `http.Agent` that will be used to manage socket connections (eg. to implement connection\n * persistence). Set this to `false` to create a connection that uses no agent. This applies to\n * Node environments only.\n */\n httpAgent?: NodeHttpAgent | NodeHttpsAgent | false;\n /** Optional commitment level */\n commitment?: Commitment;\n /** Optional endpoint URL to the fullnode JSON RPC PubSub WebSocket Endpoint */\n wsEndpoint?: string;\n /** Optional HTTP headers object */\n httpHeaders?: HttpHeaders;\n /** Optional custom fetch function */\n fetch?: FetchFn;\n /** Optional fetch middleware callback */\n fetchMiddleware?: FetchMiddleware;\n /** Optional Disable retrying calls when server responds with HTTP 429 (Too Many Requests) */\n disableRetryOnRateLimit?: boolean;\n /** time to allow for the server to initially process a transaction (in milliseconds) */\n confirmTransactionInitialTimeout?: number;\n};\n\n/** @internal */\nconst COMMON_HTTP_HEADERS = {\n 'solana-client': `js/${process.env.npm_package_version ?? 'UNKNOWN'}`,\n};\n\n/**\n * A connection to a fullnode JSON RPC endpoint\n */\nexport class Connection {\n /** @internal */ _commitment?: Commitment;\n /** @internal */ _confirmTransactionInitialTimeout?: number;\n /** @internal */ _rpcEndpoint: string;\n /** @internal */ _rpcWsEndpoint: string;\n /** @internal */ _rpcClient: RpcClient;\n /** @internal */ _rpcRequest: RpcRequest;\n /** @internal */ _rpcBatchRequest: RpcBatchRequest;\n /** @internal */ _rpcWebSocket: RpcWebSocketClient;\n /** @internal */ _rpcWebSocketConnected: boolean = false;\n /** @internal */ _rpcWebSocketHeartbeat: ReturnType<\n typeof setInterval\n > | null = null;\n /** @internal */ _rpcWebSocketIdleTimeout: ReturnType<\n typeof setTimeout\n > | null = null;\n /** @internal\n * A number that we increment every time an active connection closes.\n * Used to determine whether the same socket connection that was open\n * when an async operation started is the same one that's active when\n * its continuation fires.\n *\n */ private _rpcWebSocketGeneration: number = 0;\n\n /** @internal */ _disableBlockhashCaching: boolean = false;\n /** @internal */ _pollingBlockhash: boolean = false;\n /** @internal */ _blockhashInfo: {\n latestBlockhash: BlockhashWithExpiryBlockHeight | null;\n lastFetch: number;\n simulatedSignatures: Array;\n transactionSignatures: Array;\n } = {\n latestBlockhash: null,\n lastFetch: 0,\n transactionSignatures: [],\n simulatedSignatures: [],\n };\n\n /** @internal */ private _nextClientSubscriptionId: ClientSubscriptionId = 0;\n /** @internal */ private _subscriptionDisposeFunctionsByClientSubscriptionId: {\n [clientSubscriptionId: ClientSubscriptionId]:\n | SubscriptionDisposeFn\n | undefined;\n } = {};\n /** @internal */ private _subscriptionHashByClientSubscriptionId: {\n [clientSubscriptionId: ClientSubscriptionId]:\n | SubscriptionConfigHash\n | undefined;\n } = {};\n /** @internal */ private _subscriptionStateChangeCallbacksByHash: {\n [hash: SubscriptionConfigHash]:\n | Set\n | undefined;\n } = {};\n /** @internal */ private _subscriptionCallbacksByServerSubscriptionId: {\n [serverSubscriptionId: ServerSubscriptionId]:\n | Set\n | undefined;\n } = {};\n /** @internal */ private _subscriptionsByHash: {\n [hash: SubscriptionConfigHash]: Subscription | undefined;\n } = {};\n /**\n * Special case.\n * After a signature is processed, RPCs automatically dispose of the\n * subscription on the server side. We need to track which of these\n * subscriptions have been disposed in such a way, so that we know\n * whether the client is dealing with a not-yet-processed signature\n * (in which case we must tear down the server subscription) or an\n * already-processed signature (in which case the client can simply\n * clear out the subscription locally without telling the server).\n *\n * NOTE: There is a proposal to eliminate this special case, here:\n * https://github.com/solana-labs/solana/issues/18892\n */\n /** @internal */ private _subscriptionsAutoDisposedByRpc: Set =\n new Set();\n\n /**\n * Establish a JSON RPC connection\n *\n * @param endpoint URL to the fullnode JSON RPC endpoint\n * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object\n */\n constructor(\n endpoint: string,\n commitmentOrConfig?: Commitment | ConnectionConfig,\n ) {\n let wsEndpoint;\n let httpHeaders;\n let fetch;\n let fetchMiddleware;\n let disableRetryOnRateLimit;\n let httpAgent;\n if (commitmentOrConfig && typeof commitmentOrConfig === 'string') {\n this._commitment = commitmentOrConfig;\n } else if (commitmentOrConfig) {\n this._commitment = commitmentOrConfig.commitment;\n this._confirmTransactionInitialTimeout =\n commitmentOrConfig.confirmTransactionInitialTimeout;\n wsEndpoint = commitmentOrConfig.wsEndpoint;\n httpHeaders = commitmentOrConfig.httpHeaders;\n fetch = commitmentOrConfig.fetch;\n fetchMiddleware = commitmentOrConfig.fetchMiddleware;\n disableRetryOnRateLimit = commitmentOrConfig.disableRetryOnRateLimit;\n httpAgent = commitmentOrConfig.httpAgent;\n }\n\n this._rpcEndpoint = assertEndpointUrl(endpoint);\n this._rpcWsEndpoint = wsEndpoint || makeWebsocketUrl(endpoint);\n\n this._rpcClient = createRpcClient(\n endpoint,\n httpHeaders,\n fetch,\n fetchMiddleware,\n disableRetryOnRateLimit,\n httpAgent,\n );\n this._rpcRequest = createRpcRequest(this._rpcClient);\n this._rpcBatchRequest = createRpcBatchRequest(this._rpcClient);\n\n this._rpcWebSocket = new RpcWebSocketClient(this._rpcWsEndpoint, {\n autoconnect: false,\n max_reconnects: Infinity,\n });\n this._rpcWebSocket.on('open', this._wsOnOpen.bind(this));\n this._rpcWebSocket.on('error', this._wsOnError.bind(this));\n this._rpcWebSocket.on('close', this._wsOnClose.bind(this));\n this._rpcWebSocket.on(\n 'accountNotification',\n this._wsOnAccountNotification.bind(this),\n );\n this._rpcWebSocket.on(\n 'programNotification',\n this._wsOnProgramAccountNotification.bind(this),\n );\n this._rpcWebSocket.on(\n 'slotNotification',\n this._wsOnSlotNotification.bind(this),\n );\n this._rpcWebSocket.on(\n 'slotsUpdatesNotification',\n this._wsOnSlotUpdatesNotification.bind(this),\n );\n this._rpcWebSocket.on(\n 'signatureNotification',\n this._wsOnSignatureNotification.bind(this),\n );\n this._rpcWebSocket.on(\n 'rootNotification',\n this._wsOnRootNotification.bind(this),\n );\n this._rpcWebSocket.on(\n 'logsNotification',\n this._wsOnLogsNotification.bind(this),\n );\n }\n\n /**\n * The default commitment used for requests\n */\n get commitment(): Commitment | undefined {\n return this._commitment;\n }\n\n /**\n * The RPC endpoint\n */\n get rpcEndpoint(): string {\n return this._rpcEndpoint;\n }\n\n /**\n * Fetch the balance for the specified public key, return with context\n */\n async getBalanceAndContext(\n publicKey: PublicKey,\n commitmentOrConfig?: Commitment | GetBalanceConfig,\n ): Promise> {\n /** @internal */\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs(\n [publicKey.toBase58()],\n commitment,\n undefined /* encoding */,\n config,\n );\n const unsafeRes = await this._rpcRequest('getBalance', args);\n const res = create(unsafeRes, jsonRpcResultAndContext(number()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n `failed to get balance for ${publicKey.toBase58()}`,\n );\n }\n return res.result;\n }\n\n /**\n * Fetch the balance for the specified public key\n */\n async getBalance(\n publicKey: PublicKey,\n commitmentOrConfig?: Commitment | GetBalanceConfig,\n ): Promise {\n return await this.getBalanceAndContext(publicKey, commitmentOrConfig)\n .then(x => x.value)\n .catch(e => {\n throw new Error(\n 'failed to get balance of account ' + publicKey.toBase58() + ': ' + e,\n );\n });\n }\n\n /**\n * Fetch the estimated production time of a block\n */\n async getBlockTime(slot: number): Promise {\n const unsafeRes = await this._rpcRequest('getBlockTime', [slot]);\n const res = create(unsafeRes, jsonRpcResult(nullable(number())));\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n `failed to get block time for slot ${slot}`,\n );\n }\n return res.result;\n }\n\n /**\n * Fetch the lowest slot that the node has information about in its ledger.\n * This value may increase over time if the node is configured to purge older ledger data\n */\n async getMinimumLedgerSlot(): Promise {\n const unsafeRes = await this._rpcRequest('minimumLedgerSlot', []);\n const res = create(unsafeRes, jsonRpcResult(number()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n 'failed to get minimum ledger slot',\n );\n }\n return res.result;\n }\n\n /**\n * Fetch the slot of the lowest confirmed block that has not been purged from the ledger\n */\n async getFirstAvailableBlock(): Promise {\n const unsafeRes = await this._rpcRequest('getFirstAvailableBlock', []);\n const res = create(unsafeRes, SlotRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n 'failed to get first available block',\n );\n }\n return res.result;\n }\n\n /**\n * Fetch information about the current supply\n */\n async getSupply(\n config?: GetSupplyConfig | Commitment,\n ): Promise> {\n let configArg: GetSupplyConfig = {};\n if (typeof config === 'string') {\n configArg = {commitment: config};\n } else if (config) {\n configArg = {\n ...config,\n commitment: (config && config.commitment) || this.commitment,\n };\n } else {\n configArg = {\n commitment: this.commitment,\n };\n }\n\n const unsafeRes = await this._rpcRequest('getSupply', [configArg]);\n const res = create(unsafeRes, GetSupplyRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get supply');\n }\n return res.result;\n }\n\n /**\n * Fetch the current supply of a token mint\n */\n async getTokenSupply(\n tokenMintAddress: PublicKey,\n commitment?: Commitment,\n ): Promise> {\n const args = this._buildArgs([tokenMintAddress.toBase58()], commitment);\n const unsafeRes = await this._rpcRequest('getTokenSupply', args);\n const res = create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get token supply');\n }\n return res.result;\n }\n\n /**\n * Fetch the current balance of a token account\n */\n async getTokenAccountBalance(\n tokenAddress: PublicKey,\n commitment?: Commitment,\n ): Promise> {\n const args = this._buildArgs([tokenAddress.toBase58()], commitment);\n const unsafeRes = await this._rpcRequest('getTokenAccountBalance', args);\n const res = create(unsafeRes, jsonRpcResultAndContext(TokenAmountResult));\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n 'failed to get token account balance',\n );\n }\n return res.result;\n }\n\n /**\n * Fetch all the token accounts owned by the specified account\n *\n * @return {Promise}\n */\n async getTokenAccountsByOwner(\n ownerAddress: PublicKey,\n filter: TokenAccountsFilter,\n commitmentOrConfig?: Commitment | GetTokenAccountsByOwnerConfig,\n ): Promise> {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n let _args: any[] = [ownerAddress.toBase58()];\n if ('mint' in filter) {\n _args.push({mint: filter.mint.toBase58()});\n } else {\n _args.push({programId: filter.programId.toBase58()});\n }\n\n const args = this._buildArgs(_args, commitment, 'base64', config);\n const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);\n const res = create(unsafeRes, GetTokenAccountsByOwner);\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n `failed to get token accounts owned by account ${ownerAddress.toBase58()}`,\n );\n }\n return res.result;\n }\n\n /**\n * Fetch parsed token accounts owned by the specified account\n *\n * @return {Promise}>>>}\n */\n async getParsedTokenAccountsByOwner(\n ownerAddress: PublicKey,\n filter: TokenAccountsFilter,\n commitment?: Commitment,\n ): Promise<\n RpcResponseAndContext<\n Array<{pubkey: PublicKey; account: AccountInfo}>\n >\n > {\n let _args: any[] = [ownerAddress.toBase58()];\n if ('mint' in filter) {\n _args.push({mint: filter.mint.toBase58()});\n } else {\n _args.push({programId: filter.programId.toBase58()});\n }\n\n const args = this._buildArgs(_args, commitment, 'jsonParsed');\n const unsafeRes = await this._rpcRequest('getTokenAccountsByOwner', args);\n const res = create(unsafeRes, GetParsedTokenAccountsByOwner);\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n `failed to get token accounts owned by account ${ownerAddress.toBase58()}`,\n );\n }\n return res.result;\n }\n\n /**\n * Fetch the 20 largest accounts with their current balances\n */\n async getLargestAccounts(\n config?: GetLargestAccountsConfig,\n ): Promise>> {\n const arg = {\n ...config,\n commitment: (config && config.commitment) || this.commitment,\n };\n const args = arg.filter || arg.commitment ? [arg] : [];\n const unsafeRes = await this._rpcRequest('getLargestAccounts', args);\n const res = create(unsafeRes, GetLargestAccountsRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get largest accounts');\n }\n return res.result;\n }\n\n /**\n * Fetch the 20 largest token accounts with their current balances\n * for a given mint.\n */\n async getTokenLargestAccounts(\n mintAddress: PublicKey,\n commitment?: Commitment,\n ): Promise>> {\n const args = this._buildArgs([mintAddress.toBase58()], commitment);\n const unsafeRes = await this._rpcRequest('getTokenLargestAccounts', args);\n const res = create(unsafeRes, GetTokenLargestAccountsResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n 'failed to get token largest accounts',\n );\n }\n return res.result;\n }\n\n /**\n * Fetch all the account info for the specified public key, return with context\n */\n async getAccountInfoAndContext(\n publicKey: PublicKey,\n commitmentOrConfig?: Commitment | GetAccountInfoConfig,\n ): Promise | null>> {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs(\n [publicKey.toBase58()],\n commitment,\n 'base64',\n config,\n );\n const unsafeRes = await this._rpcRequest('getAccountInfo', args);\n const res = create(\n unsafeRes,\n jsonRpcResultAndContext(nullable(AccountInfoResult)),\n );\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n `failed to get info about account ${publicKey.toBase58()}`,\n );\n }\n return res.result;\n }\n\n /**\n * Fetch parsed account info for the specified public key\n */\n async getParsedAccountInfo(\n publicKey: PublicKey,\n commitmentOrConfig?: Commitment | GetAccountInfoConfig,\n ): Promise<\n RpcResponseAndContext | null>\n > {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs(\n [publicKey.toBase58()],\n commitment,\n 'jsonParsed',\n config,\n );\n const unsafeRes = await this._rpcRequest('getAccountInfo', args);\n const res = create(\n unsafeRes,\n jsonRpcResultAndContext(nullable(ParsedAccountInfoResult)),\n );\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n `failed to get info about account ${publicKey.toBase58()}`,\n );\n }\n return res.result;\n }\n\n /**\n * Fetch all the account info for the specified public key\n */\n async getAccountInfo(\n publicKey: PublicKey,\n commitmentOrConfig?: Commitment | GetAccountInfoConfig,\n ): Promise | null> {\n try {\n const res = await this.getAccountInfoAndContext(\n publicKey,\n commitmentOrConfig,\n );\n return res.value;\n } catch (e) {\n throw new Error(\n 'failed to get info about account ' + publicKey.toBase58() + ': ' + e,\n );\n }\n }\n\n /**\n * Fetch all the account info for multiple accounts specified by an array of public keys, return with context\n */\n async getMultipleParsedAccounts(\n publicKeys: PublicKey[],\n rawConfig?: GetMultipleAccountsConfig,\n ): Promise<\n RpcResponseAndContext<(AccountInfo | null)[]>\n > {\n const {commitment, config} = extractCommitmentFromConfig(rawConfig);\n const keys = publicKeys.map(key => key.toBase58());\n const args = this._buildArgs([keys], commitment, 'jsonParsed', config);\n const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);\n const res = create(\n unsafeRes,\n jsonRpcResultAndContext(array(nullable(ParsedAccountInfoResult))),\n );\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n `failed to get info for accounts ${keys}`,\n );\n }\n return res.result;\n }\n\n /**\n * Fetch all the account info for multiple accounts specified by an array of public keys, return with context\n */\n async getMultipleAccountsInfoAndContext(\n publicKeys: PublicKey[],\n commitmentOrConfig?: Commitment | GetMultipleAccountsConfig,\n ): Promise | null)[]>> {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const keys = publicKeys.map(key => key.toBase58());\n const args = this._buildArgs([keys], commitment, 'base64', config);\n const unsafeRes = await this._rpcRequest('getMultipleAccounts', args);\n const res = create(\n unsafeRes,\n jsonRpcResultAndContext(array(nullable(AccountInfoResult))),\n );\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n `failed to get info for accounts ${keys}`,\n );\n }\n return res.result;\n }\n\n /**\n * Fetch all the account info for multiple accounts specified by an array of public keys\n */\n async getMultipleAccountsInfo(\n publicKeys: PublicKey[],\n commitmentOrConfig?: Commitment | GetMultipleAccountsConfig,\n ): Promise<(AccountInfo | null)[]> {\n const res = await this.getMultipleAccountsInfoAndContext(\n publicKeys,\n commitmentOrConfig,\n );\n return res.value;\n }\n\n /**\n * Returns epoch activation information for a stake account that has been delegated\n *\n * @deprecated Deprecated since RPC v1.18; will be removed in a future version.\n */\n async getStakeActivation(\n publicKey: PublicKey,\n commitmentOrConfig?: Commitment | GetStakeActivationConfig,\n epoch?: number,\n ): Promise {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs(\n [publicKey.toBase58()],\n commitment,\n undefined /* encoding */,\n {\n ...config,\n epoch: epoch != null ? epoch : config?.epoch,\n },\n );\n\n const unsafeRes = await this._rpcRequest('getStakeActivation', args);\n const res = create(unsafeRes, jsonRpcResult(StakeActivationResult));\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n `failed to get Stake Activation ${publicKey.toBase58()}`,\n );\n }\n return res.result;\n }\n\n /**\n * Fetch all the accounts owned by the specified program id\n *\n * @return {Promise}>>}\n */\n async getProgramAccounts(\n programId: PublicKey,\n configOrCommitment: GetProgramAccountsConfig &\n Readonly<{withContext: true}>,\n ): Promise>;\n // eslint-disable-next-line no-dupe-class-members\n async getProgramAccounts(\n programId: PublicKey,\n configOrCommitment?: GetProgramAccountsConfig | Commitment,\n ): Promise;\n // eslint-disable-next-line no-dupe-class-members\n async getProgramAccounts(\n programId: PublicKey,\n configOrCommitment?: GetProgramAccountsConfig | Commitment,\n ): Promise<\n | GetProgramAccountsResponse\n | RpcResponseAndContext\n > {\n const {commitment, config} =\n extractCommitmentFromConfig(configOrCommitment);\n const {encoding, ...configWithoutEncoding} = config || {};\n const args = this._buildArgs(\n [programId.toBase58()],\n commitment,\n encoding || 'base64',\n {\n ...configWithoutEncoding,\n ...(configWithoutEncoding.filters\n ? {\n filters: applyDefaultMemcmpEncodingToFilters(\n configWithoutEncoding.filters,\n ),\n }\n : null),\n },\n );\n const unsafeRes = await this._rpcRequest('getProgramAccounts', args);\n const baseSchema = array(KeyedAccountInfoResult);\n const res =\n configWithoutEncoding.withContext === true\n ? create(unsafeRes, jsonRpcResultAndContext(baseSchema))\n : create(unsafeRes, jsonRpcResult(baseSchema));\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n `failed to get accounts owned by program ${programId.toBase58()}`,\n );\n }\n return res.result;\n }\n\n /**\n * Fetch and parse all the accounts owned by the specified program id\n *\n * @return {Promise}>>}\n */\n async getParsedProgramAccounts(\n programId: PublicKey,\n configOrCommitment?: GetParsedProgramAccountsConfig | Commitment,\n ): Promise<\n Array<{\n pubkey: PublicKey;\n account: AccountInfo;\n }>\n > {\n const {commitment, config} =\n extractCommitmentFromConfig(configOrCommitment);\n const args = this._buildArgs(\n [programId.toBase58()],\n commitment,\n 'jsonParsed',\n config,\n );\n const unsafeRes = await this._rpcRequest('getProgramAccounts', args);\n const res = create(\n unsafeRes,\n jsonRpcResult(array(KeyedParsedAccountInfoResult)),\n );\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n `failed to get accounts owned by program ${programId.toBase58()}`,\n );\n }\n return res.result;\n }\n\n confirmTransaction(\n strategy: TransactionConfirmationStrategy,\n commitment?: Commitment,\n ): Promise>;\n\n /** @deprecated Instead, call `confirmTransaction` and pass in {@link TransactionConfirmationStrategy} */\n // eslint-disable-next-line no-dupe-class-members\n confirmTransaction(\n strategy: TransactionSignature,\n commitment?: Commitment,\n ): Promise>;\n\n // eslint-disable-next-line no-dupe-class-members\n async confirmTransaction(\n strategy: TransactionConfirmationStrategy | TransactionSignature,\n commitment?: Commitment,\n ): Promise> {\n let rawSignature: string;\n\n if (typeof strategy == 'string') {\n rawSignature = strategy;\n } else {\n const config = strategy as TransactionConfirmationStrategy;\n\n if (config.abortSignal?.aborted) {\n return Promise.reject(config.abortSignal.reason);\n }\n rawSignature = config.signature;\n }\n\n let decodedSignature;\n\n try {\n decodedSignature = bs58.decode(rawSignature);\n } catch (err) {\n throw new Error('signature must be base58 encoded: ' + rawSignature);\n }\n\n assert(decodedSignature.length === 64, 'signature has invalid length');\n\n if (typeof strategy === 'string') {\n return await this.confirmTransactionUsingLegacyTimeoutStrategy({\n commitment: commitment || this.commitment,\n signature: rawSignature,\n });\n } else if ('lastValidBlockHeight' in strategy) {\n return await this.confirmTransactionUsingBlockHeightExceedanceStrategy({\n commitment: commitment || this.commitment,\n strategy,\n });\n } else {\n return await this.confirmTransactionUsingDurableNonceStrategy({\n commitment: commitment || this.commitment,\n strategy,\n });\n }\n }\n\n private getCancellationPromise(signal?: AbortSignal): Promise {\n return new Promise((_, reject) => {\n if (signal == null) {\n return;\n }\n if (signal.aborted) {\n reject(signal.reason);\n } else {\n signal.addEventListener('abort', () => {\n reject(signal.reason);\n });\n }\n });\n }\n\n private getTransactionConfirmationPromise({\n commitment,\n signature,\n }: {\n commitment?: Commitment;\n signature: string;\n }): {\n abortConfirmation(): void;\n confirmationPromise: Promise<{\n __type: TransactionStatus.PROCESSED;\n response: RpcResponseAndContext;\n }>;\n } {\n let signatureSubscriptionId: number | undefined;\n let disposeSignatureSubscriptionStateChangeObserver:\n | SubscriptionStateChangeDisposeFn\n | undefined;\n let done = false;\n const confirmationPromise = new Promise<{\n __type: TransactionStatus.PROCESSED;\n response: RpcResponseAndContext;\n }>((resolve, reject) => {\n try {\n signatureSubscriptionId = this.onSignature(\n signature,\n (result: SignatureResult, context: Context) => {\n signatureSubscriptionId = undefined;\n const response = {\n context,\n value: result,\n };\n resolve({__type: TransactionStatus.PROCESSED, response});\n },\n commitment,\n );\n const subscriptionSetupPromise = new Promise(\n resolveSubscriptionSetup => {\n if (signatureSubscriptionId == null) {\n resolveSubscriptionSetup();\n } else {\n disposeSignatureSubscriptionStateChangeObserver =\n this._onSubscriptionStateChange(\n signatureSubscriptionId,\n nextState => {\n if (nextState === 'subscribed') {\n resolveSubscriptionSetup();\n }\n },\n );\n }\n },\n );\n (async () => {\n await subscriptionSetupPromise;\n if (done) return;\n const response = await this.getSignatureStatus(signature);\n if (done) return;\n if (response == null) {\n return;\n }\n const {context, value} = response;\n if (value == null) {\n return;\n }\n if (value?.err) {\n reject(value.err);\n } else {\n switch (commitment) {\n case 'confirmed':\n case 'single':\n case 'singleGossip': {\n if (value.confirmationStatus === 'processed') {\n return;\n }\n break;\n }\n case 'finalized':\n case 'max':\n case 'root': {\n if (\n value.confirmationStatus === 'processed' ||\n value.confirmationStatus === 'confirmed'\n ) {\n return;\n }\n break;\n }\n // exhaust enums to ensure full coverage\n case 'processed':\n case 'recent':\n }\n done = true;\n resolve({\n __type: TransactionStatus.PROCESSED,\n response: {\n context,\n value,\n },\n });\n }\n })();\n } catch (err) {\n reject(err);\n }\n });\n const abortConfirmation = () => {\n if (disposeSignatureSubscriptionStateChangeObserver) {\n disposeSignatureSubscriptionStateChangeObserver();\n disposeSignatureSubscriptionStateChangeObserver = undefined;\n }\n if (signatureSubscriptionId != null) {\n this.removeSignatureListener(signatureSubscriptionId);\n signatureSubscriptionId = undefined;\n }\n };\n return {abortConfirmation, confirmationPromise};\n }\n\n private async confirmTransactionUsingBlockHeightExceedanceStrategy({\n commitment,\n strategy: {abortSignal, lastValidBlockHeight, signature},\n }: {\n commitment?: Commitment;\n strategy: BlockheightBasedTransactionConfirmationStrategy;\n }) {\n let done: boolean = false;\n const expiryPromise = new Promise<{\n __type: TransactionStatus.BLOCKHEIGHT_EXCEEDED;\n }>(resolve => {\n const checkBlockHeight = async () => {\n try {\n const blockHeight = await this.getBlockHeight(commitment);\n return blockHeight;\n } catch (_e) {\n return -1;\n }\n };\n (async () => {\n let currentBlockHeight = await checkBlockHeight();\n if (done) return;\n while (currentBlockHeight <= lastValidBlockHeight) {\n await sleep(1000);\n if (done) return;\n currentBlockHeight = await checkBlockHeight();\n if (done) return;\n }\n resolve({__type: TransactionStatus.BLOCKHEIGHT_EXCEEDED});\n })();\n });\n const {abortConfirmation, confirmationPromise} =\n this.getTransactionConfirmationPromise({commitment, signature});\n const cancellationPromise = this.getCancellationPromise(abortSignal);\n let result: RpcResponseAndContext;\n try {\n const outcome = await Promise.race([\n cancellationPromise,\n confirmationPromise,\n expiryPromise,\n ]);\n if (outcome.__type === TransactionStatus.PROCESSED) {\n result = outcome.response;\n } else {\n throw new TransactionExpiredBlockheightExceededError(signature);\n }\n } finally {\n done = true;\n abortConfirmation();\n }\n return result;\n }\n\n private async confirmTransactionUsingDurableNonceStrategy({\n commitment,\n strategy: {\n abortSignal,\n minContextSlot,\n nonceAccountPubkey,\n nonceValue,\n signature,\n },\n }: {\n commitment?: Commitment;\n strategy: DurableNonceTransactionConfirmationStrategy;\n }) {\n let done: boolean = false;\n const expiryPromise = new Promise<{\n __type: TransactionStatus.NONCE_INVALID;\n slotInWhichNonceDidAdvance: number | null;\n }>(resolve => {\n let currentNonceValue: string | undefined = nonceValue;\n let lastCheckedSlot: number | null = null;\n const getCurrentNonceValue = async () => {\n try {\n const {context, value: nonceAccount} = await this.getNonceAndContext(\n nonceAccountPubkey,\n {\n commitment,\n minContextSlot,\n },\n );\n lastCheckedSlot = context.slot;\n return nonceAccount?.nonce;\n } catch (e) {\n // If for whatever reason we can't reach/read the nonce\n // account, just keep using the last-known value.\n return currentNonceValue;\n }\n };\n (async () => {\n currentNonceValue = await getCurrentNonceValue();\n if (done) return;\n while (\n true // eslint-disable-line no-constant-condition\n ) {\n if (nonceValue !== currentNonceValue) {\n resolve({\n __type: TransactionStatus.NONCE_INVALID,\n slotInWhichNonceDidAdvance: lastCheckedSlot,\n });\n return;\n }\n await sleep(2000);\n if (done) return;\n currentNonceValue = await getCurrentNonceValue();\n if (done) return;\n }\n })();\n });\n const {abortConfirmation, confirmationPromise} =\n this.getTransactionConfirmationPromise({commitment, signature});\n const cancellationPromise = this.getCancellationPromise(abortSignal);\n let result: RpcResponseAndContext;\n try {\n const outcome = await Promise.race([\n cancellationPromise,\n confirmationPromise,\n expiryPromise,\n ]);\n if (outcome.__type === TransactionStatus.PROCESSED) {\n result = outcome.response;\n } else {\n // Double check that the transaction is indeed unconfirmed.\n let signatureStatus:\n | RpcResponseAndContext\n | null\n | undefined;\n while (\n true // eslint-disable-line no-constant-condition\n ) {\n const status = await this.getSignatureStatus(signature);\n if (status == null) {\n break;\n }\n if (\n status.context.slot <\n (outcome.slotInWhichNonceDidAdvance ?? minContextSlot)\n ) {\n await sleep(400);\n continue;\n }\n signatureStatus = status;\n break;\n }\n if (signatureStatus?.value) {\n const commitmentForStatus = commitment || 'finalized';\n const {confirmationStatus} = signatureStatus.value;\n switch (commitmentForStatus) {\n case 'processed':\n case 'recent':\n if (\n confirmationStatus !== 'processed' &&\n confirmationStatus !== 'confirmed' &&\n confirmationStatus !== 'finalized'\n ) {\n throw new TransactionExpiredNonceInvalidError(signature);\n }\n break;\n case 'confirmed':\n case 'single':\n case 'singleGossip':\n if (\n confirmationStatus !== 'confirmed' &&\n confirmationStatus !== 'finalized'\n ) {\n throw new TransactionExpiredNonceInvalidError(signature);\n }\n break;\n case 'finalized':\n case 'max':\n case 'root':\n if (confirmationStatus !== 'finalized') {\n throw new TransactionExpiredNonceInvalidError(signature);\n }\n break;\n default:\n // Exhaustive switch.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n ((_: never) => {})(commitmentForStatus);\n }\n result = {\n context: signatureStatus.context,\n value: {err: signatureStatus.value.err},\n };\n } else {\n throw new TransactionExpiredNonceInvalidError(signature);\n }\n }\n } finally {\n done = true;\n abortConfirmation();\n }\n return result;\n }\n\n private async confirmTransactionUsingLegacyTimeoutStrategy({\n commitment,\n signature,\n }: {\n commitment?: Commitment;\n signature: string;\n }) {\n let timeoutId;\n const expiryPromise = new Promise<{\n __type: TransactionStatus.TIMED_OUT;\n timeoutMs: number;\n }>(resolve => {\n let timeoutMs = this._confirmTransactionInitialTimeout || 60 * 1000;\n switch (commitment) {\n case 'processed':\n case 'recent':\n case 'single':\n case 'confirmed':\n case 'singleGossip': {\n timeoutMs = this._confirmTransactionInitialTimeout || 30 * 1000;\n break;\n }\n // exhaust enums to ensure full coverage\n case 'finalized':\n case 'max':\n case 'root':\n }\n timeoutId = setTimeout(\n () => resolve({__type: TransactionStatus.TIMED_OUT, timeoutMs}),\n timeoutMs,\n );\n });\n const {abortConfirmation, confirmationPromise} =\n this.getTransactionConfirmationPromise({\n commitment,\n signature,\n });\n let result: RpcResponseAndContext;\n try {\n const outcome = await Promise.race([confirmationPromise, expiryPromise]);\n if (outcome.__type === TransactionStatus.PROCESSED) {\n result = outcome.response;\n } else {\n throw new TransactionExpiredTimeoutError(\n signature,\n outcome.timeoutMs / 1000,\n );\n }\n } finally {\n clearTimeout(timeoutId);\n abortConfirmation();\n }\n return result;\n }\n\n /**\n * Return the list of nodes that are currently participating in the cluster\n */\n async getClusterNodes(): Promise> {\n const unsafeRes = await this._rpcRequest('getClusterNodes', []);\n const res = create(unsafeRes, jsonRpcResult(array(ContactInfoResult)));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get cluster nodes');\n }\n return res.result;\n }\n\n /**\n * Return the list of nodes that are currently participating in the cluster\n */\n async getVoteAccounts(commitment?: Commitment): Promise {\n const args = this._buildArgs([], commitment);\n const unsafeRes = await this._rpcRequest('getVoteAccounts', args);\n const res = create(unsafeRes, GetVoteAccounts);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get vote accounts');\n }\n return res.result;\n }\n\n /**\n * Fetch the current slot that the node is processing\n */\n async getSlot(\n commitmentOrConfig?: Commitment | GetSlotConfig,\n ): Promise {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs(\n [],\n commitment,\n undefined /* encoding */,\n config,\n );\n const unsafeRes = await this._rpcRequest('getSlot', args);\n const res = create(unsafeRes, jsonRpcResult(number()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get slot');\n }\n return res.result;\n }\n\n /**\n * Fetch the current slot leader of the cluster\n */\n async getSlotLeader(\n commitmentOrConfig?: Commitment | GetSlotLeaderConfig,\n ): Promise {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs(\n [],\n commitment,\n undefined /* encoding */,\n config,\n );\n const unsafeRes = await this._rpcRequest('getSlotLeader', args);\n const res = create(unsafeRes, jsonRpcResult(string()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get slot leader');\n }\n return res.result;\n }\n\n /**\n * Fetch `limit` number of slot leaders starting from `startSlot`\n *\n * @param startSlot fetch slot leaders starting from this slot\n * @param limit number of slot leaders to return\n */\n async getSlotLeaders(\n startSlot: number,\n limit: number,\n ): Promise> {\n const args = [startSlot, limit];\n const unsafeRes = await this._rpcRequest('getSlotLeaders', args);\n const res = create(unsafeRes, jsonRpcResult(array(PublicKeyFromString)));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get slot leaders');\n }\n return res.result;\n }\n\n /**\n * Fetch the current status of a signature\n */\n async getSignatureStatus(\n signature: TransactionSignature,\n config?: SignatureStatusConfig,\n ): Promise> {\n const {context, value: values} = await this.getSignatureStatuses(\n [signature],\n config,\n );\n assert(values.length === 1);\n const value = values[0];\n return {context, value};\n }\n\n /**\n * Fetch the current statuses of a batch of signatures\n */\n async getSignatureStatuses(\n signatures: Array,\n config?: SignatureStatusConfig,\n ): Promise>> {\n const params: any[] = [signatures];\n if (config) {\n params.push(config);\n }\n const unsafeRes = await this._rpcRequest('getSignatureStatuses', params);\n const res = create(unsafeRes, GetSignatureStatusesRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get signature status');\n }\n return res.result;\n }\n\n /**\n * Fetch the current transaction count of the cluster\n */\n async getTransactionCount(\n commitmentOrConfig?: Commitment | GetTransactionCountConfig,\n ): Promise {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs(\n [],\n commitment,\n undefined /* encoding */,\n config,\n );\n const unsafeRes = await this._rpcRequest('getTransactionCount', args);\n const res = create(unsafeRes, jsonRpcResult(number()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n 'failed to get transaction count',\n );\n }\n return res.result;\n }\n\n /**\n * Fetch the current total currency supply of the cluster in lamports\n *\n * @deprecated Deprecated since RPC v1.2.8. Please use {@link getSupply} instead.\n */\n async getTotalSupply(commitment?: Commitment): Promise {\n const result = await this.getSupply({\n commitment,\n excludeNonCirculatingAccountsList: true,\n });\n return result.value.total;\n }\n\n /**\n * Fetch the cluster InflationGovernor parameters\n */\n async getInflationGovernor(\n commitment?: Commitment,\n ): Promise {\n const args = this._buildArgs([], commitment);\n const unsafeRes = await this._rpcRequest('getInflationGovernor', args);\n const res = create(unsafeRes, GetInflationGovernorRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get inflation');\n }\n return res.result;\n }\n\n /**\n * Fetch the inflation reward for a list of addresses for an epoch\n */\n async getInflationReward(\n addresses: PublicKey[],\n epoch?: number,\n commitmentOrConfig?: Commitment | GetInflationRewardConfig,\n ): Promise<(InflationReward | null)[]> {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs(\n [addresses.map(pubkey => pubkey.toBase58())],\n commitment,\n undefined /* encoding */,\n {\n ...config,\n epoch: epoch != null ? epoch : config?.epoch,\n },\n );\n const unsafeRes = await this._rpcRequest('getInflationReward', args);\n const res = create(unsafeRes, GetInflationRewardResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get inflation reward');\n }\n return res.result;\n }\n\n /**\n * Fetch the specific inflation values for the current epoch\n */\n async getInflationRate(): Promise {\n const unsafeRes = await this._rpcRequest('getInflationRate', []);\n const res = create(unsafeRes, GetInflationRateRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get inflation rate');\n }\n return res.result;\n }\n\n /**\n * Fetch the Epoch Info parameters\n */\n async getEpochInfo(\n commitmentOrConfig?: Commitment | GetEpochInfoConfig,\n ): Promise {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs(\n [],\n commitment,\n undefined /* encoding */,\n config,\n );\n const unsafeRes = await this._rpcRequest('getEpochInfo', args);\n const res = create(unsafeRes, GetEpochInfoRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get epoch info');\n }\n return res.result;\n }\n\n /**\n * Fetch the Epoch Schedule parameters\n */\n async getEpochSchedule(): Promise {\n const unsafeRes = await this._rpcRequest('getEpochSchedule', []);\n const res = create(unsafeRes, GetEpochScheduleRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get epoch schedule');\n }\n const epochSchedule = res.result;\n return new EpochSchedule(\n epochSchedule.slotsPerEpoch,\n epochSchedule.leaderScheduleSlotOffset,\n epochSchedule.warmup,\n epochSchedule.firstNormalEpoch,\n epochSchedule.firstNormalSlot,\n );\n }\n\n /**\n * Fetch the leader schedule for the current epoch\n * @return {Promise>}\n */\n async getLeaderSchedule(): Promise {\n const unsafeRes = await this._rpcRequest('getLeaderSchedule', []);\n const res = create(unsafeRes, GetLeaderScheduleRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get leader schedule');\n }\n return res.result;\n }\n\n /**\n * Fetch the minimum balance needed to exempt an account of `dataLength`\n * size from rent\n */\n async getMinimumBalanceForRentExemption(\n dataLength: number,\n commitment?: Commitment,\n ): Promise {\n const args = this._buildArgs([dataLength], commitment);\n const unsafeRes = await this._rpcRequest(\n 'getMinimumBalanceForRentExemption',\n args,\n );\n const res = create(unsafeRes, GetMinimumBalanceForRentExemptionRpcResult);\n if ('error' in res) {\n console.warn('Unable to fetch minimum balance for rent exemption');\n return 0;\n }\n return res.result;\n }\n\n /**\n * Fetch a recent blockhash from the cluster, return with context\n * @return {Promise>}\n *\n * @deprecated Deprecated since RPC v1.9.0. Please use {@link getLatestBlockhash} instead.\n */\n async getRecentBlockhashAndContext(commitment?: Commitment): Promise<\n RpcResponseAndContext<{\n blockhash: Blockhash;\n feeCalculator: FeeCalculator;\n }>\n > {\n const {\n context,\n value: {blockhash},\n } = await this.getLatestBlockhashAndContext(commitment);\n const feeCalculator = {\n get lamportsPerSignature(): number {\n throw new Error(\n 'The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is ' +\n 'no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee ' +\n 'for a given message.',\n );\n },\n toJSON() {\n return {};\n },\n };\n return {\n context,\n value: {\n blockhash,\n feeCalculator,\n },\n };\n }\n\n /**\n * Fetch recent performance samples\n * @return {Promise>}\n */\n async getRecentPerformanceSamples(\n limit?: number,\n ): Promise> {\n const unsafeRes = await this._rpcRequest(\n 'getRecentPerformanceSamples',\n limit ? [limit] : [],\n );\n const res = create(unsafeRes, GetRecentPerformanceSamplesRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n 'failed to get recent performance samples',\n );\n }\n\n return res.result;\n }\n\n /**\n * Fetch the fee calculator for a recent blockhash from the cluster, return with context\n *\n * @deprecated Deprecated since RPC v1.9.0. Please use {@link getFeeForMessage} instead.\n */\n async getFeeCalculatorForBlockhash(\n blockhash: Blockhash,\n commitment?: Commitment,\n ): Promise> {\n const args = this._buildArgs([blockhash], commitment);\n const unsafeRes = await this._rpcRequest(\n 'getFeeCalculatorForBlockhash',\n args,\n );\n\n const res = create(unsafeRes, GetFeeCalculatorRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get fee calculator');\n }\n const {context, value} = res.result;\n return {\n context,\n value: value !== null ? value.feeCalculator : null,\n };\n }\n\n /**\n * Fetch the fee for a message from the cluster, return with context\n */\n async getFeeForMessage(\n message: VersionedMessage,\n commitment?: Commitment,\n ): Promise> {\n const wireMessage = toBuffer(message.serialize()).toString('base64');\n const args = this._buildArgs([wireMessage], commitment);\n const unsafeRes = await this._rpcRequest('getFeeForMessage', args);\n\n const res = create(unsafeRes, jsonRpcResultAndContext(nullable(number())));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get fee for message');\n }\n if (res.result === null) {\n throw new Error('invalid blockhash');\n }\n return res.result;\n }\n\n /**\n * Fetch a list of prioritization fees from recent blocks.\n */\n async getRecentPrioritizationFees(\n config?: GetRecentPrioritizationFeesConfig,\n ): Promise {\n const accounts = config?.lockedWritableAccounts?.map(key => key.toBase58());\n const args = accounts?.length ? [accounts] : [];\n const unsafeRes = await this._rpcRequest(\n 'getRecentPrioritizationFees',\n args,\n );\n const res = create(unsafeRes, GetRecentPrioritizationFeesRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n 'failed to get recent prioritization fees',\n );\n }\n return res.result;\n }\n /**\n * Fetch a recent blockhash from the cluster\n * @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}\n *\n * @deprecated Deprecated since RPC v1.8.0. Please use {@link getLatestBlockhash} instead.\n */\n async getRecentBlockhash(\n commitment?: Commitment,\n ): Promise<{blockhash: Blockhash; feeCalculator: FeeCalculator}> {\n try {\n const res = await this.getRecentBlockhashAndContext(commitment);\n return res.value;\n } catch (e) {\n throw new Error('failed to get recent blockhash: ' + e);\n }\n }\n\n /**\n * Fetch the latest blockhash from the cluster\n * @return {Promise}\n */\n async getLatestBlockhash(\n commitmentOrConfig?: Commitment | GetLatestBlockhashConfig,\n ): Promise {\n try {\n const res = await this.getLatestBlockhashAndContext(commitmentOrConfig);\n return res.value;\n } catch (e) {\n throw new Error('failed to get recent blockhash: ' + e);\n }\n }\n\n /**\n * Fetch the latest blockhash from the cluster\n * @return {Promise}\n */\n async getLatestBlockhashAndContext(\n commitmentOrConfig?: Commitment | GetLatestBlockhashConfig,\n ): Promise> {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs(\n [],\n commitment,\n undefined /* encoding */,\n config,\n );\n const unsafeRes = await this._rpcRequest('getLatestBlockhash', args);\n const res = create(unsafeRes, GetLatestBlockhashRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get latest blockhash');\n }\n return res.result;\n }\n\n /**\n * Returns whether a blockhash is still valid or not\n */\n async isBlockhashValid(\n blockhash: Blockhash,\n rawConfig?: IsBlockhashValidConfig,\n ): Promise> {\n const {commitment, config} = extractCommitmentFromConfig(rawConfig);\n const args = this._buildArgs(\n [blockhash],\n commitment,\n undefined /* encoding */,\n config,\n );\n const unsafeRes = await this._rpcRequest('isBlockhashValid', args);\n const res = create(unsafeRes, IsBlockhashValidRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n 'failed to determine if the blockhash `' + blockhash + '`is valid',\n );\n }\n return res.result;\n }\n\n /**\n * Fetch the node version\n */\n async getVersion(): Promise {\n const unsafeRes = await this._rpcRequest('getVersion', []);\n const res = create(unsafeRes, jsonRpcResult(VersionResult));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get version');\n }\n return res.result;\n }\n\n /**\n * Fetch the genesis hash\n */\n async getGenesisHash(): Promise {\n const unsafeRes = await this._rpcRequest('getGenesisHash', []);\n const res = create(unsafeRes, jsonRpcResult(string()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get genesis hash');\n }\n return res.result;\n }\n\n /**\n * Fetch a processed block from the cluster.\n *\n * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by\n * setting the `maxSupportedTransactionVersion` property.\n */\n async getBlock(\n slot: number,\n rawConfig?: GetBlockConfig,\n ): Promise;\n\n /**\n * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by\n * setting the `maxSupportedTransactionVersion` property.\n */\n // eslint-disable-next-line no-dupe-class-members\n async getBlock(\n slot: number,\n rawConfig: GetBlockConfig & {transactionDetails: 'accounts'},\n ): Promise;\n\n /**\n * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by\n * setting the `maxSupportedTransactionVersion` property.\n */\n // eslint-disable-next-line no-dupe-class-members\n async getBlock(\n slot: number,\n rawConfig: GetBlockConfig & {transactionDetails: 'none'},\n ): Promise;\n\n /**\n * Fetch a processed block from the cluster.\n */\n // eslint-disable-next-line no-dupe-class-members\n async getBlock(\n slot: number,\n rawConfig?: GetVersionedBlockConfig,\n ): Promise;\n\n // eslint-disable-next-line no-dupe-class-members\n async getBlock(\n slot: number,\n rawConfig: GetVersionedBlockConfig & {transactionDetails: 'accounts'},\n ): Promise;\n\n // eslint-disable-next-line no-dupe-class-members\n async getBlock(\n slot: number,\n rawConfig: GetVersionedBlockConfig & {transactionDetails: 'none'},\n ): Promise;\n\n /**\n * Fetch a processed block from the cluster.\n */\n // eslint-disable-next-line no-dupe-class-members\n async getBlock(\n slot: number,\n rawConfig?: GetVersionedBlockConfig,\n ): Promise<\n | VersionedBlockResponse\n | VersionedAccountsModeBlockResponse\n | VersionedNoneModeBlockResponse\n | null\n > {\n const {commitment, config} = extractCommitmentFromConfig(rawConfig);\n const args = this._buildArgsAtLeastConfirmed(\n [slot],\n commitment as Finality,\n undefined /* encoding */,\n config,\n );\n const unsafeRes = await this._rpcRequest('getBlock', args);\n try {\n switch (config?.transactionDetails) {\n case 'accounts': {\n const res = create(unsafeRes, GetAccountsModeBlockRpcResult);\n if ('error' in res) {\n throw res.error;\n }\n return res.result;\n }\n case 'none': {\n const res = create(unsafeRes, GetNoneModeBlockRpcResult);\n if ('error' in res) {\n throw res.error;\n }\n return res.result;\n }\n default: {\n const res = create(unsafeRes, GetBlockRpcResult);\n if ('error' in res) {\n throw res.error;\n }\n const {result} = res;\n return result\n ? {\n ...result,\n transactions: result.transactions.map(\n ({transaction, meta, version}) => ({\n meta,\n transaction: {\n ...transaction,\n message: versionedMessageFromResponse(\n version,\n transaction.message,\n ),\n },\n version,\n }),\n ),\n }\n : null;\n }\n }\n } catch (e) {\n throw new SolanaJSONRPCError(\n e as JSONRPCError,\n 'failed to get confirmed block',\n );\n }\n }\n\n /**\n * Fetch parsed transaction details for a confirmed or finalized block\n */\n async getParsedBlock(\n slot: number,\n rawConfig?: GetVersionedBlockConfig,\n ): Promise;\n\n // eslint-disable-next-line no-dupe-class-members\n async getParsedBlock(\n slot: number,\n rawConfig: GetVersionedBlockConfig & {transactionDetails: 'accounts'},\n ): Promise;\n\n // eslint-disable-next-line no-dupe-class-members\n async getParsedBlock(\n slot: number,\n rawConfig: GetVersionedBlockConfig & {transactionDetails: 'none'},\n ): Promise;\n // eslint-disable-next-line no-dupe-class-members\n async getParsedBlock(\n slot: number,\n rawConfig?: GetVersionedBlockConfig,\n ): Promise<\n | ParsedBlockResponse\n | ParsedAccountsModeBlockResponse\n | ParsedNoneModeBlockResponse\n | null\n > {\n const {commitment, config} = extractCommitmentFromConfig(rawConfig);\n const args = this._buildArgsAtLeastConfirmed(\n [slot],\n commitment as Finality,\n 'jsonParsed',\n config,\n );\n const unsafeRes = await this._rpcRequest('getBlock', args);\n try {\n switch (config?.transactionDetails) {\n case 'accounts': {\n const res = create(unsafeRes, GetParsedAccountsModeBlockRpcResult);\n if ('error' in res) {\n throw res.error;\n }\n return res.result;\n }\n case 'none': {\n const res = create(unsafeRes, GetParsedNoneModeBlockRpcResult);\n if ('error' in res) {\n throw res.error;\n }\n return res.result;\n }\n default: {\n const res = create(unsafeRes, GetParsedBlockRpcResult);\n if ('error' in res) {\n throw res.error;\n }\n return res.result;\n }\n }\n } catch (e) {\n throw new SolanaJSONRPCError(e as JSONRPCError, 'failed to get block');\n }\n }\n\n /*\n * Returns the current block height of the node\n */\n getBlockHeight = (() => {\n const requestPromises: {[hash: string]: Promise} = {};\n return async (\n commitmentOrConfig?: Commitment | GetBlockHeightConfig,\n ): Promise => {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs(\n [],\n commitment,\n undefined /* encoding */,\n config,\n );\n const requestHash = fastStableStringify(args);\n requestPromises[requestHash] =\n requestPromises[requestHash] ??\n (async () => {\n try {\n const unsafeRes = await this._rpcRequest('getBlockHeight', args);\n const res = create(unsafeRes, jsonRpcResult(number()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n 'failed to get block height information',\n );\n }\n return res.result;\n } finally {\n delete requestPromises[requestHash];\n }\n })();\n return await requestPromises[requestHash];\n };\n })();\n\n /*\n * Returns recent block production information from the current or previous epoch\n */\n async getBlockProduction(\n configOrCommitment?: GetBlockProductionConfig | Commitment,\n ): Promise> {\n let extra: Omit | undefined;\n let commitment: Commitment | undefined;\n\n if (typeof configOrCommitment === 'string') {\n commitment = configOrCommitment;\n } else if (configOrCommitment) {\n const {commitment: c, ...rest} = configOrCommitment;\n commitment = c;\n extra = rest;\n }\n\n const args = this._buildArgs([], commitment, 'base64', extra);\n const unsafeRes = await this._rpcRequest('getBlockProduction', args);\n const res = create(unsafeRes, BlockProductionResponseStruct);\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n 'failed to get block production information',\n );\n }\n\n return res.result;\n }\n\n /**\n * Fetch a confirmed or finalized transaction from the cluster.\n *\n * @deprecated Instead, call `getTransaction` using a\n * `GetVersionedTransactionConfig` by setting the\n * `maxSupportedTransactionVersion` property.\n */\n async getTransaction(\n signature: string,\n rawConfig?: GetTransactionConfig,\n ): Promise;\n\n /**\n * Fetch a confirmed or finalized transaction from the cluster.\n */\n // eslint-disable-next-line no-dupe-class-members\n async getTransaction(\n signature: string,\n rawConfig: GetVersionedTransactionConfig,\n ): Promise;\n\n /**\n * Fetch a confirmed or finalized transaction from the cluster.\n */\n // eslint-disable-next-line no-dupe-class-members\n async getTransaction(\n signature: string,\n rawConfig?: GetVersionedTransactionConfig,\n ): Promise {\n const {commitment, config} = extractCommitmentFromConfig(rawConfig);\n const args = this._buildArgsAtLeastConfirmed(\n [signature],\n commitment as Finality,\n undefined /* encoding */,\n config,\n );\n const unsafeRes = await this._rpcRequest('getTransaction', args);\n const res = create(unsafeRes, GetTransactionRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get transaction');\n }\n\n const result = res.result;\n if (!result) return result;\n\n return {\n ...result,\n transaction: {\n ...result.transaction,\n message: versionedMessageFromResponse(\n result.version,\n result.transaction.message,\n ),\n },\n };\n }\n\n /**\n * Fetch parsed transaction details for a confirmed or finalized transaction\n */\n async getParsedTransaction(\n signature: TransactionSignature,\n commitmentOrConfig?: GetVersionedTransactionConfig | Finality,\n ): Promise {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgsAtLeastConfirmed(\n [signature],\n commitment as Finality,\n 'jsonParsed',\n config,\n );\n const unsafeRes = await this._rpcRequest('getTransaction', args);\n const res = create(unsafeRes, GetParsedTransactionRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get transaction');\n }\n return res.result;\n }\n\n /**\n * Fetch parsed transaction details for a batch of confirmed transactions\n */\n async getParsedTransactions(\n signatures: TransactionSignature[],\n commitmentOrConfig?: GetVersionedTransactionConfig | Finality,\n ): Promise<(ParsedTransactionWithMeta | null)[]> {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const batch = signatures.map(signature => {\n const args = this._buildArgsAtLeastConfirmed(\n [signature],\n commitment as Finality,\n 'jsonParsed',\n config,\n );\n return {\n methodName: 'getTransaction',\n args,\n };\n });\n\n const unsafeRes = await this._rpcBatchRequest(batch);\n const res = unsafeRes.map((unsafeRes: any) => {\n const res = create(unsafeRes, GetParsedTransactionRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get transactions');\n }\n return res.result;\n });\n\n return res;\n }\n\n /**\n * Fetch transaction details for a batch of confirmed transactions.\n * Similar to {@link getParsedTransactions} but returns a {@link TransactionResponse}.\n *\n * @deprecated Instead, call `getTransactions` using a\n * `GetVersionedTransactionConfig` by setting the\n * `maxSupportedTransactionVersion` property.\n */\n async getTransactions(\n signatures: TransactionSignature[],\n commitmentOrConfig?: GetTransactionConfig | Finality,\n ): Promise<(TransactionResponse | null)[]>;\n\n /**\n * Fetch transaction details for a batch of confirmed transactions.\n * Similar to {@link getParsedTransactions} but returns a {@link\n * VersionedTransactionResponse}.\n */\n // eslint-disable-next-line no-dupe-class-members\n async getTransactions(\n signatures: TransactionSignature[],\n commitmentOrConfig: GetVersionedTransactionConfig | Finality,\n ): Promise<(VersionedTransactionResponse | null)[]>;\n\n /**\n * Fetch transaction details for a batch of confirmed transactions.\n * Similar to {@link getParsedTransactions} but returns a {@link\n * VersionedTransactionResponse}.\n */\n // eslint-disable-next-line no-dupe-class-members\n async getTransactions(\n signatures: TransactionSignature[],\n commitmentOrConfig: GetVersionedTransactionConfig | Finality,\n ): Promise<(VersionedTransactionResponse | null)[]> {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const batch = signatures.map(signature => {\n const args = this._buildArgsAtLeastConfirmed(\n [signature],\n commitment as Finality,\n undefined /* encoding */,\n config,\n );\n return {\n methodName: 'getTransaction',\n args,\n };\n });\n\n const unsafeRes = await this._rpcBatchRequest(batch);\n const res = unsafeRes.map((unsafeRes: any) => {\n const res = create(unsafeRes, GetTransactionRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get transactions');\n }\n const result = res.result;\n if (!result) return result;\n\n return {\n ...result,\n transaction: {\n ...result.transaction,\n message: versionedMessageFromResponse(\n result.version,\n result.transaction.message,\n ),\n },\n };\n });\n\n return res;\n }\n\n /**\n * Fetch a list of Transactions and transaction statuses from the cluster\n * for a confirmed block.\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getBlock} instead.\n */\n async getConfirmedBlock(\n slot: number,\n commitment?: Finality,\n ): Promise {\n const args = this._buildArgsAtLeastConfirmed([slot], commitment);\n const unsafeRes = await this._rpcRequest('getBlock', args);\n const res = create(unsafeRes, GetConfirmedBlockRpcResult);\n\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');\n }\n\n const result = res.result;\n if (!result) {\n throw new Error('Confirmed block ' + slot + ' not found');\n }\n\n const block = {\n ...result,\n transactions: result.transactions.map(({transaction, meta}) => {\n const message = new Message(transaction.message);\n return {\n meta,\n transaction: {\n ...transaction,\n message,\n },\n };\n }),\n };\n\n return {\n ...block,\n transactions: block.transactions.map(({transaction, meta}) => {\n return {\n meta,\n transaction: Transaction.populate(\n transaction.message,\n transaction.signatures,\n ),\n };\n }),\n };\n }\n\n /**\n * Fetch confirmed blocks between two slots\n */\n async getBlocks(\n startSlot: number,\n endSlot?: number,\n commitment?: Finality,\n ): Promise> {\n const args = this._buildArgsAtLeastConfirmed(\n endSlot !== undefined ? [startSlot, endSlot] : [startSlot],\n commitment,\n );\n const unsafeRes = await this._rpcRequest('getBlocks', args);\n const res = create(unsafeRes, jsonRpcResult(array(number())));\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get blocks');\n }\n return res.result;\n }\n\n /**\n * Fetch a list of Signatures from the cluster for a block, excluding rewards\n */\n async getBlockSignatures(\n slot: number,\n commitment?: Finality,\n ): Promise {\n const args = this._buildArgsAtLeastConfirmed(\n [slot],\n commitment,\n undefined,\n {\n transactionDetails: 'signatures',\n rewards: false,\n },\n );\n const unsafeRes = await this._rpcRequest('getBlock', args);\n const res = create(unsafeRes, GetBlockSignaturesRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get block');\n }\n const result = res.result;\n if (!result) {\n throw new Error('Block ' + slot + ' not found');\n }\n return result;\n }\n\n /**\n * Fetch a list of Signatures from the cluster for a confirmed block, excluding rewards\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getBlockSignatures} instead.\n */\n async getConfirmedBlockSignatures(\n slot: number,\n commitment?: Finality,\n ): Promise {\n const args = this._buildArgsAtLeastConfirmed(\n [slot],\n commitment,\n undefined,\n {\n transactionDetails: 'signatures',\n rewards: false,\n },\n );\n const unsafeRes = await this._rpcRequest('getBlock', args);\n const res = create(unsafeRes, GetBlockSignaturesRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get confirmed block');\n }\n const result = res.result;\n if (!result) {\n throw new Error('Confirmed block ' + slot + ' not found');\n }\n return result;\n }\n\n /**\n * Fetch a transaction details for a confirmed transaction\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getTransaction} instead.\n */\n async getConfirmedTransaction(\n signature: TransactionSignature,\n commitment?: Finality,\n ): Promise {\n const args = this._buildArgsAtLeastConfirmed([signature], commitment);\n const unsafeRes = await this._rpcRequest('getTransaction', args);\n const res = create(unsafeRes, GetTransactionRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(res.error, 'failed to get transaction');\n }\n\n const result = res.result;\n if (!result) return result;\n\n const message = new Message(result.transaction.message);\n const signatures = result.transaction.signatures;\n return {\n ...result,\n transaction: Transaction.populate(message, signatures),\n };\n }\n\n /**\n * Fetch parsed transaction details for a confirmed transaction\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getParsedTransaction} instead.\n */\n async getParsedConfirmedTransaction(\n signature: TransactionSignature,\n commitment?: Finality,\n ): Promise {\n const args = this._buildArgsAtLeastConfirmed(\n [signature],\n commitment,\n 'jsonParsed',\n );\n const unsafeRes = await this._rpcRequest('getTransaction', args);\n const res = create(unsafeRes, GetParsedTransactionRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n 'failed to get confirmed transaction',\n );\n }\n return res.result;\n }\n\n /**\n * Fetch parsed transaction details for a batch of confirmed transactions\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getParsedTransactions} instead.\n */\n async getParsedConfirmedTransactions(\n signatures: TransactionSignature[],\n commitment?: Finality,\n ): Promise<(ParsedConfirmedTransaction | null)[]> {\n const batch = signatures.map(signature => {\n const args = this._buildArgsAtLeastConfirmed(\n [signature],\n commitment,\n 'jsonParsed',\n );\n return {\n methodName: 'getTransaction',\n args,\n };\n });\n\n const unsafeRes = await this._rpcBatchRequest(batch);\n const res = unsafeRes.map((unsafeRes: any) => {\n const res = create(unsafeRes, GetParsedTransactionRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n 'failed to get confirmed transactions',\n );\n }\n return res.result;\n });\n\n return res;\n }\n\n /**\n * Fetch a list of all the confirmed signatures for transactions involving an address\n * within a specified slot range. Max range allowed is 10,000 slots.\n *\n * @deprecated Deprecated since RPC v1.3. Please use {@link getConfirmedSignaturesForAddress2} instead.\n *\n * @param address queried address\n * @param startSlot start slot, inclusive\n * @param endSlot end slot, inclusive\n */\n async getConfirmedSignaturesForAddress(\n address: PublicKey,\n startSlot: number,\n endSlot: number,\n ): Promise> {\n let options: any = {};\n\n let firstAvailableBlock = await this.getFirstAvailableBlock();\n while (!('until' in options)) {\n startSlot--;\n if (startSlot <= 0 || startSlot < firstAvailableBlock) {\n break;\n }\n\n try {\n const block = await this.getConfirmedBlockSignatures(\n startSlot,\n 'finalized',\n );\n if (block.signatures.length > 0) {\n options.until =\n block.signatures[block.signatures.length - 1].toString();\n }\n } catch (err) {\n if (err instanceof Error && err.message.includes('skipped')) {\n continue;\n } else {\n throw err;\n }\n }\n }\n\n let highestConfirmedRoot = await this.getSlot('finalized');\n while (!('before' in options)) {\n endSlot++;\n if (endSlot > highestConfirmedRoot) {\n break;\n }\n\n try {\n const block = await this.getConfirmedBlockSignatures(endSlot);\n if (block.signatures.length > 0) {\n options.before =\n block.signatures[block.signatures.length - 1].toString();\n }\n } catch (err) {\n if (err instanceof Error && err.message.includes('skipped')) {\n continue;\n } else {\n throw err;\n }\n }\n }\n\n const confirmedSignatureInfo = await this.getConfirmedSignaturesForAddress2(\n address,\n options,\n );\n return confirmedSignatureInfo.map(info => info.signature);\n }\n\n /**\n * Returns confirmed signatures for transactions involving an\n * address backwards in time from the provided signature or most recent confirmed block\n *\n * @deprecated Deprecated since RPC v1.7.0. Please use {@link getSignaturesForAddress} instead.\n */\n async getConfirmedSignaturesForAddress2(\n address: PublicKey,\n options?: ConfirmedSignaturesForAddress2Options,\n commitment?: Finality,\n ): Promise> {\n const args = this._buildArgsAtLeastConfirmed(\n [address.toBase58()],\n commitment,\n undefined,\n options,\n );\n const unsafeRes = await this._rpcRequest(\n 'getConfirmedSignaturesForAddress2',\n args,\n );\n const res = create(unsafeRes, GetConfirmedSignaturesForAddress2RpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n 'failed to get confirmed signatures for address',\n );\n }\n return res.result;\n }\n\n /**\n * Returns confirmed signatures for transactions involving an\n * address backwards in time from the provided signature or most recent confirmed block\n *\n *\n * @param address queried address\n * @param options\n */\n async getSignaturesForAddress(\n address: PublicKey,\n options?: SignaturesForAddressOptions,\n commitment?: Finality,\n ): Promise> {\n const args = this._buildArgsAtLeastConfirmed(\n [address.toBase58()],\n commitment,\n undefined,\n options,\n );\n const unsafeRes = await this._rpcRequest('getSignaturesForAddress', args);\n const res = create(unsafeRes, GetSignaturesForAddressRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n 'failed to get signatures for address',\n );\n }\n return res.result;\n }\n\n async getAddressLookupTable(\n accountKey: PublicKey,\n config?: GetAccountInfoConfig,\n ): Promise> {\n const {context, value: accountInfo} = await this.getAccountInfoAndContext(\n accountKey,\n config,\n );\n\n let value = null;\n if (accountInfo !== null) {\n value = new AddressLookupTableAccount({\n key: accountKey,\n state: AddressLookupTableAccount.deserialize(accountInfo.data),\n });\n }\n\n return {\n context,\n value,\n };\n }\n\n /**\n * Fetch the contents of a Nonce account from the cluster, return with context\n */\n async getNonceAndContext(\n nonceAccount: PublicKey,\n commitmentOrConfig?: Commitment | GetNonceAndContextConfig,\n ): Promise> {\n const {context, value: accountInfo} = await this.getAccountInfoAndContext(\n nonceAccount,\n commitmentOrConfig,\n );\n\n let value = null;\n if (accountInfo !== null) {\n value = NonceAccount.fromAccountData(accountInfo.data);\n }\n\n return {\n context,\n value,\n };\n }\n\n /**\n * Fetch the contents of a Nonce account from the cluster\n */\n async getNonce(\n nonceAccount: PublicKey,\n commitmentOrConfig?: Commitment | GetNonceConfig,\n ): Promise {\n return await this.getNonceAndContext(nonceAccount, commitmentOrConfig)\n .then(x => x.value)\n .catch(e => {\n throw new Error(\n 'failed to get nonce for account ' +\n nonceAccount.toBase58() +\n ': ' +\n e,\n );\n });\n }\n\n /**\n * Request an allocation of lamports to the specified address\n *\n * ```typescript\n * import { Connection, PublicKey, LAMPORTS_PER_SOL } from \"@solana/web3.js\";\n *\n * (async () => {\n * const connection = new Connection(\"https://api.testnet.solana.com\", \"confirmed\");\n * const myAddress = new PublicKey(\"2nr1bHFT86W9tGnyvmYW4vcHKsQB3sVQfnddasz4kExM\");\n * const signature = await connection.requestAirdrop(myAddress, LAMPORTS_PER_SOL);\n * await connection.confirmTransaction(signature);\n * })();\n * ```\n */\n async requestAirdrop(\n to: PublicKey,\n lamports: number,\n ): Promise {\n const unsafeRes = await this._rpcRequest('requestAirdrop', [\n to.toBase58(),\n lamports,\n ]);\n const res = create(unsafeRes, RequestAirdropRpcResult);\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n `airdrop to ${to.toBase58()} failed`,\n );\n }\n return res.result;\n }\n\n /**\n * @internal\n */\n async _blockhashWithExpiryBlockHeight(\n disableCache: boolean,\n ): Promise {\n if (!disableCache) {\n // Wait for polling to finish\n while (this._pollingBlockhash) {\n await sleep(100);\n }\n const timeSinceFetch = Date.now() - this._blockhashInfo.lastFetch;\n const expired = timeSinceFetch >= BLOCKHASH_CACHE_TIMEOUT_MS;\n if (this._blockhashInfo.latestBlockhash !== null && !expired) {\n return this._blockhashInfo.latestBlockhash;\n }\n }\n\n return await this._pollNewBlockhash();\n }\n\n /**\n * @internal\n */\n async _pollNewBlockhash(): Promise {\n this._pollingBlockhash = true;\n try {\n const startTime = Date.now();\n const cachedLatestBlockhash = this._blockhashInfo.latestBlockhash;\n const cachedBlockhash = cachedLatestBlockhash\n ? cachedLatestBlockhash.blockhash\n : null;\n for (let i = 0; i < 50; i++) {\n const latestBlockhash = await this.getLatestBlockhash('finalized');\n\n if (cachedBlockhash !== latestBlockhash.blockhash) {\n this._blockhashInfo = {\n latestBlockhash,\n lastFetch: Date.now(),\n transactionSignatures: [],\n simulatedSignatures: [],\n };\n return latestBlockhash;\n }\n\n // Sleep for approximately half a slot\n await sleep(MS_PER_SLOT / 2);\n }\n\n throw new Error(\n `Unable to obtain a new blockhash after ${Date.now() - startTime}ms`,\n );\n } finally {\n this._pollingBlockhash = false;\n }\n }\n\n /**\n * get the stake minimum delegation\n */\n async getStakeMinimumDelegation(\n config?: GetStakeMinimumDelegationConfig,\n ): Promise> {\n const {commitment, config: configArg} = extractCommitmentFromConfig(config);\n const args = this._buildArgs([], commitment, 'base64', configArg);\n const unsafeRes = await this._rpcRequest('getStakeMinimumDelegation', args);\n const res = create(unsafeRes, jsonRpcResultAndContext(number()));\n if ('error' in res) {\n throw new SolanaJSONRPCError(\n res.error,\n `failed to get stake minimum delegation`,\n );\n }\n return res.result;\n }\n\n /**\n * Simulate a transaction\n *\n * @deprecated Instead, call {@link simulateTransaction} with {@link\n * VersionedTransaction} and {@link SimulateTransactionConfig} parameters\n */\n simulateTransaction(\n transactionOrMessage: Transaction | Message,\n signers?: Array,\n includeAccounts?: boolean | Array,\n ): Promise>;\n\n /**\n * Simulate a transaction\n */\n // eslint-disable-next-line no-dupe-class-members\n simulateTransaction(\n transaction: VersionedTransaction,\n config?: SimulateTransactionConfig,\n ): Promise>;\n\n /**\n * Simulate a transaction\n */\n // eslint-disable-next-line no-dupe-class-members\n async simulateTransaction(\n transactionOrMessage: VersionedTransaction | Transaction | Message,\n configOrSigners?: SimulateTransactionConfig | Array,\n includeAccounts?: boolean | Array,\n ): Promise> {\n if ('message' in transactionOrMessage) {\n const versionedTx = transactionOrMessage;\n const wireTransaction = versionedTx.serialize();\n const encodedTransaction =\n Buffer.from(wireTransaction).toString('base64');\n if (Array.isArray(configOrSigners) || includeAccounts !== undefined) {\n throw new Error('Invalid arguments');\n }\n\n const config: any = configOrSigners || {};\n config.encoding = 'base64';\n if (!('commitment' in config)) {\n config.commitment = this.commitment;\n }\n\n if (\n configOrSigners &&\n typeof configOrSigners === 'object' &&\n 'innerInstructions' in configOrSigners\n ) {\n config.innerInstructions = configOrSigners.innerInstructions;\n }\n\n const args = [encodedTransaction, config];\n const unsafeRes = await this._rpcRequest('simulateTransaction', args);\n const res = create(unsafeRes, SimulatedTransactionResponseStruct);\n if ('error' in res) {\n throw new Error('failed to simulate transaction: ' + res.error.message);\n }\n return res.result;\n }\n\n let transaction;\n if (transactionOrMessage instanceof Transaction) {\n let originalTx: Transaction = transactionOrMessage;\n transaction = new Transaction();\n transaction.feePayer = originalTx.feePayer;\n transaction.instructions = transactionOrMessage.instructions;\n transaction.nonceInfo = originalTx.nonceInfo;\n transaction.signatures = originalTx.signatures;\n } else {\n transaction = Transaction.populate(transactionOrMessage);\n // HACK: this function relies on mutating the populated transaction\n transaction._message = transaction._json = undefined;\n }\n\n if (configOrSigners !== undefined && !Array.isArray(configOrSigners)) {\n throw new Error('Invalid arguments');\n }\n\n const signers = configOrSigners;\n if (transaction.nonceInfo && signers) {\n transaction.sign(...signers);\n } else {\n let disableCache = this._disableBlockhashCaching;\n for (;;) {\n const latestBlockhash =\n await this._blockhashWithExpiryBlockHeight(disableCache);\n transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;\n transaction.recentBlockhash = latestBlockhash.blockhash;\n\n if (!signers) break;\n\n transaction.sign(...signers);\n if (!transaction.signature) {\n throw new Error('!signature'); // should never happen\n }\n\n const signature = transaction.signature.toString('base64');\n if (\n !this._blockhashInfo.simulatedSignatures.includes(signature) &&\n !this._blockhashInfo.transactionSignatures.includes(signature)\n ) {\n // The signature of this transaction has not been seen before with the\n // current recentBlockhash, all done. Let's break\n this._blockhashInfo.simulatedSignatures.push(signature);\n break;\n } else {\n // This transaction would be treated as duplicate (its derived signature\n // matched to one of already recorded signatures).\n // So, we must fetch a new blockhash for a different signature by disabling\n // our cache not to wait for the cache expiration (BLOCKHASH_CACHE_TIMEOUT_MS).\n disableCache = true;\n }\n }\n }\n\n const message = transaction._compile();\n const signData = message.serialize();\n const wireTransaction = transaction._serialize(signData);\n const encodedTransaction = wireTransaction.toString('base64');\n const config: any = {\n encoding: 'base64',\n commitment: this.commitment,\n };\n\n if (includeAccounts) {\n const addresses = (\n Array.isArray(includeAccounts)\n ? includeAccounts\n : message.nonProgramIds()\n ).map(key => key.toBase58());\n\n config['accounts'] = {\n encoding: 'base64',\n addresses,\n };\n }\n\n if (signers) {\n config.sigVerify = true;\n }\n\n if (\n configOrSigners &&\n typeof configOrSigners === 'object' &&\n 'innerInstructions' in configOrSigners\n ) {\n config.innerInstructions = configOrSigners.innerInstructions;\n }\n\n const args = [encodedTransaction, config];\n const unsafeRes = await this._rpcRequest('simulateTransaction', args);\n const res = create(unsafeRes, SimulatedTransactionResponseStruct);\n if ('error' in res) {\n let logs;\n if ('data' in res.error) {\n logs = res.error.data.logs;\n if (logs && Array.isArray(logs)) {\n const traceIndent = '\\n ';\n const logTrace = traceIndent + logs.join(traceIndent);\n console.error(res.error.message, logTrace);\n }\n }\n\n throw new SendTransactionError({\n action: 'simulate',\n signature: '',\n transactionMessage: res.error.message,\n logs: logs,\n });\n }\n return res.result;\n }\n\n /**\n * Sign and send a transaction\n *\n * @deprecated Instead, call {@link sendTransaction} with a {@link\n * VersionedTransaction}\n */\n sendTransaction(\n transaction: Transaction,\n signers: Array,\n options?: SendOptions,\n ): Promise;\n\n /**\n * Send a signed transaction\n */\n // eslint-disable-next-line no-dupe-class-members\n sendTransaction(\n transaction: VersionedTransaction,\n options?: SendOptions,\n ): Promise;\n\n /**\n * Sign and send a transaction\n */\n // eslint-disable-next-line no-dupe-class-members\n async sendTransaction(\n transaction: VersionedTransaction | Transaction,\n signersOrOptions?: Array | SendOptions,\n options?: SendOptions,\n ): Promise {\n if ('version' in transaction) {\n if (signersOrOptions && Array.isArray(signersOrOptions)) {\n throw new Error('Invalid arguments');\n }\n\n const wireTransaction = transaction.serialize();\n return await this.sendRawTransaction(wireTransaction, signersOrOptions);\n }\n\n if (signersOrOptions === undefined || !Array.isArray(signersOrOptions)) {\n throw new Error('Invalid arguments');\n }\n\n const signers = signersOrOptions;\n if (transaction.nonceInfo) {\n transaction.sign(...signers);\n } else {\n let disableCache = this._disableBlockhashCaching;\n for (;;) {\n const latestBlockhash =\n await this._blockhashWithExpiryBlockHeight(disableCache);\n transaction.lastValidBlockHeight = latestBlockhash.lastValidBlockHeight;\n transaction.recentBlockhash = latestBlockhash.blockhash;\n transaction.sign(...signers);\n if (!transaction.signature) {\n throw new Error('!signature'); // should never happen\n }\n\n const signature = transaction.signature.toString('base64');\n if (!this._blockhashInfo.transactionSignatures.includes(signature)) {\n // The signature of this transaction has not been seen before with the\n // current recentBlockhash, all done. Let's break\n this._blockhashInfo.transactionSignatures.push(signature);\n break;\n } else {\n // This transaction would be treated as duplicate (its derived signature\n // matched to one of already recorded signatures).\n // So, we must fetch a new blockhash for a different signature by disabling\n // our cache not to wait for the cache expiration (BLOCKHASH_CACHE_TIMEOUT_MS).\n disableCache = true;\n }\n }\n }\n\n const wireTransaction = transaction.serialize();\n return await this.sendRawTransaction(wireTransaction, options);\n }\n\n /**\n * Send a transaction that has already been signed and serialized into the\n * wire format\n */\n async sendRawTransaction(\n rawTransaction: Buffer | Uint8Array | Array,\n options?: SendOptions,\n ): Promise {\n const encodedTransaction = toBuffer(rawTransaction).toString('base64');\n const result = await this.sendEncodedTransaction(\n encodedTransaction,\n options,\n );\n return result;\n }\n\n /**\n * Send a transaction that has already been signed, serialized into the\n * wire format, and encoded as a base64 string\n */\n async sendEncodedTransaction(\n encodedTransaction: string,\n options?: SendOptions,\n ): Promise {\n const config: any = {encoding: 'base64'};\n const skipPreflight = options && options.skipPreflight;\n const preflightCommitment =\n skipPreflight === true\n ? 'processed' // FIXME Remove when https://github.com/anza-xyz/agave/pull/483 is deployed.\n : (options && options.preflightCommitment) || this.commitment;\n\n if (options && options.maxRetries != null) {\n config.maxRetries = options.maxRetries;\n }\n if (options && options.minContextSlot != null) {\n config.minContextSlot = options.minContextSlot;\n }\n if (skipPreflight) {\n config.skipPreflight = skipPreflight;\n }\n if (preflightCommitment) {\n config.preflightCommitment = preflightCommitment;\n }\n\n const args = [encodedTransaction, config];\n const unsafeRes = await this._rpcRequest('sendTransaction', args);\n const res = create(unsafeRes, SendTransactionRpcResult);\n if ('error' in res) {\n let logs = undefined;\n if ('data' in res.error) {\n logs = res.error.data.logs;\n }\n\n throw new SendTransactionError({\n action: skipPreflight ? 'send' : 'simulate',\n signature: '',\n transactionMessage: res.error.message,\n logs: logs,\n });\n }\n return res.result;\n }\n\n /**\n * @internal\n */\n _wsOnOpen() {\n this._rpcWebSocketConnected = true;\n this._rpcWebSocketHeartbeat = setInterval(() => {\n // Ping server every 5s to prevent idle timeouts\n (async () => {\n try {\n await this._rpcWebSocket.notify('ping');\n // eslint-disable-next-line no-empty\n } catch {}\n })();\n }, 5000);\n this._updateSubscriptions();\n }\n\n /**\n * @internal\n */\n _wsOnError(err: Error) {\n this._rpcWebSocketConnected = false;\n console.error('ws error:', err.message);\n }\n\n /**\n * @internal\n */\n _wsOnClose(code: number) {\n this._rpcWebSocketConnected = false;\n this._rpcWebSocketGeneration =\n (this._rpcWebSocketGeneration + 1) % Number.MAX_SAFE_INTEGER;\n if (this._rpcWebSocketIdleTimeout) {\n clearTimeout(this._rpcWebSocketIdleTimeout);\n this._rpcWebSocketIdleTimeout = null;\n }\n if (this._rpcWebSocketHeartbeat) {\n clearInterval(this._rpcWebSocketHeartbeat);\n this._rpcWebSocketHeartbeat = null;\n }\n\n if (code === 1000) {\n // explicit close, check if any subscriptions have been made since close\n this._updateSubscriptions();\n return;\n }\n\n // implicit close, prepare subscriptions for auto-reconnect\n this._subscriptionCallbacksByServerSubscriptionId = {};\n Object.entries(\n this._subscriptionsByHash as Record,\n ).forEach(([hash, subscription]) => {\n this._setSubscription(hash, {\n ...subscription,\n state: 'pending',\n });\n });\n }\n\n /**\n * @internal\n */\n private _setSubscription(\n hash: SubscriptionConfigHash,\n nextSubscription: Subscription,\n ) {\n const prevState = this._subscriptionsByHash[hash]?.state;\n this._subscriptionsByHash[hash] = nextSubscription;\n if (prevState !== nextSubscription.state) {\n const stateChangeCallbacks =\n this._subscriptionStateChangeCallbacksByHash[hash];\n if (stateChangeCallbacks) {\n stateChangeCallbacks.forEach(cb => {\n try {\n cb(nextSubscription.state);\n // eslint-disable-next-line no-empty\n } catch {}\n });\n }\n }\n }\n\n /**\n * @internal\n */\n private _onSubscriptionStateChange(\n clientSubscriptionId: ClientSubscriptionId,\n callback: SubscriptionStateChangeCallback,\n ): SubscriptionStateChangeDisposeFn {\n const hash =\n this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];\n if (hash == null) {\n return () => {};\n }\n const stateChangeCallbacks = (this._subscriptionStateChangeCallbacksByHash[\n hash\n ] ||= new Set());\n stateChangeCallbacks.add(callback);\n return () => {\n stateChangeCallbacks.delete(callback);\n if (stateChangeCallbacks.size === 0) {\n delete this._subscriptionStateChangeCallbacksByHash[hash];\n }\n };\n }\n\n /**\n * @internal\n */\n async _updateSubscriptions() {\n if (Object.keys(this._subscriptionsByHash).length === 0) {\n if (this._rpcWebSocketConnected) {\n this._rpcWebSocketConnected = false;\n this._rpcWebSocketIdleTimeout = setTimeout(() => {\n this._rpcWebSocketIdleTimeout = null;\n try {\n this._rpcWebSocket.close();\n } catch (err) {\n // swallow error if socket has already been closed.\n if (err instanceof Error) {\n console.log(\n `Error when closing socket connection: ${err.message}`,\n );\n }\n }\n }, 500);\n }\n return;\n }\n\n if (this._rpcWebSocketIdleTimeout !== null) {\n clearTimeout(this._rpcWebSocketIdleTimeout);\n this._rpcWebSocketIdleTimeout = null;\n this._rpcWebSocketConnected = true;\n }\n\n if (!this._rpcWebSocketConnected) {\n this._rpcWebSocket.connect();\n return;\n }\n\n const activeWebSocketGeneration = this._rpcWebSocketGeneration;\n const isCurrentConnectionStillActive = () => {\n return activeWebSocketGeneration === this._rpcWebSocketGeneration;\n };\n\n await Promise.all(\n // Don't be tempted to change this to `Object.entries`. We call\n // `_updateSubscriptions` recursively when processing the state,\n // so it's important that we look up the *current* version of\n // each subscription, every time we process a hash.\n Object.keys(this._subscriptionsByHash).map(async hash => {\n const subscription = this._subscriptionsByHash[hash];\n if (subscription === undefined) {\n // This entry has since been deleted. Skip.\n return;\n }\n switch (subscription.state) {\n case 'pending':\n case 'unsubscribed':\n if (subscription.callbacks.size === 0) {\n /**\n * You can end up here when:\n *\n * - a subscription has recently unsubscribed\n * without having new callbacks added to it\n * while the unsubscribe was in flight, or\n * - when a pending subscription has its\n * listeners removed before a request was\n * sent to the server.\n *\n * Being that nobody is interested in this\n * subscription any longer, delete it.\n */\n delete this._subscriptionsByHash[hash];\n if (subscription.state === 'unsubscribed') {\n delete this._subscriptionCallbacksByServerSubscriptionId[\n subscription.serverSubscriptionId\n ];\n }\n await this._updateSubscriptions();\n return;\n }\n await (async () => {\n const {args, method} = subscription;\n try {\n this._setSubscription(hash, {\n ...subscription,\n state: 'subscribing',\n });\n const serverSubscriptionId: ServerSubscriptionId =\n (await this._rpcWebSocket.call(method, args)) as number;\n this._setSubscription(hash, {\n ...subscription,\n serverSubscriptionId,\n state: 'subscribed',\n });\n this._subscriptionCallbacksByServerSubscriptionId[\n serverSubscriptionId\n ] = subscription.callbacks;\n await this._updateSubscriptions();\n } catch (e) {\n console.error(\n `Received ${e instanceof Error ? '' : 'JSON-RPC '}error calling \\`${method}\\``,\n {\n args,\n error: e,\n },\n );\n if (!isCurrentConnectionStillActive()) {\n return;\n }\n // TODO: Maybe add an 'errored' state or a retry limit?\n this._setSubscription(hash, {\n ...subscription,\n state: 'pending',\n });\n await this._updateSubscriptions();\n }\n })();\n break;\n case 'subscribed':\n if (subscription.callbacks.size === 0) {\n // By the time we successfully set up a subscription\n // with the server, the client stopped caring about it.\n // Tear it down now.\n await (async () => {\n const {serverSubscriptionId, unsubscribeMethod} = subscription;\n if (\n this._subscriptionsAutoDisposedByRpc.has(serverSubscriptionId)\n ) {\n /**\n * Special case.\n * If we're dealing with a subscription that has been auto-\n * disposed by the RPC, then we can skip the RPC call to\n * tear down the subscription here.\n *\n * NOTE: There is a proposal to eliminate this special case, here:\n * https://github.com/solana-labs/solana/issues/18892\n */\n this._subscriptionsAutoDisposedByRpc.delete(\n serverSubscriptionId,\n );\n } else {\n this._setSubscription(hash, {\n ...subscription,\n state: 'unsubscribing',\n });\n this._setSubscription(hash, {\n ...subscription,\n state: 'unsubscribing',\n });\n try {\n await this._rpcWebSocket.call(unsubscribeMethod, [\n serverSubscriptionId,\n ]);\n } catch (e) {\n if (e instanceof Error) {\n console.error(`${unsubscribeMethod} error:`, e.message);\n }\n if (!isCurrentConnectionStillActive()) {\n return;\n }\n // TODO: Maybe add an 'errored' state or a retry limit?\n this._setSubscription(hash, {\n ...subscription,\n state: 'subscribed',\n });\n await this._updateSubscriptions();\n return;\n }\n }\n this._setSubscription(hash, {\n ...subscription,\n state: 'unsubscribed',\n });\n await this._updateSubscriptions();\n })();\n }\n break;\n case 'subscribing':\n case 'unsubscribing':\n break;\n }\n }),\n );\n }\n\n /**\n * @internal\n */\n private _handleServerNotification<\n TCallback extends SubscriptionConfig['callback'],\n >(\n serverSubscriptionId: ServerSubscriptionId,\n callbackArgs: Parameters,\n ): void {\n const callbacks =\n this._subscriptionCallbacksByServerSubscriptionId[serverSubscriptionId];\n if (callbacks === undefined) {\n return;\n }\n callbacks.forEach(cb => {\n try {\n cb(\n // I failed to find a way to convince TypeScript that `cb` is of type\n // `TCallback` which is certainly compatible with `Parameters`.\n // See https://github.com/microsoft/TypeScript/issues/47615\n // @ts-ignore\n ...callbackArgs,\n );\n } catch (e) {\n console.error(e);\n }\n });\n }\n\n /**\n * @internal\n */\n _wsOnAccountNotification(notification: object) {\n const {result, subscription} = create(\n notification,\n AccountNotificationResult,\n );\n this._handleServerNotification(subscription, [\n result.value,\n result.context,\n ]);\n }\n\n /**\n * @internal\n */\n private _makeSubscription(\n subscriptionConfig: SubscriptionConfig,\n /**\n * When preparing `args` for a call to `_makeSubscription`, be sure\n * to carefully apply a default `commitment` property, if necessary.\n *\n * - If the user supplied a `commitment` use that.\n * - Otherwise, if the `Connection::commitment` is set, use that.\n * - Otherwise, set it to the RPC server default: `finalized`.\n *\n * This is extremely important to ensure that these two fundamentally\n * identical subscriptions produce the same identifying hash:\n *\n * - A subscription made without specifying a commitment.\n * - A subscription made where the commitment specified is the same\n * as the default applied to the subscription above.\n *\n * Example; these two subscriptions must produce the same hash:\n *\n * - An `accountSubscribe` subscription for `'PUBKEY'`\n * - An `accountSubscribe` subscription for `'PUBKEY'` with commitment\n * `'finalized'`.\n *\n * See the 'making a subscription with defaulted params omitted' test\n * in `connection-subscriptions.ts` for more.\n */\n args: IWSRequestParams,\n ): ClientSubscriptionId {\n const clientSubscriptionId = this._nextClientSubscriptionId++;\n const hash = fastStableStringify([subscriptionConfig.method, args]);\n const existingSubscription = this._subscriptionsByHash[hash];\n if (existingSubscription === undefined) {\n this._subscriptionsByHash[hash] = {\n ...subscriptionConfig,\n args,\n callbacks: new Set([subscriptionConfig.callback]),\n state: 'pending',\n };\n } else {\n existingSubscription.callbacks.add(subscriptionConfig.callback);\n }\n this._subscriptionHashByClientSubscriptionId[clientSubscriptionId] = hash;\n this._subscriptionDisposeFunctionsByClientSubscriptionId[\n clientSubscriptionId\n ] = async () => {\n delete this._subscriptionDisposeFunctionsByClientSubscriptionId[\n clientSubscriptionId\n ];\n delete this._subscriptionHashByClientSubscriptionId[clientSubscriptionId];\n const subscription = this._subscriptionsByHash[hash];\n assert(\n subscription !== undefined,\n `Could not find a \\`Subscription\\` when tearing down client subscription #${clientSubscriptionId}`,\n );\n subscription.callbacks.delete(subscriptionConfig.callback);\n await this._updateSubscriptions();\n };\n this._updateSubscriptions();\n return clientSubscriptionId;\n }\n\n /**\n * Register a callback to be invoked whenever the specified account changes\n *\n * @param publicKey Public key of the account to monitor\n * @param callback Function to invoke whenever the account is changed\n * @param config\n * @return subscription id\n */\n onAccountChange(\n publicKey: PublicKey,\n callback: AccountChangeCallback,\n config?: AccountSubscriptionConfig,\n ): ClientSubscriptionId;\n /** @deprecated Instead, pass in an {@link AccountSubscriptionConfig} */\n // eslint-disable-next-line no-dupe-class-members\n onAccountChange(\n publicKey: PublicKey,\n callback: AccountChangeCallback,\n commitment?: Commitment,\n ): ClientSubscriptionId;\n // eslint-disable-next-line no-dupe-class-members\n onAccountChange(\n publicKey: PublicKey,\n callback: AccountChangeCallback,\n commitmentOrConfig?: Commitment | AccountSubscriptionConfig,\n ): ClientSubscriptionId {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs(\n [publicKey.toBase58()],\n commitment || this._commitment || 'finalized', // Apply connection/server default.\n 'base64',\n config,\n );\n return this._makeSubscription(\n {\n callback,\n method: 'accountSubscribe',\n unsubscribeMethod: 'accountUnsubscribe',\n },\n args,\n );\n }\n\n /**\n * Deregister an account notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */\n async removeAccountChangeListener(\n clientSubscriptionId: ClientSubscriptionId,\n ): Promise {\n await this._unsubscribeClientSubscription(\n clientSubscriptionId,\n 'account change',\n );\n }\n\n /**\n * @internal\n */\n _wsOnProgramAccountNotification(notification: Object) {\n const {result, subscription} = create(\n notification,\n ProgramAccountNotificationResult,\n );\n this._handleServerNotification(subscription, [\n {\n accountId: result.value.pubkey,\n accountInfo: result.value.account,\n },\n result.context,\n ]);\n }\n\n /**\n * Register a callback to be invoked whenever accounts owned by the\n * specified program change\n *\n * @param programId Public key of the program to monitor\n * @param callback Function to invoke whenever the account is changed\n * @param config\n * @return subscription id\n */\n onProgramAccountChange(\n programId: PublicKey,\n callback: ProgramAccountChangeCallback,\n config?: ProgramAccountSubscriptionConfig,\n ): ClientSubscriptionId;\n /** @deprecated Instead, pass in a {@link ProgramAccountSubscriptionConfig} */\n // eslint-disable-next-line no-dupe-class-members\n onProgramAccountChange(\n programId: PublicKey,\n callback: ProgramAccountChangeCallback,\n commitment?: Commitment,\n filters?: GetProgramAccountsFilter[],\n ): ClientSubscriptionId;\n // eslint-disable-next-line no-dupe-class-members\n onProgramAccountChange(\n programId: PublicKey,\n callback: ProgramAccountChangeCallback,\n commitmentOrConfig?: Commitment | ProgramAccountSubscriptionConfig,\n maybeFilters?: GetProgramAccountsFilter[],\n ): ClientSubscriptionId {\n const {commitment, config} =\n extractCommitmentFromConfig(commitmentOrConfig);\n const args = this._buildArgs(\n [programId.toBase58()],\n commitment || this._commitment || 'finalized', // Apply connection/server default.\n 'base64' /* encoding */,\n config\n ? config\n : maybeFilters\n ? {filters: applyDefaultMemcmpEncodingToFilters(maybeFilters)}\n : undefined /* extra */,\n );\n return this._makeSubscription(\n {\n callback,\n method: 'programSubscribe',\n unsubscribeMethod: 'programUnsubscribe',\n },\n args,\n );\n }\n\n /**\n * Deregister an account notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */\n async removeProgramAccountChangeListener(\n clientSubscriptionId: ClientSubscriptionId,\n ): Promise {\n await this._unsubscribeClientSubscription(\n clientSubscriptionId,\n 'program account change',\n );\n }\n\n /**\n * Registers a callback to be invoked whenever logs are emitted.\n */\n onLogs(\n filter: LogsFilter,\n callback: LogsCallback,\n commitment?: Commitment,\n ): ClientSubscriptionId {\n const args = this._buildArgs(\n [typeof filter === 'object' ? {mentions: [filter.toString()]} : filter],\n commitment || this._commitment || 'finalized', // Apply connection/server default.\n );\n return this._makeSubscription(\n {\n callback,\n method: 'logsSubscribe',\n unsubscribeMethod: 'logsUnsubscribe',\n },\n args,\n );\n }\n\n /**\n * Deregister a logs callback.\n *\n * @param clientSubscriptionId client subscription id to deregister.\n */\n async removeOnLogsListener(\n clientSubscriptionId: ClientSubscriptionId,\n ): Promise {\n await this._unsubscribeClientSubscription(clientSubscriptionId, 'logs');\n }\n\n /**\n * @internal\n */\n _wsOnLogsNotification(notification: Object) {\n const {result, subscription} = create(notification, LogsNotificationResult);\n this._handleServerNotification(subscription, [\n result.value,\n result.context,\n ]);\n }\n\n /**\n * @internal\n */\n _wsOnSlotNotification(notification: Object) {\n const {result, subscription} = create(notification, SlotNotificationResult);\n this._handleServerNotification(subscription, [result]);\n }\n\n /**\n * Register a callback to be invoked upon slot changes\n *\n * @param callback Function to invoke whenever the slot changes\n * @return subscription id\n */\n onSlotChange(callback: SlotChangeCallback): ClientSubscriptionId {\n return this._makeSubscription(\n {\n callback,\n method: 'slotSubscribe',\n unsubscribeMethod: 'slotUnsubscribe',\n },\n [] /* args */,\n );\n }\n\n /**\n * Deregister a slot notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */\n async removeSlotChangeListener(\n clientSubscriptionId: ClientSubscriptionId,\n ): Promise {\n await this._unsubscribeClientSubscription(\n clientSubscriptionId,\n 'slot change',\n );\n }\n\n /**\n * @internal\n */\n _wsOnSlotUpdatesNotification(notification: Object) {\n const {result, subscription} = create(\n notification,\n SlotUpdateNotificationResult,\n );\n this._handleServerNotification(subscription, [result]);\n }\n\n /**\n * Register a callback to be invoked upon slot updates. {@link SlotUpdate}'s\n * may be useful to track live progress of a cluster.\n *\n * @param callback Function to invoke whenever the slot updates\n * @return subscription id\n */\n onSlotUpdate(callback: SlotUpdateCallback): ClientSubscriptionId {\n return this._makeSubscription(\n {\n callback,\n method: 'slotsUpdatesSubscribe',\n unsubscribeMethod: 'slotsUpdatesUnsubscribe',\n },\n [] /* args */,\n );\n }\n\n /**\n * Deregister a slot update notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */\n async removeSlotUpdateListener(\n clientSubscriptionId: ClientSubscriptionId,\n ): Promise {\n await this._unsubscribeClientSubscription(\n clientSubscriptionId,\n 'slot update',\n );\n }\n\n /**\n * @internal\n */\n\n private async _unsubscribeClientSubscription(\n clientSubscriptionId: ClientSubscriptionId,\n subscriptionName: string,\n ) {\n const dispose =\n this._subscriptionDisposeFunctionsByClientSubscriptionId[\n clientSubscriptionId\n ];\n if (dispose) {\n await dispose();\n } else {\n console.warn(\n 'Ignored unsubscribe request because an active subscription with id ' +\n `\\`${clientSubscriptionId}\\` for '${subscriptionName}' events ` +\n 'could not be found.',\n );\n }\n }\n\n _buildArgs(\n args: Array,\n override?: Commitment,\n encoding?: 'jsonParsed' | 'base64',\n extra?: any,\n ): Array {\n const commitment = override || this._commitment;\n if (commitment || encoding || extra) {\n let options: any = {};\n if (encoding) {\n options.encoding = encoding;\n }\n if (commitment) {\n options.commitment = commitment;\n }\n if (extra) {\n options = Object.assign(options, extra);\n }\n args.push(options);\n }\n return args;\n }\n\n /**\n * @internal\n */\n _buildArgsAtLeastConfirmed(\n args: Array,\n override?: Finality,\n encoding?: 'jsonParsed' | 'base64',\n extra?: any,\n ): Array {\n const commitment = override || this._commitment;\n if (commitment && !['confirmed', 'finalized'].includes(commitment)) {\n throw new Error(\n 'Using Connection with default commitment: `' +\n this._commitment +\n '`, but method requires at least `confirmed`',\n );\n }\n return this._buildArgs(args, override, encoding, extra);\n }\n\n /**\n * @internal\n */\n _wsOnSignatureNotification(notification: Object) {\n const {result, subscription} = create(\n notification,\n SignatureNotificationResult,\n );\n if (result.value !== 'receivedSignature') {\n /**\n * Special case.\n * After a signature is processed, RPCs automatically dispose of the\n * subscription on the server side. We need to track which of these\n * subscriptions have been disposed in such a way, so that we know\n * whether the client is dealing with a not-yet-processed signature\n * (in which case we must tear down the server subscription) or an\n * already-processed signature (in which case the client can simply\n * clear out the subscription locally without telling the server).\n *\n * NOTE: There is a proposal to eliminate this special case, here:\n * https://github.com/solana-labs/solana/issues/18892\n */\n this._subscriptionsAutoDisposedByRpc.add(subscription);\n }\n this._handleServerNotification(\n subscription,\n result.value === 'receivedSignature'\n ? [{type: 'received'}, result.context]\n : [{type: 'status', result: result.value}, result.context],\n );\n }\n\n /**\n * Register a callback to be invoked upon signature updates\n *\n * @param signature Transaction signature string in base 58\n * @param callback Function to invoke on signature notifications\n * @param commitment Specify the commitment level signature must reach before notification\n * @return subscription id\n */\n onSignature(\n signature: TransactionSignature,\n callback: SignatureResultCallback,\n commitment?: Commitment,\n ): ClientSubscriptionId {\n const args = this._buildArgs(\n [signature],\n commitment || this._commitment || 'finalized', // Apply connection/server default.\n );\n const clientSubscriptionId = this._makeSubscription(\n {\n callback: (notification, context) => {\n if (notification.type === 'status') {\n callback(notification.result, context);\n // Signatures subscriptions are auto-removed by the RPC service\n // so no need to explicitly send an unsubscribe message.\n try {\n this.removeSignatureListener(clientSubscriptionId);\n // eslint-disable-next-line no-empty\n } catch (_err) {\n // Already removed.\n }\n }\n },\n method: 'signatureSubscribe',\n unsubscribeMethod: 'signatureUnsubscribe',\n },\n args,\n );\n return clientSubscriptionId;\n }\n\n /**\n * Register a callback to be invoked when a transaction is\n * received and/or processed.\n *\n * @param signature Transaction signature string in base 58\n * @param callback Function to invoke on signature notifications\n * @param options Enable received notifications and set the commitment\n * level that signature must reach before notification\n * @return subscription id\n */\n onSignatureWithOptions(\n signature: TransactionSignature,\n callback: SignatureSubscriptionCallback,\n options?: SignatureSubscriptionOptions,\n ): ClientSubscriptionId {\n const {commitment, ...extra} = {\n ...options,\n commitment:\n (options && options.commitment) || this._commitment || 'finalized', // Apply connection/server default.\n };\n const args = this._buildArgs(\n [signature],\n commitment,\n undefined /* encoding */,\n extra,\n );\n const clientSubscriptionId = this._makeSubscription(\n {\n callback: (notification, context) => {\n callback(notification, context);\n // Signatures subscriptions are auto-removed by the RPC service\n // so no need to explicitly send an unsubscribe message.\n try {\n this.removeSignatureListener(clientSubscriptionId);\n // eslint-disable-next-line no-empty\n } catch (_err) {\n // Already removed.\n }\n },\n method: 'signatureSubscribe',\n unsubscribeMethod: 'signatureUnsubscribe',\n },\n args,\n );\n return clientSubscriptionId;\n }\n\n /**\n * Deregister a signature notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */\n async removeSignatureListener(\n clientSubscriptionId: ClientSubscriptionId,\n ): Promise {\n await this._unsubscribeClientSubscription(\n clientSubscriptionId,\n 'signature result',\n );\n }\n\n /**\n * @internal\n */\n _wsOnRootNotification(notification: Object) {\n const {result, subscription} = create(notification, RootNotificationResult);\n this._handleServerNotification(subscription, [result]);\n }\n\n /**\n * Register a callback to be invoked upon root changes\n *\n * @param callback Function to invoke whenever the root changes\n * @return subscription id\n */\n onRootChange(callback: RootChangeCallback): ClientSubscriptionId {\n return this._makeSubscription(\n {\n callback,\n method: 'rootSubscribe',\n unsubscribeMethod: 'rootUnsubscribe',\n },\n [] /* args */,\n );\n }\n\n /**\n * Deregister a root notification callback\n *\n * @param clientSubscriptionId client subscription id to deregister\n */\n async removeRootChangeListener(\n clientSubscriptionId: ClientSubscriptionId,\n ): Promise {\n await this._unsubscribeClientSubscription(\n clientSubscriptionId,\n 'root change',\n );\n }\n}\n","import {generateKeypair, getPublicKey, Ed25519Keypair} from './utils/ed25519';\nimport {PublicKey} from './publickey';\n\n/**\n * Keypair signer interface\n */\nexport interface Signer {\n publicKey: PublicKey;\n secretKey: Uint8Array;\n}\n\n/**\n * An account keypair used for signing transactions.\n */\nexport class Keypair {\n private _keypair: Ed25519Keypair;\n\n /**\n * Create a new keypair instance.\n * Generate random keypair if no {@link Ed25519Keypair} is provided.\n *\n * @param {Ed25519Keypair} keypair ed25519 keypair\n */\n constructor(keypair?: Ed25519Keypair) {\n this._keypair = keypair ?? generateKeypair();\n }\n\n /**\n * Generate a new random keypair\n *\n * @returns {Keypair} Keypair\n */\n static generate(): Keypair {\n return new Keypair(generateKeypair());\n }\n\n /**\n * Create a keypair from a raw secret key byte array.\n *\n * This method should only be used to recreate a keypair from a previously\n * generated secret key. Generating keypairs from a random seed should be done\n * with the {@link Keypair.fromSeed} method.\n *\n * @throws error if the provided secret key is invalid and validation is not skipped.\n *\n * @param secretKey secret key byte array\n * @param options skip secret key validation\n *\n * @returns {Keypair} Keypair\n */\n static fromSecretKey(\n secretKey: Uint8Array,\n options?: {skipValidation?: boolean},\n ): Keypair {\n if (secretKey.byteLength !== 64) {\n throw new Error('bad secret key size');\n }\n const publicKey = secretKey.slice(32, 64);\n if (!options || !options.skipValidation) {\n const privateScalar = secretKey.slice(0, 32);\n const computedPublicKey = getPublicKey(privateScalar);\n for (let ii = 0; ii < 32; ii++) {\n if (publicKey[ii] !== computedPublicKey[ii]) {\n throw new Error('provided secretKey is invalid');\n }\n }\n }\n return new Keypair({publicKey, secretKey});\n }\n\n /**\n * Generate a keypair from a 32 byte seed.\n *\n * @param seed seed byte array\n *\n * @returns {Keypair} Keypair\n */\n static fromSeed(seed: Uint8Array): Keypair {\n const publicKey = getPublicKey(seed);\n const secretKey = new Uint8Array(64);\n secretKey.set(seed);\n secretKey.set(publicKey, 32);\n return new Keypair({publicKey, secretKey});\n }\n\n /**\n * The public key for this keypair\n *\n * @returns {PublicKey} PublicKey\n */\n get publicKey(): PublicKey {\n return new PublicKey(this._keypair.publicKey);\n }\n\n /**\n * The raw secret key for this keypair\n * @returns {Uint8Array} Secret key in an array of Uint8 bytes\n */\n get secretKey(): Uint8Array {\n return new Uint8Array(this._keypair.secretKey);\n }\n}\n","import {toBufferLE} from 'bigint-buffer';\nimport * as BufferLayout from '@solana/buffer-layout';\n\nimport * as Layout from '../../layout';\nimport {PublicKey} from '../../publickey';\nimport * as bigintLayout from '../../utils/bigint';\nimport {SystemProgram} from '../system';\nimport {TransactionInstruction} from '../../transaction';\nimport {decodeData, encodeData, IInstructionInputData} from '../../instruction';\n\nexport * from './state';\n\nexport type CreateLookupTableParams = {\n /** Account used to derive and control the new address lookup table. */\n authority: PublicKey;\n /** Account that will fund the new address lookup table. */\n payer: PublicKey;\n /** A recent slot must be used in the derivation path for each initialized table. */\n recentSlot: bigint | number;\n};\n\nexport type FreezeLookupTableParams = {\n /** Address lookup table account to freeze. */\n lookupTable: PublicKey;\n /** Account which is the current authority. */\n authority: PublicKey;\n};\n\nexport type ExtendLookupTableParams = {\n /** Address lookup table account to extend. */\n lookupTable: PublicKey;\n /** Account which is the current authority. */\n authority: PublicKey;\n /** Account that will fund the table reallocation.\n * Not required if the reallocation has already been funded. */\n payer?: PublicKey;\n /** List of Public Keys to be added to the lookup table. */\n addresses: Array;\n};\n\nexport type DeactivateLookupTableParams = {\n /** Address lookup table account to deactivate. */\n lookupTable: PublicKey;\n /** Account which is the current authority. */\n authority: PublicKey;\n};\n\nexport type CloseLookupTableParams = {\n /** Address lookup table account to close. */\n lookupTable: PublicKey;\n /** Account which is the current authority. */\n authority: PublicKey;\n /** Recipient of closed account lamports. */\n recipient: PublicKey;\n};\n\n/**\n * An enumeration of valid LookupTableInstructionType's\n */\nexport type LookupTableInstructionType =\n | 'CreateLookupTable'\n | 'ExtendLookupTable'\n | 'CloseLookupTable'\n | 'FreezeLookupTable'\n | 'DeactivateLookupTable';\n\ntype LookupTableInstructionInputData = {\n CreateLookupTable: IInstructionInputData &\n Readonly<{\n recentSlot: bigint;\n bumpSeed: number;\n }>;\n FreezeLookupTable: IInstructionInputData;\n ExtendLookupTable: IInstructionInputData &\n Readonly<{\n numberOfAddresses: bigint;\n addresses: Array;\n }>;\n DeactivateLookupTable: IInstructionInputData;\n CloseLookupTable: IInstructionInputData;\n};\n\n/**\n * An enumeration of valid address lookup table InstructionType's\n * @internal\n */\nexport const LOOKUP_TABLE_INSTRUCTION_LAYOUTS = Object.freeze({\n CreateLookupTable: {\n index: 0,\n layout: BufferLayout.struct<\n LookupTableInstructionInputData['CreateLookupTable']\n >([\n BufferLayout.u32('instruction'),\n bigintLayout.u64('recentSlot'),\n BufferLayout.u8('bumpSeed'),\n ]),\n },\n FreezeLookupTable: {\n index: 1,\n layout: BufferLayout.struct<\n LookupTableInstructionInputData['FreezeLookupTable']\n >([BufferLayout.u32('instruction')]),\n },\n ExtendLookupTable: {\n index: 2,\n layout: BufferLayout.struct<\n LookupTableInstructionInputData['ExtendLookupTable']\n >([\n BufferLayout.u32('instruction'),\n bigintLayout.u64(),\n BufferLayout.seq(\n Layout.publicKey(),\n BufferLayout.offset(BufferLayout.u32(), -8),\n 'addresses',\n ),\n ]),\n },\n DeactivateLookupTable: {\n index: 3,\n layout: BufferLayout.struct<\n LookupTableInstructionInputData['DeactivateLookupTable']\n >([BufferLayout.u32('instruction')]),\n },\n CloseLookupTable: {\n index: 4,\n layout: BufferLayout.struct<\n LookupTableInstructionInputData['CloseLookupTable']\n >([BufferLayout.u32('instruction')]),\n },\n});\n\nexport class AddressLookupTableInstruction {\n /**\n * @internal\n */\n constructor() {}\n\n static decodeInstructionType(\n instruction: TransactionInstruction,\n ): LookupTableInstructionType {\n this.checkProgramId(instruction.programId);\n\n const instructionTypeLayout = BufferLayout.u32('instruction');\n const index = instructionTypeLayout.decode(instruction.data);\n\n let type: LookupTableInstructionType | undefined;\n for (const [layoutType, layout] of Object.entries(\n LOOKUP_TABLE_INSTRUCTION_LAYOUTS,\n )) {\n if ((layout as any).index == index) {\n type = layoutType as LookupTableInstructionType;\n break;\n }\n }\n if (!type) {\n throw new Error(\n 'Invalid Instruction. Should be a LookupTable Instruction',\n );\n }\n return type;\n }\n\n static decodeCreateLookupTable(\n instruction: TransactionInstruction,\n ): CreateLookupTableParams {\n this.checkProgramId(instruction.programId);\n this.checkKeysLength(instruction.keys, 4);\n\n const {recentSlot} = decodeData(\n LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable,\n instruction.data,\n );\n\n return {\n authority: instruction.keys[1].pubkey,\n payer: instruction.keys[2].pubkey,\n recentSlot: Number(recentSlot),\n };\n }\n\n static decodeExtendLookupTable(\n instruction: TransactionInstruction,\n ): ExtendLookupTableParams {\n this.checkProgramId(instruction.programId);\n if (instruction.keys.length < 2) {\n throw new Error(\n `invalid instruction; found ${instruction.keys.length} keys, expected at least 2`,\n );\n }\n\n const {addresses} = decodeData(\n LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable,\n instruction.data,\n );\n return {\n lookupTable: instruction.keys[0].pubkey,\n authority: instruction.keys[1].pubkey,\n payer:\n instruction.keys.length > 2 ? instruction.keys[2].pubkey : undefined,\n addresses: addresses.map(buffer => new PublicKey(buffer)),\n };\n }\n\n static decodeCloseLookupTable(\n instruction: TransactionInstruction,\n ): CloseLookupTableParams {\n this.checkProgramId(instruction.programId);\n this.checkKeysLength(instruction.keys, 3);\n\n return {\n lookupTable: instruction.keys[0].pubkey,\n authority: instruction.keys[1].pubkey,\n recipient: instruction.keys[2].pubkey,\n };\n }\n\n static decodeFreezeLookupTable(\n instruction: TransactionInstruction,\n ): FreezeLookupTableParams {\n this.checkProgramId(instruction.programId);\n this.checkKeysLength(instruction.keys, 2);\n\n return {\n lookupTable: instruction.keys[0].pubkey,\n authority: instruction.keys[1].pubkey,\n };\n }\n\n static decodeDeactivateLookupTable(\n instruction: TransactionInstruction,\n ): DeactivateLookupTableParams {\n this.checkProgramId(instruction.programId);\n this.checkKeysLength(instruction.keys, 2);\n\n return {\n lookupTable: instruction.keys[0].pubkey,\n authority: instruction.keys[1].pubkey,\n };\n }\n\n /**\n * @internal\n */\n static checkProgramId(programId: PublicKey) {\n if (!programId.equals(AddressLookupTableProgram.programId)) {\n throw new Error(\n 'invalid instruction; programId is not AddressLookupTable Program',\n );\n }\n }\n /**\n * @internal\n */\n static checkKeysLength(keys: Array, expectedLength: number) {\n if (keys.length < expectedLength) {\n throw new Error(\n `invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`,\n );\n }\n }\n}\n\nexport class AddressLookupTableProgram {\n /**\n * @internal\n */\n constructor() {}\n\n static programId: PublicKey = new PublicKey(\n 'AddressLookupTab1e1111111111111111111111111',\n );\n\n static createLookupTable(params: CreateLookupTableParams) {\n const [lookupTableAddress, bumpSeed] = PublicKey.findProgramAddressSync(\n [params.authority.toBuffer(), toBufferLE(BigInt(params.recentSlot), 8)],\n this.programId,\n );\n\n const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CreateLookupTable;\n const data = encodeData(type, {\n recentSlot: BigInt(params.recentSlot),\n bumpSeed: bumpSeed,\n });\n\n const keys = [\n {\n pubkey: lookupTableAddress,\n isSigner: false,\n isWritable: true,\n },\n {\n pubkey: params.authority,\n isSigner: true,\n isWritable: false,\n },\n {\n pubkey: params.payer,\n isSigner: true,\n isWritable: true,\n },\n {\n pubkey: SystemProgram.programId,\n isSigner: false,\n isWritable: false,\n },\n ];\n\n return [\n new TransactionInstruction({\n programId: this.programId,\n keys: keys,\n data: data,\n }),\n lookupTableAddress,\n ] as [TransactionInstruction, PublicKey];\n }\n\n static freezeLookupTable(params: FreezeLookupTableParams) {\n const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.FreezeLookupTable;\n const data = encodeData(type);\n\n const keys = [\n {\n pubkey: params.lookupTable,\n isSigner: false,\n isWritable: true,\n },\n {\n pubkey: params.authority,\n isSigner: true,\n isWritable: false,\n },\n ];\n\n return new TransactionInstruction({\n programId: this.programId,\n keys: keys,\n data: data,\n });\n }\n\n static extendLookupTable(params: ExtendLookupTableParams) {\n const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.ExtendLookupTable;\n const data = encodeData(type, {\n addresses: params.addresses.map(addr => addr.toBytes()),\n });\n\n const keys = [\n {\n pubkey: params.lookupTable,\n isSigner: false,\n isWritable: true,\n },\n {\n pubkey: params.authority,\n isSigner: true,\n isWritable: false,\n },\n ];\n\n if (params.payer) {\n keys.push(\n {\n pubkey: params.payer,\n isSigner: true,\n isWritable: true,\n },\n {\n pubkey: SystemProgram.programId,\n isSigner: false,\n isWritable: false,\n },\n );\n }\n\n return new TransactionInstruction({\n programId: this.programId,\n keys: keys,\n data: data,\n });\n }\n\n static deactivateLookupTable(params: DeactivateLookupTableParams) {\n const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.DeactivateLookupTable;\n const data = encodeData(type);\n\n const keys = [\n {\n pubkey: params.lookupTable,\n isSigner: false,\n isWritable: true,\n },\n {\n pubkey: params.authority,\n isSigner: true,\n isWritable: false,\n },\n ];\n\n return new TransactionInstruction({\n programId: this.programId,\n keys: keys,\n data: data,\n });\n }\n\n static closeLookupTable(params: CloseLookupTableParams) {\n const type = LOOKUP_TABLE_INSTRUCTION_LAYOUTS.CloseLookupTable;\n const data = encodeData(type);\n\n const keys = [\n {\n pubkey: params.lookupTable,\n isSigner: false,\n isWritable: true,\n },\n {\n pubkey: params.authority,\n isSigner: true,\n isWritable: false,\n },\n {\n pubkey: params.recipient,\n isSigner: false,\n isWritable: true,\n },\n ];\n\n return new TransactionInstruction({\n programId: this.programId,\n keys: keys,\n data: data,\n });\n }\n}\n","import * as BufferLayout from '@solana/buffer-layout';\n\nimport {\n encodeData,\n decodeData,\n InstructionType,\n IInstructionInputData,\n} from '../instruction';\nimport {PublicKey} from '../publickey';\nimport {TransactionInstruction} from '../transaction';\nimport {u64} from '../utils/bigint';\n\n/**\n * Compute Budget Instruction class\n */\nexport class ComputeBudgetInstruction {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Decode a compute budget instruction and retrieve the instruction type.\n */\n static decodeInstructionType(\n instruction: TransactionInstruction,\n ): ComputeBudgetInstructionType {\n this.checkProgramId(instruction.programId);\n\n const instructionTypeLayout = BufferLayout.u8('instruction');\n const typeIndex = instructionTypeLayout.decode(instruction.data);\n\n let type: ComputeBudgetInstructionType | undefined;\n for (const [ixType, layout] of Object.entries(\n COMPUTE_BUDGET_INSTRUCTION_LAYOUTS,\n )) {\n if (layout.index == typeIndex) {\n type = ixType as ComputeBudgetInstructionType;\n break;\n }\n }\n\n if (!type) {\n throw new Error(\n 'Instruction type incorrect; not a ComputeBudgetInstruction',\n );\n }\n\n return type;\n }\n\n /**\n * Decode request units compute budget instruction and retrieve the instruction params.\n */\n static decodeRequestUnits(\n instruction: TransactionInstruction,\n ): RequestUnitsParams {\n this.checkProgramId(instruction.programId);\n const {units, additionalFee} = decodeData(\n COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits,\n instruction.data,\n );\n return {units, additionalFee};\n }\n\n /**\n * Decode request heap frame compute budget instruction and retrieve the instruction params.\n */\n static decodeRequestHeapFrame(\n instruction: TransactionInstruction,\n ): RequestHeapFrameParams {\n this.checkProgramId(instruction.programId);\n const {bytes} = decodeData(\n COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame,\n instruction.data,\n );\n return {bytes};\n }\n\n /**\n * Decode set compute unit limit compute budget instruction and retrieve the instruction params.\n */\n static decodeSetComputeUnitLimit(\n instruction: TransactionInstruction,\n ): SetComputeUnitLimitParams {\n this.checkProgramId(instruction.programId);\n const {units} = decodeData(\n COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitLimit,\n instruction.data,\n );\n return {units};\n }\n\n /**\n * Decode set compute unit price compute budget instruction and retrieve the instruction params.\n */\n static decodeSetComputeUnitPrice(\n instruction: TransactionInstruction,\n ): SetComputeUnitPriceParams {\n this.checkProgramId(instruction.programId);\n const {microLamports} = decodeData(\n COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitPrice,\n instruction.data,\n );\n return {microLamports};\n }\n\n /**\n * @internal\n */\n static checkProgramId(programId: PublicKey) {\n if (!programId.equals(ComputeBudgetProgram.programId)) {\n throw new Error(\n 'invalid instruction; programId is not ComputeBudgetProgram',\n );\n }\n }\n}\n\n/**\n * An enumeration of valid ComputeBudgetInstructionType's\n */\nexport type ComputeBudgetInstructionType =\n // FIXME\n // It would be preferable for this type to be `keyof ComputeBudgetInstructionInputData`\n // but Typedoc does not transpile `keyof` expressions.\n // See https://github.com/TypeStrong/typedoc/issues/1894\n | 'RequestUnits'\n | 'RequestHeapFrame'\n | 'SetComputeUnitLimit'\n | 'SetComputeUnitPrice';\n\ntype ComputeBudgetInstructionInputData = {\n RequestUnits: IInstructionInputData & Readonly;\n RequestHeapFrame: IInstructionInputData & Readonly;\n SetComputeUnitLimit: IInstructionInputData &\n Readonly;\n SetComputeUnitPrice: IInstructionInputData &\n Readonly;\n};\n\n/**\n * Request units instruction params\n */\nexport interface RequestUnitsParams {\n /** Units to request for transaction-wide compute */\n units: number;\n /** Prioritization fee lamports */\n additionalFee: number;\n}\n\n/**\n * Request heap frame instruction params\n */\nexport type RequestHeapFrameParams = {\n /** Requested transaction-wide program heap size in bytes. Must be multiple of 1024. Applies to each program, including CPIs. */\n bytes: number;\n};\n\n/**\n * Set compute unit limit instruction params\n */\nexport interface SetComputeUnitLimitParams {\n /** Transaction-wide compute unit limit */\n units: number;\n}\n\n/**\n * Set compute unit price instruction params\n */\nexport interface SetComputeUnitPriceParams {\n /** Transaction compute unit price used for prioritization fees */\n microLamports: number | bigint;\n}\n\n/**\n * An enumeration of valid ComputeBudget InstructionType's\n * @internal\n */\nexport const COMPUTE_BUDGET_INSTRUCTION_LAYOUTS = Object.freeze<{\n [Instruction in ComputeBudgetInstructionType]: InstructionType<\n ComputeBudgetInstructionInputData[Instruction]\n >;\n}>({\n RequestUnits: {\n index: 0,\n layout: BufferLayout.struct<\n ComputeBudgetInstructionInputData['RequestUnits']\n >([\n BufferLayout.u8('instruction'),\n BufferLayout.u32('units'),\n BufferLayout.u32('additionalFee'),\n ]),\n },\n RequestHeapFrame: {\n index: 1,\n layout: BufferLayout.struct<\n ComputeBudgetInstructionInputData['RequestHeapFrame']\n >([BufferLayout.u8('instruction'), BufferLayout.u32('bytes')]),\n },\n SetComputeUnitLimit: {\n index: 2,\n layout: BufferLayout.struct<\n ComputeBudgetInstructionInputData['SetComputeUnitLimit']\n >([BufferLayout.u8('instruction'), BufferLayout.u32('units')]),\n },\n SetComputeUnitPrice: {\n index: 3,\n layout: BufferLayout.struct<\n ComputeBudgetInstructionInputData['SetComputeUnitPrice']\n >([BufferLayout.u8('instruction'), u64('microLamports')]),\n },\n});\n\n/**\n * Factory class for transaction instructions to interact with the Compute Budget program\n */\nexport class ComputeBudgetProgram {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Public key that identifies the Compute Budget program\n */\n static programId: PublicKey = new PublicKey(\n 'ComputeBudget111111111111111111111111111111',\n );\n\n /**\n * @deprecated Instead, call {@link setComputeUnitLimit} and/or {@link setComputeUnitPrice}\n */\n static requestUnits(params: RequestUnitsParams): TransactionInstruction {\n const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestUnits;\n const data = encodeData(type, params);\n return new TransactionInstruction({\n keys: [],\n programId: this.programId,\n data,\n });\n }\n\n static requestHeapFrame(\n params: RequestHeapFrameParams,\n ): TransactionInstruction {\n const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.RequestHeapFrame;\n const data = encodeData(type, params);\n return new TransactionInstruction({\n keys: [],\n programId: this.programId,\n data,\n });\n }\n\n static setComputeUnitLimit(\n params: SetComputeUnitLimitParams,\n ): TransactionInstruction {\n const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitLimit;\n const data = encodeData(type, params);\n return new TransactionInstruction({\n keys: [],\n programId: this.programId,\n data,\n });\n }\n\n static setComputeUnitPrice(\n params: SetComputeUnitPriceParams,\n ): TransactionInstruction {\n const type = COMPUTE_BUDGET_INSTRUCTION_LAYOUTS.SetComputeUnitPrice;\n const data = encodeData(type, {\n microLamports: BigInt(params.microLamports),\n });\n return new TransactionInstruction({\n keys: [],\n programId: this.programId,\n data,\n });\n }\n}\n","import {Buffer} from 'buffer';\nimport * as BufferLayout from '@solana/buffer-layout';\n\nimport {Keypair} from '../keypair';\nimport {PublicKey} from '../publickey';\nimport {TransactionInstruction} from '../transaction';\nimport assert from '../utils/assert';\nimport {sign} from '../utils/ed25519';\n\nconst PRIVATE_KEY_BYTES = 64;\nconst PUBLIC_KEY_BYTES = 32;\nconst SIGNATURE_BYTES = 64;\n\n/**\n * Params for creating an ed25519 instruction using a public key\n */\nexport type CreateEd25519InstructionWithPublicKeyParams = {\n publicKey: Uint8Array;\n message: Uint8Array;\n signature: Uint8Array;\n instructionIndex?: number;\n};\n\n/**\n * Params for creating an ed25519 instruction using a private key\n */\nexport type CreateEd25519InstructionWithPrivateKeyParams = {\n privateKey: Uint8Array;\n message: Uint8Array;\n instructionIndex?: number;\n};\n\nconst ED25519_INSTRUCTION_LAYOUT = BufferLayout.struct<\n Readonly<{\n messageDataOffset: number;\n messageDataSize: number;\n messageInstructionIndex: number;\n numSignatures: number;\n padding: number;\n publicKeyInstructionIndex: number;\n publicKeyOffset: number;\n signatureInstructionIndex: number;\n signatureOffset: number;\n }>\n>([\n BufferLayout.u8('numSignatures'),\n BufferLayout.u8('padding'),\n BufferLayout.u16('signatureOffset'),\n BufferLayout.u16('signatureInstructionIndex'),\n BufferLayout.u16('publicKeyOffset'),\n BufferLayout.u16('publicKeyInstructionIndex'),\n BufferLayout.u16('messageDataOffset'),\n BufferLayout.u16('messageDataSize'),\n BufferLayout.u16('messageInstructionIndex'),\n]);\n\nexport class Ed25519Program {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Public key that identifies the ed25519 program\n */\n static programId: PublicKey = new PublicKey(\n 'Ed25519SigVerify111111111111111111111111111',\n );\n\n /**\n * Create an ed25519 instruction with a public key and signature. The\n * public key must be a buffer that is 32 bytes long, and the signature\n * must be a buffer of 64 bytes.\n */\n static createInstructionWithPublicKey(\n params: CreateEd25519InstructionWithPublicKeyParams,\n ): TransactionInstruction {\n const {publicKey, message, signature, instructionIndex} = params;\n\n assert(\n publicKey.length === PUBLIC_KEY_BYTES,\n `Public Key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`,\n );\n\n assert(\n signature.length === SIGNATURE_BYTES,\n `Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`,\n );\n\n const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;\n const signatureOffset = publicKeyOffset + publicKey.length;\n const messageDataOffset = signatureOffset + signature.length;\n const numSignatures = 1;\n\n const instructionData = Buffer.alloc(messageDataOffset + message.length);\n\n const index =\n instructionIndex == null\n ? 0xffff // An index of `u16::MAX` makes it default to the current instruction.\n : instructionIndex;\n\n ED25519_INSTRUCTION_LAYOUT.encode(\n {\n numSignatures,\n padding: 0,\n signatureOffset,\n signatureInstructionIndex: index,\n publicKeyOffset,\n publicKeyInstructionIndex: index,\n messageDataOffset,\n messageDataSize: message.length,\n messageInstructionIndex: index,\n },\n instructionData,\n );\n\n instructionData.fill(publicKey, publicKeyOffset);\n instructionData.fill(signature, signatureOffset);\n instructionData.fill(message, messageDataOffset);\n\n return new TransactionInstruction({\n keys: [],\n programId: Ed25519Program.programId,\n data: instructionData,\n });\n }\n\n /**\n * Create an ed25519 instruction with a private key. The private key\n * must be a buffer that is 64 bytes long.\n */\n static createInstructionWithPrivateKey(\n params: CreateEd25519InstructionWithPrivateKeyParams,\n ): TransactionInstruction {\n const {privateKey, message, instructionIndex} = params;\n\n assert(\n privateKey.length === PRIVATE_KEY_BYTES,\n `Private key must be ${PRIVATE_KEY_BYTES} bytes but received ${privateKey.length} bytes`,\n );\n\n try {\n const keypair = Keypair.fromSecretKey(privateKey);\n const publicKey = keypair.publicKey.toBytes();\n const signature = sign(message, keypair.secretKey);\n\n return this.createInstructionWithPublicKey({\n publicKey,\n message,\n signature,\n instructionIndex,\n });\n } catch (error) {\n throw new Error(`Error creating instruction; ${error}`);\n }\n }\n}\n","import {secp256k1} from '@noble/curves/secp256k1';\n\nexport const ecdsaSign = (\n msgHash: Parameters[0],\n privKey: Parameters[1],\n) => {\n const signature = secp256k1.sign(msgHash, privKey);\n return [signature.toCompactRawBytes(), signature.recovery!] as const;\n};\nexport const isValidPrivateKey = secp256k1.utils.isValidPrivateKey;\nexport const publicKeyCreate = secp256k1.getPublicKey;\n","import {Buffer} from 'buffer';\nimport * as BufferLayout from '@solana/buffer-layout';\nimport {keccak_256} from '@noble/hashes/sha3';\n\nimport {PublicKey} from '../publickey';\nimport {TransactionInstruction} from '../transaction';\nimport assert from '../utils/assert';\nimport {publicKeyCreate, ecdsaSign} from '../utils/secp256k1';\nimport {toBuffer} from '../utils/to-buffer';\n\nconst PRIVATE_KEY_BYTES = 32;\nconst ETHEREUM_ADDRESS_BYTES = 20;\nconst PUBLIC_KEY_BYTES = 64;\nconst SIGNATURE_OFFSETS_SERIALIZED_SIZE = 11;\n\n/**\n * Params for creating an secp256k1 instruction using a public key\n */\nexport type CreateSecp256k1InstructionWithPublicKeyParams = {\n publicKey: Buffer | Uint8Array | Array;\n message: Buffer | Uint8Array | Array;\n signature: Buffer | Uint8Array | Array;\n recoveryId: number;\n instructionIndex?: number;\n};\n\n/**\n * Params for creating an secp256k1 instruction using an Ethereum address\n */\nexport type CreateSecp256k1InstructionWithEthAddressParams = {\n ethAddress: Buffer | Uint8Array | Array | string;\n message: Buffer | Uint8Array | Array;\n signature: Buffer | Uint8Array | Array;\n recoveryId: number;\n instructionIndex?: number;\n};\n\n/**\n * Params for creating an secp256k1 instruction using a private key\n */\nexport type CreateSecp256k1InstructionWithPrivateKeyParams = {\n privateKey: Buffer | Uint8Array | Array;\n message: Buffer | Uint8Array | Array;\n instructionIndex?: number;\n};\n\nconst SECP256K1_INSTRUCTION_LAYOUT = BufferLayout.struct<\n Readonly<{\n ethAddress: Uint8Array;\n ethAddressInstructionIndex: number;\n ethAddressOffset: number;\n messageDataOffset: number;\n messageDataSize: number;\n messageInstructionIndex: number;\n numSignatures: number;\n recoveryId: number;\n signature: Uint8Array;\n signatureInstructionIndex: number;\n signatureOffset: number;\n }>\n>([\n BufferLayout.u8('numSignatures'),\n BufferLayout.u16('signatureOffset'),\n BufferLayout.u8('signatureInstructionIndex'),\n BufferLayout.u16('ethAddressOffset'),\n BufferLayout.u8('ethAddressInstructionIndex'),\n BufferLayout.u16('messageDataOffset'),\n BufferLayout.u16('messageDataSize'),\n BufferLayout.u8('messageInstructionIndex'),\n BufferLayout.blob(20, 'ethAddress'),\n BufferLayout.blob(64, 'signature'),\n BufferLayout.u8('recoveryId'),\n]);\n\nexport class Secp256k1Program {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Public key that identifies the secp256k1 program\n */\n static programId: PublicKey = new PublicKey(\n 'KeccakSecp256k11111111111111111111111111111',\n );\n\n /**\n * Construct an Ethereum address from a secp256k1 public key buffer.\n * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer\n */\n static publicKeyToEthAddress(\n publicKey: Buffer | Uint8Array | Array,\n ): Buffer {\n assert(\n publicKey.length === PUBLIC_KEY_BYTES,\n `Public key must be ${PUBLIC_KEY_BYTES} bytes but received ${publicKey.length} bytes`,\n );\n\n try {\n return Buffer.from(keccak_256(toBuffer(publicKey))).slice(\n -ETHEREUM_ADDRESS_BYTES,\n );\n } catch (error) {\n throw new Error(`Error constructing Ethereum address: ${error}`);\n }\n }\n\n /**\n * Create an secp256k1 instruction with a public key. The public key\n * must be a buffer that is 64 bytes long.\n */\n static createInstructionWithPublicKey(\n params: CreateSecp256k1InstructionWithPublicKeyParams,\n ): TransactionInstruction {\n const {publicKey, message, signature, recoveryId, instructionIndex} =\n params;\n return Secp256k1Program.createInstructionWithEthAddress({\n ethAddress: Secp256k1Program.publicKeyToEthAddress(publicKey),\n message,\n signature,\n recoveryId,\n instructionIndex,\n });\n }\n\n /**\n * Create an secp256k1 instruction with an Ethereum address. The address\n * must be a hex string or a buffer that is 20 bytes long.\n */\n static createInstructionWithEthAddress(\n params: CreateSecp256k1InstructionWithEthAddressParams,\n ): TransactionInstruction {\n const {\n ethAddress: rawAddress,\n message,\n signature,\n recoveryId,\n instructionIndex = 0,\n } = params;\n\n let ethAddress;\n if (typeof rawAddress === 'string') {\n if (rawAddress.startsWith('0x')) {\n ethAddress = Buffer.from(rawAddress.substr(2), 'hex');\n } else {\n ethAddress = Buffer.from(rawAddress, 'hex');\n }\n } else {\n ethAddress = rawAddress;\n }\n\n assert(\n ethAddress.length === ETHEREUM_ADDRESS_BYTES,\n `Address must be ${ETHEREUM_ADDRESS_BYTES} bytes but received ${ethAddress.length} bytes`,\n );\n\n const dataStart = 1 + SIGNATURE_OFFSETS_SERIALIZED_SIZE;\n const ethAddressOffset = dataStart;\n const signatureOffset = dataStart + ethAddress.length;\n const messageDataOffset = signatureOffset + signature.length + 1;\n const numSignatures = 1;\n\n const instructionData = Buffer.alloc(\n SECP256K1_INSTRUCTION_LAYOUT.span + message.length,\n );\n\n SECP256K1_INSTRUCTION_LAYOUT.encode(\n {\n numSignatures,\n signatureOffset,\n signatureInstructionIndex: instructionIndex,\n ethAddressOffset,\n ethAddressInstructionIndex: instructionIndex,\n messageDataOffset,\n messageDataSize: message.length,\n messageInstructionIndex: instructionIndex,\n signature: toBuffer(signature),\n ethAddress: toBuffer(ethAddress),\n recoveryId,\n },\n instructionData,\n );\n\n instructionData.fill(toBuffer(message), SECP256K1_INSTRUCTION_LAYOUT.span);\n\n return new TransactionInstruction({\n keys: [],\n programId: Secp256k1Program.programId,\n data: instructionData,\n });\n }\n\n /**\n * Create an secp256k1 instruction with a private key. The private key\n * must be a buffer that is 32 bytes long.\n */\n static createInstructionWithPrivateKey(\n params: CreateSecp256k1InstructionWithPrivateKeyParams,\n ): TransactionInstruction {\n const {privateKey: pkey, message, instructionIndex} = params;\n\n assert(\n pkey.length === PRIVATE_KEY_BYTES,\n `Private key must be ${PRIVATE_KEY_BYTES} bytes but received ${pkey.length} bytes`,\n );\n\n try {\n const privateKey = toBuffer(pkey);\n const publicKey = publicKeyCreate(\n privateKey,\n false /* isCompressed */,\n ).slice(1); // throw away leading byte\n const messageHash = Buffer.from(keccak_256(toBuffer(message)));\n const [signature, recoveryId] = ecdsaSign(messageHash, privateKey);\n\n return this.createInstructionWithPublicKey({\n publicKey,\n message,\n signature,\n recoveryId,\n instructionIndex,\n });\n } catch (error) {\n throw new Error(`Error creating instruction; ${error}`);\n }\n }\n}\n","import * as BufferLayout from '@solana/buffer-layout';\n\nimport {\n encodeData,\n decodeData,\n InstructionType,\n IInstructionInputData,\n} from '../instruction';\nimport * as Layout from '../layout';\nimport {PublicKey} from '../publickey';\nimport {SystemProgram} from './system';\nimport {\n SYSVAR_CLOCK_PUBKEY,\n SYSVAR_RENT_PUBKEY,\n SYSVAR_STAKE_HISTORY_PUBKEY,\n} from '../sysvar';\nimport {Transaction, TransactionInstruction} from '../transaction';\nimport {toBuffer} from '../utils/to-buffer';\n\n/**\n * Address of the stake config account which configures the rate\n * of stake warmup and cooldown as well as the slashing penalty.\n */\nexport const STAKE_CONFIG_ID = new PublicKey(\n 'StakeConfig11111111111111111111111111111111',\n);\n\n/**\n * Stake account authority info\n */\nexport class Authorized {\n /** stake authority */\n staker: PublicKey;\n /** withdraw authority */\n withdrawer: PublicKey;\n\n /**\n * Create a new Authorized object\n * @param staker the stake authority\n * @param withdrawer the withdraw authority\n */\n constructor(staker: PublicKey, withdrawer: PublicKey) {\n this.staker = staker;\n this.withdrawer = withdrawer;\n }\n}\n\ntype AuthorizedRaw = Readonly<{\n staker: Uint8Array;\n withdrawer: Uint8Array;\n}>;\n\n/**\n * Stake account lockup info\n */\nexport class Lockup {\n /** Unix timestamp of lockup expiration */\n unixTimestamp: number;\n /** Epoch of lockup expiration */\n epoch: number;\n /** Lockup custodian authority */\n custodian: PublicKey;\n\n /**\n * Create a new Lockup object\n */\n constructor(unixTimestamp: number, epoch: number, custodian: PublicKey) {\n this.unixTimestamp = unixTimestamp;\n this.epoch = epoch;\n this.custodian = custodian;\n }\n\n /**\n * Default, inactive Lockup value\n */\n static default: Lockup = new Lockup(0, 0, PublicKey.default);\n}\n\ntype LockupRaw = Readonly<{\n custodian: Uint8Array;\n epoch: number;\n unixTimestamp: number;\n}>;\n\n/**\n * Create stake account transaction params\n */\nexport type CreateStakeAccountParams = {\n /** Address of the account which will fund creation */\n fromPubkey: PublicKey;\n /** Address of the new stake account */\n stakePubkey: PublicKey;\n /** Authorities of the new stake account */\n authorized: Authorized;\n /** Lockup of the new stake account */\n lockup?: Lockup;\n /** Funding amount */\n lamports: number;\n};\n\n/**\n * Create stake account with seed transaction params\n */\nexport type CreateStakeAccountWithSeedParams = {\n fromPubkey: PublicKey;\n stakePubkey: PublicKey;\n basePubkey: PublicKey;\n seed: string;\n authorized: Authorized;\n lockup?: Lockup;\n lamports: number;\n};\n\n/**\n * Initialize stake instruction params\n */\nexport type InitializeStakeParams = {\n stakePubkey: PublicKey;\n authorized: Authorized;\n lockup?: Lockup;\n};\n\n/**\n * Delegate stake instruction params\n */\nexport type DelegateStakeParams = {\n stakePubkey: PublicKey;\n authorizedPubkey: PublicKey;\n votePubkey: PublicKey;\n};\n\n/**\n * Authorize stake instruction params\n */\nexport type AuthorizeStakeParams = {\n stakePubkey: PublicKey;\n authorizedPubkey: PublicKey;\n newAuthorizedPubkey: PublicKey;\n stakeAuthorizationType: StakeAuthorizationType;\n custodianPubkey?: PublicKey;\n};\n\n/**\n * Authorize stake instruction params using a derived key\n */\nexport type AuthorizeWithSeedStakeParams = {\n stakePubkey: PublicKey;\n authorityBase: PublicKey;\n authoritySeed: string;\n authorityOwner: PublicKey;\n newAuthorizedPubkey: PublicKey;\n stakeAuthorizationType: StakeAuthorizationType;\n custodianPubkey?: PublicKey;\n};\n\n/**\n * Split stake instruction params\n */\nexport type SplitStakeParams = {\n stakePubkey: PublicKey;\n authorizedPubkey: PublicKey;\n splitStakePubkey: PublicKey;\n lamports: number;\n};\n\n/**\n * Split with seed transaction params\n */\nexport type SplitStakeWithSeedParams = {\n stakePubkey: PublicKey;\n authorizedPubkey: PublicKey;\n splitStakePubkey: PublicKey;\n basePubkey: PublicKey;\n seed: string;\n lamports: number;\n};\n\n/**\n * Withdraw stake instruction params\n */\nexport type WithdrawStakeParams = {\n stakePubkey: PublicKey;\n authorizedPubkey: PublicKey;\n toPubkey: PublicKey;\n lamports: number;\n custodianPubkey?: PublicKey;\n};\n\n/**\n * Deactivate stake instruction params\n */\nexport type DeactivateStakeParams = {\n stakePubkey: PublicKey;\n authorizedPubkey: PublicKey;\n};\n\n/**\n * Merge stake instruction params\n */\nexport type MergeStakeParams = {\n stakePubkey: PublicKey;\n sourceStakePubKey: PublicKey;\n authorizedPubkey: PublicKey;\n};\n\n/**\n * Stake Instruction class\n */\nexport class StakeInstruction {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Decode a stake instruction and retrieve the instruction type.\n */\n static decodeInstructionType(\n instruction: TransactionInstruction,\n ): StakeInstructionType {\n this.checkProgramId(instruction.programId);\n\n const instructionTypeLayout = BufferLayout.u32('instruction');\n const typeIndex = instructionTypeLayout.decode(instruction.data);\n\n let type: StakeInstructionType | undefined;\n for (const [ixType, layout] of Object.entries(STAKE_INSTRUCTION_LAYOUTS)) {\n if (layout.index == typeIndex) {\n type = ixType as StakeInstructionType;\n break;\n }\n }\n\n if (!type) {\n throw new Error('Instruction type incorrect; not a StakeInstruction');\n }\n\n return type;\n }\n\n /**\n * Decode a initialize stake instruction and retrieve the instruction params.\n */\n static decodeInitialize(\n instruction: TransactionInstruction,\n ): InitializeStakeParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n\n const {authorized, lockup} = decodeData(\n STAKE_INSTRUCTION_LAYOUTS.Initialize,\n instruction.data,\n );\n\n return {\n stakePubkey: instruction.keys[0].pubkey,\n authorized: new Authorized(\n new PublicKey(authorized.staker),\n new PublicKey(authorized.withdrawer),\n ),\n lockup: new Lockup(\n lockup.unixTimestamp,\n lockup.epoch,\n new PublicKey(lockup.custodian),\n ),\n };\n }\n\n /**\n * Decode a delegate stake instruction and retrieve the instruction params.\n */\n static decodeDelegate(\n instruction: TransactionInstruction,\n ): DelegateStakeParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 6);\n decodeData(STAKE_INSTRUCTION_LAYOUTS.Delegate, instruction.data);\n\n return {\n stakePubkey: instruction.keys[0].pubkey,\n votePubkey: instruction.keys[1].pubkey,\n authorizedPubkey: instruction.keys[5].pubkey,\n };\n }\n\n /**\n * Decode an authorize stake instruction and retrieve the instruction params.\n */\n static decodeAuthorize(\n instruction: TransactionInstruction,\n ): AuthorizeStakeParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const {newAuthorized, stakeAuthorizationType} = decodeData(\n STAKE_INSTRUCTION_LAYOUTS.Authorize,\n instruction.data,\n );\n\n const o: AuthorizeStakeParams = {\n stakePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: instruction.keys[2].pubkey,\n newAuthorizedPubkey: new PublicKey(newAuthorized),\n stakeAuthorizationType: {\n index: stakeAuthorizationType,\n },\n };\n if (instruction.keys.length > 3) {\n o.custodianPubkey = instruction.keys[3].pubkey;\n }\n return o;\n }\n\n /**\n * Decode an authorize-with-seed stake instruction and retrieve the instruction params.\n */\n static decodeAuthorizeWithSeed(\n instruction: TransactionInstruction,\n ): AuthorizeWithSeedStakeParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 2);\n\n const {\n newAuthorized,\n stakeAuthorizationType,\n authoritySeed,\n authorityOwner,\n } = decodeData(\n STAKE_INSTRUCTION_LAYOUTS.AuthorizeWithSeed,\n instruction.data,\n );\n\n const o: AuthorizeWithSeedStakeParams = {\n stakePubkey: instruction.keys[0].pubkey,\n authorityBase: instruction.keys[1].pubkey,\n authoritySeed: authoritySeed,\n authorityOwner: new PublicKey(authorityOwner),\n newAuthorizedPubkey: new PublicKey(newAuthorized),\n stakeAuthorizationType: {\n index: stakeAuthorizationType,\n },\n };\n if (instruction.keys.length > 3) {\n o.custodianPubkey = instruction.keys[3].pubkey;\n }\n return o;\n }\n\n /**\n * Decode a split stake instruction and retrieve the instruction params.\n */\n static decodeSplit(instruction: TransactionInstruction): SplitStakeParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n const {lamports} = decodeData(\n STAKE_INSTRUCTION_LAYOUTS.Split,\n instruction.data,\n );\n\n return {\n stakePubkey: instruction.keys[0].pubkey,\n splitStakePubkey: instruction.keys[1].pubkey,\n authorizedPubkey: instruction.keys[2].pubkey,\n lamports,\n };\n }\n\n /**\n * Decode a merge stake instruction and retrieve the instruction params.\n */\n static decodeMerge(instruction: TransactionInstruction): MergeStakeParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n decodeData(STAKE_INSTRUCTION_LAYOUTS.Merge, instruction.data);\n\n return {\n stakePubkey: instruction.keys[0].pubkey,\n sourceStakePubKey: instruction.keys[1].pubkey,\n authorizedPubkey: instruction.keys[4].pubkey,\n };\n }\n\n /**\n * Decode a withdraw stake instruction and retrieve the instruction params.\n */\n static decodeWithdraw(\n instruction: TransactionInstruction,\n ): WithdrawStakeParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 5);\n const {lamports} = decodeData(\n STAKE_INSTRUCTION_LAYOUTS.Withdraw,\n instruction.data,\n );\n\n const o: WithdrawStakeParams = {\n stakePubkey: instruction.keys[0].pubkey,\n toPubkey: instruction.keys[1].pubkey,\n authorizedPubkey: instruction.keys[4].pubkey,\n lamports,\n };\n if (instruction.keys.length > 5) {\n o.custodianPubkey = instruction.keys[5].pubkey;\n }\n return o;\n }\n\n /**\n * Decode a deactivate stake instruction and retrieve the instruction params.\n */\n static decodeDeactivate(\n instruction: TransactionInstruction,\n ): DeactivateStakeParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n decodeData(STAKE_INSTRUCTION_LAYOUTS.Deactivate, instruction.data);\n\n return {\n stakePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: instruction.keys[2].pubkey,\n };\n }\n\n /**\n * @internal\n */\n static checkProgramId(programId: PublicKey) {\n if (!programId.equals(StakeProgram.programId)) {\n throw new Error('invalid instruction; programId is not StakeProgram');\n }\n }\n\n /**\n * @internal\n */\n static checkKeyLength(keys: Array, expectedLength: number) {\n if (keys.length < expectedLength) {\n throw new Error(\n `invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`,\n );\n }\n }\n}\n\n/**\n * An enumeration of valid StakeInstructionType's\n */\nexport type StakeInstructionType =\n // FIXME\n // It would be preferable for this type to be `keyof StakeInstructionInputData`\n // but Typedoc does not transpile `keyof` expressions.\n // See https://github.com/TypeStrong/typedoc/issues/1894\n | 'Authorize'\n | 'AuthorizeWithSeed'\n | 'Deactivate'\n | 'Delegate'\n | 'Initialize'\n | 'Merge'\n | 'Split'\n | 'Withdraw';\n\ntype StakeInstructionInputData = {\n Authorize: IInstructionInputData &\n Readonly<{\n newAuthorized: Uint8Array;\n stakeAuthorizationType: number;\n }>;\n AuthorizeWithSeed: IInstructionInputData &\n Readonly<{\n authorityOwner: Uint8Array;\n authoritySeed: string;\n instruction: number;\n newAuthorized: Uint8Array;\n stakeAuthorizationType: number;\n }>;\n Deactivate: IInstructionInputData;\n Delegate: IInstructionInputData;\n Initialize: IInstructionInputData &\n Readonly<{\n authorized: AuthorizedRaw;\n lockup: LockupRaw;\n }>;\n Merge: IInstructionInputData;\n Split: IInstructionInputData &\n Readonly<{\n lamports: number;\n }>;\n Withdraw: IInstructionInputData &\n Readonly<{\n lamports: number;\n }>;\n};\n\n/**\n * An enumeration of valid stake InstructionType's\n * @internal\n */\nexport const STAKE_INSTRUCTION_LAYOUTS = Object.freeze<{\n [Instruction in StakeInstructionType]: InstructionType<\n StakeInstructionInputData[Instruction]\n >;\n}>({\n Initialize: {\n index: 0,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n Layout.authorized(),\n Layout.lockup(),\n ]),\n },\n Authorize: {\n index: 1,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n Layout.publicKey('newAuthorized'),\n BufferLayout.u32('stakeAuthorizationType'),\n ]),\n },\n Delegate: {\n index: 2,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n ]),\n },\n Split: {\n index: 3,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n BufferLayout.ns64('lamports'),\n ]),\n },\n Withdraw: {\n index: 4,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n BufferLayout.ns64('lamports'),\n ]),\n },\n Deactivate: {\n index: 5,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n ]),\n },\n Merge: {\n index: 7,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n ]),\n },\n AuthorizeWithSeed: {\n index: 8,\n layout: BufferLayout.struct(\n [\n BufferLayout.u32('instruction'),\n Layout.publicKey('newAuthorized'),\n BufferLayout.u32('stakeAuthorizationType'),\n Layout.rustString('authoritySeed'),\n Layout.publicKey('authorityOwner'),\n ],\n ),\n },\n});\n\n/**\n * Stake authorization type\n */\nexport type StakeAuthorizationType = {\n /** The Stake Authorization index (from solana-stake-program) */\n index: number;\n};\n\n/**\n * An enumeration of valid StakeAuthorizationLayout's\n */\nexport const StakeAuthorizationLayout = Object.freeze({\n Staker: {\n index: 0,\n },\n Withdrawer: {\n index: 1,\n },\n});\n\n/**\n * Factory class for transactions to interact with the Stake program\n */\nexport class StakeProgram {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Public key that identifies the Stake program\n */\n static programId: PublicKey = new PublicKey(\n 'Stake11111111111111111111111111111111111111',\n );\n\n /**\n * Max space of a Stake account\n *\n * This is generated from the solana-stake-program StakeState struct as\n * `StakeStateV2::size_of()`:\n * https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeStateV2.html\n */\n static space: number = 200;\n\n /**\n * Generate an Initialize instruction to add to a Stake Create transaction\n */\n static initialize(params: InitializeStakeParams): TransactionInstruction {\n const {stakePubkey, authorized, lockup: maybeLockup} = params;\n const lockup: Lockup = maybeLockup || Lockup.default;\n const type = STAKE_INSTRUCTION_LAYOUTS.Initialize;\n const data = encodeData(type, {\n authorized: {\n staker: toBuffer(authorized.staker.toBuffer()),\n withdrawer: toBuffer(authorized.withdrawer.toBuffer()),\n },\n lockup: {\n unixTimestamp: lockup.unixTimestamp,\n epoch: lockup.epoch,\n custodian: toBuffer(lockup.custodian.toBuffer()),\n },\n });\n const instructionData = {\n keys: [\n {pubkey: stakePubkey, isSigner: false, isWritable: true},\n {pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false},\n ],\n programId: this.programId,\n data,\n };\n return new TransactionInstruction(instructionData);\n }\n\n /**\n * Generate a Transaction that creates a new Stake account at\n * an address generated with `from`, a seed, and the Stake programId\n */\n static createAccountWithSeed(\n params: CreateStakeAccountWithSeedParams,\n ): Transaction {\n const transaction = new Transaction();\n transaction.add(\n SystemProgram.createAccountWithSeed({\n fromPubkey: params.fromPubkey,\n newAccountPubkey: params.stakePubkey,\n basePubkey: params.basePubkey,\n seed: params.seed,\n lamports: params.lamports,\n space: this.space,\n programId: this.programId,\n }),\n );\n\n const {stakePubkey, authorized, lockup} = params;\n return transaction.add(this.initialize({stakePubkey, authorized, lockup}));\n }\n\n /**\n * Generate a Transaction that creates a new Stake account\n */\n static createAccount(params: CreateStakeAccountParams): Transaction {\n const transaction = new Transaction();\n transaction.add(\n SystemProgram.createAccount({\n fromPubkey: params.fromPubkey,\n newAccountPubkey: params.stakePubkey,\n lamports: params.lamports,\n space: this.space,\n programId: this.programId,\n }),\n );\n\n const {stakePubkey, authorized, lockup} = params;\n return transaction.add(this.initialize({stakePubkey, authorized, lockup}));\n }\n\n /**\n * Generate a Transaction that delegates Stake tokens to a validator\n * Vote PublicKey. This transaction can also be used to redelegate Stake\n * to a new validator Vote PublicKey.\n */\n static delegate(params: DelegateStakeParams): Transaction {\n const {stakePubkey, authorizedPubkey, votePubkey} = params;\n\n const type = STAKE_INSTRUCTION_LAYOUTS.Delegate;\n const data = encodeData(type);\n\n return new Transaction().add({\n keys: [\n {pubkey: stakePubkey, isSigner: false, isWritable: true},\n {pubkey: votePubkey, isSigner: false, isWritable: false},\n {pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},\n {\n pubkey: SYSVAR_STAKE_HISTORY_PUBKEY,\n isSigner: false,\n isWritable: false,\n },\n {pubkey: STAKE_CONFIG_ID, isSigner: false, isWritable: false},\n {pubkey: authorizedPubkey, isSigner: true, isWritable: false},\n ],\n programId: this.programId,\n data,\n });\n }\n\n /**\n * Generate a Transaction that authorizes a new PublicKey as Staker\n * or Withdrawer on the Stake account.\n */\n static authorize(params: AuthorizeStakeParams): Transaction {\n const {\n stakePubkey,\n authorizedPubkey,\n newAuthorizedPubkey,\n stakeAuthorizationType,\n custodianPubkey,\n } = params;\n\n const type = STAKE_INSTRUCTION_LAYOUTS.Authorize;\n const data = encodeData(type, {\n newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),\n stakeAuthorizationType: stakeAuthorizationType.index,\n });\n\n const keys = [\n {pubkey: stakePubkey, isSigner: false, isWritable: true},\n {pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: true},\n {pubkey: authorizedPubkey, isSigner: true, isWritable: false},\n ];\n if (custodianPubkey) {\n keys.push({\n pubkey: custodianPubkey,\n isSigner: true,\n isWritable: false,\n });\n }\n return new Transaction().add({\n keys,\n programId: this.programId,\n data,\n });\n }\n\n /**\n * Generate a Transaction that authorizes a new PublicKey as Staker\n * or Withdrawer on the Stake account.\n */\n static authorizeWithSeed(params: AuthorizeWithSeedStakeParams): Transaction {\n const {\n stakePubkey,\n authorityBase,\n authoritySeed,\n authorityOwner,\n newAuthorizedPubkey,\n stakeAuthorizationType,\n custodianPubkey,\n } = params;\n\n const type = STAKE_INSTRUCTION_LAYOUTS.AuthorizeWithSeed;\n const data = encodeData(type, {\n newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),\n stakeAuthorizationType: stakeAuthorizationType.index,\n authoritySeed: authoritySeed,\n authorityOwner: toBuffer(authorityOwner.toBuffer()),\n });\n\n const keys = [\n {pubkey: stakePubkey, isSigner: false, isWritable: true},\n {pubkey: authorityBase, isSigner: true, isWritable: false},\n {pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},\n ];\n if (custodianPubkey) {\n keys.push({\n pubkey: custodianPubkey,\n isSigner: true,\n isWritable: false,\n });\n }\n return new Transaction().add({\n keys,\n programId: this.programId,\n data,\n });\n }\n\n /**\n * @internal\n */\n static splitInstruction(params: SplitStakeParams): TransactionInstruction {\n const {stakePubkey, authorizedPubkey, splitStakePubkey, lamports} = params;\n const type = STAKE_INSTRUCTION_LAYOUTS.Split;\n const data = encodeData(type, {lamports});\n return new TransactionInstruction({\n keys: [\n {pubkey: stakePubkey, isSigner: false, isWritable: true},\n {pubkey: splitStakePubkey, isSigner: false, isWritable: true},\n {pubkey: authorizedPubkey, isSigner: true, isWritable: false},\n ],\n programId: this.programId,\n data,\n });\n }\n\n /**\n * Generate a Transaction that splits Stake tokens into another stake account\n */\n static split(\n params: SplitStakeParams,\n // Compute the cost of allocating the new stake account in lamports\n rentExemptReserve: number,\n ): Transaction {\n const transaction = new Transaction();\n transaction.add(\n SystemProgram.createAccount({\n fromPubkey: params.authorizedPubkey,\n newAccountPubkey: params.splitStakePubkey,\n lamports: rentExemptReserve,\n space: this.space,\n programId: this.programId,\n }),\n );\n return transaction.add(this.splitInstruction(params));\n }\n\n /**\n * Generate a Transaction that splits Stake tokens into another account\n * derived from a base public key and seed\n */\n static splitWithSeed(\n params: SplitStakeWithSeedParams,\n // If this stake account is new, compute the cost of allocating it in lamports\n rentExemptReserve?: number,\n ): Transaction {\n const {\n stakePubkey,\n authorizedPubkey,\n splitStakePubkey,\n basePubkey,\n seed,\n lamports,\n } = params;\n const transaction = new Transaction();\n transaction.add(\n SystemProgram.allocate({\n accountPubkey: splitStakePubkey,\n basePubkey,\n seed,\n space: this.space,\n programId: this.programId,\n }),\n );\n if (rentExemptReserve && rentExemptReserve > 0) {\n transaction.add(\n SystemProgram.transfer({\n fromPubkey: params.authorizedPubkey,\n toPubkey: splitStakePubkey,\n lamports: rentExemptReserve,\n }),\n );\n }\n return transaction.add(\n this.splitInstruction({\n stakePubkey,\n authorizedPubkey,\n splitStakePubkey,\n lamports,\n }),\n );\n }\n\n /**\n * Generate a Transaction that merges Stake accounts.\n */\n static merge(params: MergeStakeParams): Transaction {\n const {stakePubkey, sourceStakePubKey, authorizedPubkey} = params;\n const type = STAKE_INSTRUCTION_LAYOUTS.Merge;\n const data = encodeData(type);\n\n return new Transaction().add({\n keys: [\n {pubkey: stakePubkey, isSigner: false, isWritable: true},\n {pubkey: sourceStakePubKey, isSigner: false, isWritable: true},\n {pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},\n {\n pubkey: SYSVAR_STAKE_HISTORY_PUBKEY,\n isSigner: false,\n isWritable: false,\n },\n {pubkey: authorizedPubkey, isSigner: true, isWritable: false},\n ],\n programId: this.programId,\n data,\n });\n }\n\n /**\n * Generate a Transaction that withdraws deactivated Stake tokens.\n */\n static withdraw(params: WithdrawStakeParams): Transaction {\n const {stakePubkey, authorizedPubkey, toPubkey, lamports, custodianPubkey} =\n params;\n const type = STAKE_INSTRUCTION_LAYOUTS.Withdraw;\n const data = encodeData(type, {lamports});\n\n const keys = [\n {pubkey: stakePubkey, isSigner: false, isWritable: true},\n {pubkey: toPubkey, isSigner: false, isWritable: true},\n {pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},\n {\n pubkey: SYSVAR_STAKE_HISTORY_PUBKEY,\n isSigner: false,\n isWritable: false,\n },\n {pubkey: authorizedPubkey, isSigner: true, isWritable: false},\n ];\n if (custodianPubkey) {\n keys.push({\n pubkey: custodianPubkey,\n isSigner: true,\n isWritable: false,\n });\n }\n return new Transaction().add({\n keys,\n programId: this.programId,\n data,\n });\n }\n\n /**\n * Generate a Transaction that deactivates Stake tokens.\n */\n static deactivate(params: DeactivateStakeParams): Transaction {\n const {stakePubkey, authorizedPubkey} = params;\n const type = STAKE_INSTRUCTION_LAYOUTS.Deactivate;\n const data = encodeData(type);\n\n return new Transaction().add({\n keys: [\n {pubkey: stakePubkey, isSigner: false, isWritable: true},\n {pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},\n {pubkey: authorizedPubkey, isSigner: true, isWritable: false},\n ],\n programId: this.programId,\n data,\n });\n }\n}\n","import * as BufferLayout from '@solana/buffer-layout';\n\nimport {\n encodeData,\n decodeData,\n InstructionType,\n IInstructionInputData,\n} from '../instruction';\nimport * as Layout from '../layout';\nimport {PublicKey} from '../publickey';\nimport {SystemProgram} from './system';\nimport {SYSVAR_CLOCK_PUBKEY, SYSVAR_RENT_PUBKEY} from '../sysvar';\nimport {Transaction, TransactionInstruction} from '../transaction';\nimport {toBuffer} from '../utils/to-buffer';\n\n/**\n * Vote account info\n */\nexport class VoteInit {\n nodePubkey: PublicKey;\n authorizedVoter: PublicKey;\n authorizedWithdrawer: PublicKey;\n commission: number; /** [0, 100] */\n\n constructor(\n nodePubkey: PublicKey,\n authorizedVoter: PublicKey,\n authorizedWithdrawer: PublicKey,\n commission: number,\n ) {\n this.nodePubkey = nodePubkey;\n this.authorizedVoter = authorizedVoter;\n this.authorizedWithdrawer = authorizedWithdrawer;\n this.commission = commission;\n }\n}\n\n/**\n * Create vote account transaction params\n */\nexport type CreateVoteAccountParams = {\n fromPubkey: PublicKey;\n votePubkey: PublicKey;\n voteInit: VoteInit;\n lamports: number;\n};\n\n/**\n * InitializeAccount instruction params\n */\nexport type InitializeAccountParams = {\n votePubkey: PublicKey;\n nodePubkey: PublicKey;\n voteInit: VoteInit;\n};\n\n/**\n * Authorize instruction params\n */\nexport type AuthorizeVoteParams = {\n votePubkey: PublicKey;\n /** Current vote or withdraw authority, depending on `voteAuthorizationType` */\n authorizedPubkey: PublicKey;\n newAuthorizedPubkey: PublicKey;\n voteAuthorizationType: VoteAuthorizationType;\n};\n\n/**\n * AuthorizeWithSeed instruction params\n */\nexport type AuthorizeVoteWithSeedParams = {\n currentAuthorityDerivedKeyBasePubkey: PublicKey;\n currentAuthorityDerivedKeyOwnerPubkey: PublicKey;\n currentAuthorityDerivedKeySeed: string;\n newAuthorizedPubkey: PublicKey;\n voteAuthorizationType: VoteAuthorizationType;\n votePubkey: PublicKey;\n};\n\n/**\n * Withdraw from vote account transaction params\n */\nexport type WithdrawFromVoteAccountParams = {\n votePubkey: PublicKey;\n authorizedWithdrawerPubkey: PublicKey;\n lamports: number;\n toPubkey: PublicKey;\n};\n\n/**\n * Update validator identity (node pubkey) vote account instruction params.\n */\nexport type UpdateValidatorIdentityParams = {\n votePubkey: PublicKey;\n authorizedWithdrawerPubkey: PublicKey;\n nodePubkey: PublicKey;\n};\n\n/**\n * Vote Instruction class\n */\nexport class VoteInstruction {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Decode a vote instruction and retrieve the instruction type.\n */\n static decodeInstructionType(\n instruction: TransactionInstruction,\n ): VoteInstructionType {\n this.checkProgramId(instruction.programId);\n\n const instructionTypeLayout = BufferLayout.u32('instruction');\n const typeIndex = instructionTypeLayout.decode(instruction.data);\n\n let type: VoteInstructionType | undefined;\n for (const [ixType, layout] of Object.entries(VOTE_INSTRUCTION_LAYOUTS)) {\n if (layout.index == typeIndex) {\n type = ixType as VoteInstructionType;\n break;\n }\n }\n\n if (!type) {\n throw new Error('Instruction type incorrect; not a VoteInstruction');\n }\n\n return type;\n }\n\n /**\n * Decode an initialize vote instruction and retrieve the instruction params.\n */\n static decodeInitializeAccount(\n instruction: TransactionInstruction,\n ): InitializeAccountParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 4);\n\n const {voteInit} = decodeData(\n VOTE_INSTRUCTION_LAYOUTS.InitializeAccount,\n instruction.data,\n );\n\n return {\n votePubkey: instruction.keys[0].pubkey,\n nodePubkey: instruction.keys[3].pubkey,\n voteInit: new VoteInit(\n new PublicKey(voteInit.nodePubkey),\n new PublicKey(voteInit.authorizedVoter),\n new PublicKey(voteInit.authorizedWithdrawer),\n voteInit.commission,\n ),\n };\n }\n\n /**\n * Decode an authorize instruction and retrieve the instruction params.\n */\n static decodeAuthorize(\n instruction: TransactionInstruction,\n ): AuthorizeVoteParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n\n const {newAuthorized, voteAuthorizationType} = decodeData(\n VOTE_INSTRUCTION_LAYOUTS.Authorize,\n instruction.data,\n );\n\n return {\n votePubkey: instruction.keys[0].pubkey,\n authorizedPubkey: instruction.keys[2].pubkey,\n newAuthorizedPubkey: new PublicKey(newAuthorized),\n voteAuthorizationType: {\n index: voteAuthorizationType,\n },\n };\n }\n\n /**\n * Decode an authorize instruction and retrieve the instruction params.\n */\n static decodeAuthorizeWithSeed(\n instruction: TransactionInstruction,\n ): AuthorizeVoteWithSeedParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n\n const {\n voteAuthorizeWithSeedArgs: {\n currentAuthorityDerivedKeyOwnerPubkey,\n currentAuthorityDerivedKeySeed,\n newAuthorized,\n voteAuthorizationType,\n },\n } = decodeData(\n VOTE_INSTRUCTION_LAYOUTS.AuthorizeWithSeed,\n instruction.data,\n );\n\n return {\n currentAuthorityDerivedKeyBasePubkey: instruction.keys[2].pubkey,\n currentAuthorityDerivedKeyOwnerPubkey: new PublicKey(\n currentAuthorityDerivedKeyOwnerPubkey,\n ),\n currentAuthorityDerivedKeySeed: currentAuthorityDerivedKeySeed,\n newAuthorizedPubkey: new PublicKey(newAuthorized),\n voteAuthorizationType: {\n index: voteAuthorizationType,\n },\n votePubkey: instruction.keys[0].pubkey,\n };\n }\n\n /**\n * Decode a withdraw instruction and retrieve the instruction params.\n */\n static decodeWithdraw(\n instruction: TransactionInstruction,\n ): WithdrawFromVoteAccountParams {\n this.checkProgramId(instruction.programId);\n this.checkKeyLength(instruction.keys, 3);\n\n const {lamports} = decodeData(\n VOTE_INSTRUCTION_LAYOUTS.Withdraw,\n instruction.data,\n );\n\n return {\n votePubkey: instruction.keys[0].pubkey,\n authorizedWithdrawerPubkey: instruction.keys[2].pubkey,\n lamports,\n toPubkey: instruction.keys[1].pubkey,\n };\n }\n\n /**\n * @internal\n */\n static checkProgramId(programId: PublicKey) {\n if (!programId.equals(VoteProgram.programId)) {\n throw new Error('invalid instruction; programId is not VoteProgram');\n }\n }\n\n /**\n * @internal\n */\n static checkKeyLength(keys: Array, expectedLength: number) {\n if (keys.length < expectedLength) {\n throw new Error(\n `invalid instruction; found ${keys.length} keys, expected at least ${expectedLength}`,\n );\n }\n }\n}\n\n/**\n * An enumeration of valid VoteInstructionType's\n */\nexport type VoteInstructionType =\n // FIXME\n // It would be preferable for this type to be `keyof VoteInstructionInputData`\n // but Typedoc does not transpile `keyof` expressions.\n // See https://github.com/TypeStrong/typedoc/issues/1894\n | 'Authorize'\n | 'AuthorizeWithSeed'\n | 'InitializeAccount'\n | 'Withdraw'\n | 'UpdateValidatorIdentity';\n\n/** @internal */\nexport type VoteAuthorizeWithSeedArgs = Readonly<{\n currentAuthorityDerivedKeyOwnerPubkey: Uint8Array;\n currentAuthorityDerivedKeySeed: string;\n newAuthorized: Uint8Array;\n voteAuthorizationType: number;\n}>;\ntype VoteInstructionInputData = {\n Authorize: IInstructionInputData & {\n newAuthorized: Uint8Array;\n voteAuthorizationType: number;\n };\n AuthorizeWithSeed: IInstructionInputData & {\n voteAuthorizeWithSeedArgs: VoteAuthorizeWithSeedArgs;\n };\n InitializeAccount: IInstructionInputData & {\n voteInit: Readonly<{\n authorizedVoter: Uint8Array;\n authorizedWithdrawer: Uint8Array;\n commission: number;\n nodePubkey: Uint8Array;\n }>;\n };\n Withdraw: IInstructionInputData & {\n lamports: number;\n };\n UpdateValidatorIdentity: IInstructionInputData;\n};\n\nconst VOTE_INSTRUCTION_LAYOUTS = Object.freeze<{\n [Instruction in VoteInstructionType]: InstructionType<\n VoteInstructionInputData[Instruction]\n >;\n}>({\n InitializeAccount: {\n index: 0,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n Layout.voteInit(),\n ]),\n },\n Authorize: {\n index: 1,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n Layout.publicKey('newAuthorized'),\n BufferLayout.u32('voteAuthorizationType'),\n ]),\n },\n Withdraw: {\n index: 3,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n BufferLayout.ns64('lamports'),\n ]),\n },\n UpdateValidatorIdentity: {\n index: 4,\n layout: BufferLayout.struct<\n VoteInstructionInputData['UpdateValidatorIdentity']\n >([BufferLayout.u32('instruction')]),\n },\n AuthorizeWithSeed: {\n index: 10,\n layout: BufferLayout.struct([\n BufferLayout.u32('instruction'),\n Layout.voteAuthorizeWithSeedArgs(),\n ]),\n },\n});\n\n/**\n * VoteAuthorize type\n */\nexport type VoteAuthorizationType = {\n /** The VoteAuthorize index (from solana-vote-program) */\n index: number;\n};\n\n/**\n * An enumeration of valid VoteAuthorization layouts.\n */\nexport const VoteAuthorizationLayout = Object.freeze({\n Voter: {\n index: 0,\n },\n Withdrawer: {\n index: 1,\n },\n});\n\n/**\n * Factory class for transactions to interact with the Vote program\n */\nexport class VoteProgram {\n /**\n * @internal\n */\n constructor() {}\n\n /**\n * Public key that identifies the Vote program\n */\n static programId: PublicKey = new PublicKey(\n 'Vote111111111111111111111111111111111111111',\n );\n\n /**\n * Max space of a Vote account\n *\n * This is generated from the solana-vote-program VoteState struct as\n * `VoteState::size_of()`:\n * https://docs.rs/solana-vote-program/1.9.5/solana_vote_program/vote_state/struct.VoteState.html#method.size_of\n *\n * KEEP IN SYNC WITH `VoteState::size_of()` in https://github.com/solana-labs/solana/blob/a474cb24b9238f5edcc982f65c0b37d4a1046f7e/sdk/program/src/vote/state/mod.rs#L340-L342\n */\n static space: number = 3762;\n\n /**\n * Generate an Initialize instruction.\n */\n static initializeAccount(\n params: InitializeAccountParams,\n ): TransactionInstruction {\n const {votePubkey, nodePubkey, voteInit} = params;\n const type = VOTE_INSTRUCTION_LAYOUTS.InitializeAccount;\n const data = encodeData(type, {\n voteInit: {\n nodePubkey: toBuffer(voteInit.nodePubkey.toBuffer()),\n authorizedVoter: toBuffer(voteInit.authorizedVoter.toBuffer()),\n authorizedWithdrawer: toBuffer(\n voteInit.authorizedWithdrawer.toBuffer(),\n ),\n commission: voteInit.commission,\n },\n });\n const instructionData = {\n keys: [\n {pubkey: votePubkey, isSigner: false, isWritable: true},\n {pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false},\n {pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},\n {pubkey: nodePubkey, isSigner: true, isWritable: false},\n ],\n programId: this.programId,\n data,\n };\n return new TransactionInstruction(instructionData);\n }\n\n /**\n * Generate a transaction that creates a new Vote account.\n */\n static createAccount(params: CreateVoteAccountParams): Transaction {\n const transaction = new Transaction();\n transaction.add(\n SystemProgram.createAccount({\n fromPubkey: params.fromPubkey,\n newAccountPubkey: params.votePubkey,\n lamports: params.lamports,\n space: this.space,\n programId: this.programId,\n }),\n );\n\n return transaction.add(\n this.initializeAccount({\n votePubkey: params.votePubkey,\n nodePubkey: params.voteInit.nodePubkey,\n voteInit: params.voteInit,\n }),\n );\n }\n\n /**\n * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account.\n */\n static authorize(params: AuthorizeVoteParams): Transaction {\n const {\n votePubkey,\n authorizedPubkey,\n newAuthorizedPubkey,\n voteAuthorizationType,\n } = params;\n\n const type = VOTE_INSTRUCTION_LAYOUTS.Authorize;\n const data = encodeData(type, {\n newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),\n voteAuthorizationType: voteAuthorizationType.index,\n });\n\n const keys = [\n {pubkey: votePubkey, isSigner: false, isWritable: true},\n {pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},\n {pubkey: authorizedPubkey, isSigner: true, isWritable: false},\n ];\n\n return new Transaction().add({\n keys,\n programId: this.programId,\n data,\n });\n }\n\n /**\n * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account\n * where the current Voter or Withdrawer authority is a derived key.\n */\n static authorizeWithSeed(params: AuthorizeVoteWithSeedParams): Transaction {\n const {\n currentAuthorityDerivedKeyBasePubkey,\n currentAuthorityDerivedKeyOwnerPubkey,\n currentAuthorityDerivedKeySeed,\n newAuthorizedPubkey,\n voteAuthorizationType,\n votePubkey,\n } = params;\n\n const type = VOTE_INSTRUCTION_LAYOUTS.AuthorizeWithSeed;\n const data = encodeData(type, {\n voteAuthorizeWithSeedArgs: {\n currentAuthorityDerivedKeyOwnerPubkey: toBuffer(\n currentAuthorityDerivedKeyOwnerPubkey.toBuffer(),\n ),\n currentAuthorityDerivedKeySeed: currentAuthorityDerivedKeySeed,\n newAuthorized: toBuffer(newAuthorizedPubkey.toBuffer()),\n voteAuthorizationType: voteAuthorizationType.index,\n },\n });\n\n const keys = [\n {pubkey: votePubkey, isSigner: false, isWritable: true},\n {pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false},\n {\n pubkey: currentAuthorityDerivedKeyBasePubkey,\n isSigner: true,\n isWritable: false,\n },\n ];\n\n return new Transaction().add({\n keys,\n programId: this.programId,\n data,\n });\n }\n\n /**\n * Generate a transaction to withdraw from a Vote account.\n */\n static withdraw(params: WithdrawFromVoteAccountParams): Transaction {\n const {votePubkey, authorizedWithdrawerPubkey, lamports, toPubkey} = params;\n const type = VOTE_INSTRUCTION_LAYOUTS.Withdraw;\n const data = encodeData(type, {lamports});\n\n const keys = [\n {pubkey: votePubkey, isSigner: false, isWritable: true},\n {pubkey: toPubkey, isSigner: false, isWritable: true},\n {pubkey: authorizedWithdrawerPubkey, isSigner: true, isWritable: false},\n ];\n\n return new Transaction().add({\n keys,\n programId: this.programId,\n data,\n });\n }\n\n /**\n * Generate a transaction to withdraw safely from a Vote account.\n *\n * This function was created as a safeguard for vote accounts running validators, `safeWithdraw`\n * checks that the withdraw amount will not exceed the specified balance while leaving enough left\n * to cover rent. If you wish to close the vote account by withdrawing the full amount, call the\n * `withdraw` method directly.\n */\n static safeWithdraw(\n params: WithdrawFromVoteAccountParams,\n currentVoteAccountBalance: number,\n rentExemptMinimum: number,\n ): Transaction {\n if (params.lamports > currentVoteAccountBalance - rentExemptMinimum) {\n throw new Error(\n 'Withdraw will leave vote account with insufficient funds.',\n );\n }\n return VoteProgram.withdraw(params);\n }\n\n /**\n * Generate a transaction to update the validator identity (node pubkey) of a Vote account.\n */\n static updateValidatorIdentity(\n params: UpdateValidatorIdentityParams,\n ): Transaction {\n const {votePubkey, authorizedWithdrawerPubkey, nodePubkey} = params;\n const type = VOTE_INSTRUCTION_LAYOUTS.UpdateValidatorIdentity;\n const data = encodeData(type);\n\n const keys = [\n {pubkey: votePubkey, isSigner: false, isWritable: true},\n {pubkey: nodePubkey, isSigner: true, isWritable: false},\n {pubkey: authorizedWithdrawerPubkey, isSigner: true, isWritable: false},\n ];\n\n return new Transaction().add({\n keys,\n programId: this.programId,\n data,\n });\n }\n}\n","import {Buffer} from 'buffer';\nimport {\n assert as assertType,\n optional,\n string,\n type as pick,\n} from 'superstruct';\n\nimport * as Layout from './layout';\nimport * as shortvec from './utils/shortvec-encoding';\nimport {PublicKey, PUBLIC_KEY_LENGTH} from './publickey';\nimport {guardedShift, guardedSplice} from './utils/guarded-array-utils';\n\nexport const VALIDATOR_INFO_KEY = new PublicKey(\n 'Va1idator1nfo111111111111111111111111111111',\n);\n\n/**\n * @internal\n */\ntype ConfigKey = {\n publicKey: PublicKey;\n isSigner: boolean;\n};\n\n/**\n * Info used to identity validators.\n */\nexport type Info = {\n /** validator name */\n name: string;\n /** optional, validator website */\n website?: string;\n /** optional, extra information the validator chose to share */\n details?: string;\n /** optional, validator logo URL */\n iconUrl?: string;\n /** optional, used to identify validators on keybase.io */\n keybaseUsername?: string;\n};\n\nconst InfoString = pick({\n name: string(),\n website: optional(string()),\n details: optional(string()),\n iconUrl: optional(string()),\n keybaseUsername: optional(string()),\n});\n\n/**\n * ValidatorInfo class\n */\nexport class ValidatorInfo {\n /**\n * validator public key\n */\n key: PublicKey;\n /**\n * validator information\n */\n info: Info;\n\n /**\n * Construct a valid ValidatorInfo\n *\n * @param key validator public key\n * @param info validator information\n */\n constructor(key: PublicKey, info: Info) {\n this.key = key;\n this.info = info;\n }\n\n /**\n * Deserialize ValidatorInfo from the config account data. Exactly two config\n * keys are required in the data.\n *\n * @param buffer config account data\n * @return null if info was not found\n */\n static fromConfigData(\n buffer: Buffer | Uint8Array | Array,\n ): ValidatorInfo | null {\n let byteArray = [...buffer];\n const configKeyCount = shortvec.decodeLength(byteArray);\n if (configKeyCount !== 2) return null;\n\n const configKeys: Array = [];\n for (let i = 0; i < 2; i++) {\n const publicKey = new PublicKey(\n guardedSplice(byteArray, 0, PUBLIC_KEY_LENGTH),\n );\n const isSigner = guardedShift(byteArray) === 1;\n configKeys.push({publicKey, isSigner});\n }\n\n if (configKeys[0].publicKey.equals(VALIDATOR_INFO_KEY)) {\n if (configKeys[1].isSigner) {\n const rawInfo: any = Layout.rustString().decode(Buffer.from(byteArray));\n const info = JSON.parse(rawInfo as string);\n assertType(info, InfoString);\n return new ValidatorInfo(configKeys[1].publicKey, info);\n }\n }\n\n return null;\n }\n}\n","import * as BufferLayout from '@solana/buffer-layout';\nimport type {Buffer} from 'buffer';\n\nimport * as Layout from './layout';\nimport {PublicKey} from './publickey';\nimport {toBuffer} from './utils/to-buffer';\n\nexport const VOTE_PROGRAM_ID = new PublicKey(\n 'Vote111111111111111111111111111111111111111',\n);\n\nexport type Lockout = {\n slot: number;\n confirmationCount: number;\n};\n\n/**\n * History of how many credits earned by the end of each epoch\n */\nexport type EpochCredits = Readonly<{\n epoch: number;\n credits: number;\n prevCredits: number;\n}>;\n\nexport type AuthorizedVoter = Readonly<{\n epoch: number;\n authorizedVoter: PublicKey;\n}>;\n\ntype AuthorizedVoterRaw = Readonly<{\n authorizedVoter: Uint8Array;\n epoch: number;\n}>;\n\ntype PriorVoters = Readonly<{\n buf: PriorVoterRaw[];\n idx: number;\n isEmpty: number;\n}>;\n\nexport type PriorVoter = Readonly<{\n authorizedPubkey: PublicKey;\n epochOfLastAuthorizedSwitch: number;\n targetEpoch: number;\n}>;\n\ntype PriorVoterRaw = Readonly<{\n authorizedPubkey: Uint8Array;\n epochOfLastAuthorizedSwitch: number;\n targetEpoch: number;\n}>;\n\nexport type BlockTimestamp = Readonly<{\n slot: number;\n timestamp: number;\n}>;\n\ntype VoteAccountData = Readonly<{\n authorizedVoters: AuthorizedVoterRaw[];\n authorizedWithdrawer: Uint8Array;\n commission: number;\n epochCredits: EpochCredits[];\n lastTimestamp: BlockTimestamp;\n nodePubkey: Uint8Array;\n priorVoters: PriorVoters;\n rootSlot: number;\n rootSlotValid: number;\n votes: Lockout[];\n}>;\n\n/**\n * See https://github.com/solana-labs/solana/blob/8a12ed029cfa38d4a45400916c2463fb82bbec8c/programs/vote_api/src/vote_state.rs#L68-L88\n *\n * @internal\n */\nconst VoteAccountLayout = BufferLayout.struct([\n Layout.publicKey('nodePubkey'),\n Layout.publicKey('authorizedWithdrawer'),\n BufferLayout.u8('commission'),\n BufferLayout.nu64(), // votes.length\n BufferLayout.seq(\n BufferLayout.struct([\n BufferLayout.nu64('slot'),\n BufferLayout.u32('confirmationCount'),\n ]),\n BufferLayout.offset(BufferLayout.u32(), -8),\n 'votes',\n ),\n BufferLayout.u8('rootSlotValid'),\n BufferLayout.nu64('rootSlot'),\n BufferLayout.nu64(), // authorizedVoters.length\n BufferLayout.seq(\n BufferLayout.struct([\n BufferLayout.nu64('epoch'),\n Layout.publicKey('authorizedVoter'),\n ]),\n BufferLayout.offset(BufferLayout.u32(), -8),\n 'authorizedVoters',\n ),\n BufferLayout.struct(\n [\n BufferLayout.seq(\n BufferLayout.struct([\n Layout.publicKey('authorizedPubkey'),\n BufferLayout.nu64('epochOfLastAuthorizedSwitch'),\n BufferLayout.nu64('targetEpoch'),\n ]),\n 32,\n 'buf',\n ),\n BufferLayout.nu64('idx'),\n BufferLayout.u8('isEmpty'),\n ],\n 'priorVoters',\n ),\n BufferLayout.nu64(), // epochCredits.length\n BufferLayout.seq(\n BufferLayout.struct([\n BufferLayout.nu64('epoch'),\n BufferLayout.nu64('credits'),\n BufferLayout.nu64('prevCredits'),\n ]),\n BufferLayout.offset(BufferLayout.u32(), -8),\n 'epochCredits',\n ),\n BufferLayout.struct(\n [BufferLayout.nu64('slot'), BufferLayout.nu64('timestamp')],\n 'lastTimestamp',\n ),\n]);\n\ntype VoteAccountArgs = {\n nodePubkey: PublicKey;\n authorizedWithdrawer: PublicKey;\n commission: number;\n rootSlot: number | null;\n votes: Lockout[];\n authorizedVoters: AuthorizedVoter[];\n priorVoters: PriorVoter[];\n epochCredits: EpochCredits[];\n lastTimestamp: BlockTimestamp;\n};\n\n/**\n * VoteAccount class\n */\nexport class VoteAccount {\n nodePubkey: PublicKey;\n authorizedWithdrawer: PublicKey;\n commission: number;\n rootSlot: number | null;\n votes: Lockout[];\n authorizedVoters: AuthorizedVoter[];\n priorVoters: PriorVoter[];\n epochCredits: EpochCredits[];\n lastTimestamp: BlockTimestamp;\n\n /**\n * @internal\n */\n constructor(args: VoteAccountArgs) {\n this.nodePubkey = args.nodePubkey;\n this.authorizedWithdrawer = args.authorizedWithdrawer;\n this.commission = args.commission;\n this.rootSlot = args.rootSlot;\n this.votes = args.votes;\n this.authorizedVoters = args.authorizedVoters;\n this.priorVoters = args.priorVoters;\n this.epochCredits = args.epochCredits;\n this.lastTimestamp = args.lastTimestamp;\n }\n\n /**\n * Deserialize VoteAccount from the account data.\n *\n * @param buffer account data\n * @return VoteAccount\n */\n static fromAccountData(\n buffer: Buffer | Uint8Array | Array,\n ): VoteAccount {\n const versionOffset = 4;\n const va = VoteAccountLayout.decode(toBuffer(buffer), versionOffset);\n\n let rootSlot: number | null = va.rootSlot;\n if (!va.rootSlotValid) {\n rootSlot = null;\n }\n\n return new VoteAccount({\n nodePubkey: new PublicKey(va.nodePubkey),\n authorizedWithdrawer: new PublicKey(va.authorizedWithdrawer),\n commission: va.commission,\n votes: va.votes,\n rootSlot,\n authorizedVoters: va.authorizedVoters.map(parseAuthorizedVoter),\n priorVoters: getPriorVoters(va.priorVoters),\n epochCredits: va.epochCredits,\n lastTimestamp: va.lastTimestamp,\n });\n }\n}\n\nfunction parseAuthorizedVoter({\n authorizedVoter,\n epoch,\n}: AuthorizedVoterRaw): AuthorizedVoter {\n return {\n epoch,\n authorizedVoter: new PublicKey(authorizedVoter),\n };\n}\n\nfunction parsePriorVoters({\n authorizedPubkey,\n epochOfLastAuthorizedSwitch,\n targetEpoch,\n}: PriorVoterRaw): PriorVoter {\n return {\n authorizedPubkey: new PublicKey(authorizedPubkey),\n epochOfLastAuthorizedSwitch,\n targetEpoch,\n };\n}\n\nfunction getPriorVoters({buf, idx, isEmpty}: PriorVoters): PriorVoter[] {\n if (isEmpty) {\n return [];\n }\n\n return [\n ...buf.slice(idx + 1).map(parsePriorVoters),\n ...buf.slice(0, idx).map(parsePriorVoters),\n ];\n}\n","const endpoint = {\n http: {\n devnet: 'http://api.devnet.solana.com',\n testnet: 'http://api.testnet.solana.com',\n 'mainnet-beta': 'http://api.mainnet-beta.solana.com/',\n },\n https: {\n devnet: 'https://api.devnet.solana.com',\n testnet: 'https://api.testnet.solana.com',\n 'mainnet-beta': 'https://api.mainnet-beta.solana.com/',\n },\n};\n\nexport type Cluster = 'devnet' | 'testnet' | 'mainnet-beta';\n\n/**\n * Retrieves the RPC API URL for the specified cluster\n * @param {Cluster} [cluster=\"devnet\"] - The cluster name of the RPC API URL to use. Possible options: 'devnet' | 'testnet' | 'mainnet-beta'\n * @param {boolean} [tls=\"http\"] - Use TLS when connecting to cluster.\n *\n * @returns {string} URL string of the RPC endpoint\n */\nexport function clusterApiUrl(cluster?: Cluster, tls?: boolean): string {\n const key = tls === false ? 'http' : 'https';\n\n if (!cluster) {\n return endpoint[key]['devnet'];\n }\n\n const url = endpoint[key][cluster];\n if (!url) {\n throw new Error(`Unknown ${key} cluster: ${cluster}`);\n }\n return url;\n}\n","import type {Buffer} from 'buffer';\n\nimport {\n BlockheightBasedTransactionConfirmationStrategy,\n Connection,\n DurableNonceTransactionConfirmationStrategy,\n TransactionConfirmationStrategy,\n} from '../connection';\nimport type {TransactionSignature} from '../transaction';\nimport type {ConfirmOptions} from '../connection';\nimport {SendTransactionError} from '../errors';\n\n/**\n * Send and confirm a raw transaction\n *\n * If `commitment` option is not specified, defaults to 'max' commitment.\n *\n * @param {Connection} connection\n * @param {Buffer} rawTransaction\n * @param {TransactionConfirmationStrategy} confirmationStrategy\n * @param {ConfirmOptions} [options]\n * @returns {Promise}\n */\nexport async function sendAndConfirmRawTransaction(\n connection: Connection,\n rawTransaction: Buffer,\n confirmationStrategy: TransactionConfirmationStrategy,\n options?: ConfirmOptions,\n): Promise;\n\n/**\n * @deprecated Calling `sendAndConfirmRawTransaction()` without a `confirmationStrategy`\n * is no longer supported and will be removed in a future version.\n */\n// eslint-disable-next-line no-redeclare\nexport async function sendAndConfirmRawTransaction(\n connection: Connection,\n rawTransaction: Buffer,\n options?: ConfirmOptions,\n): Promise;\n\n// eslint-disable-next-line no-redeclare\nexport async function sendAndConfirmRawTransaction(\n connection: Connection,\n rawTransaction: Buffer,\n confirmationStrategyOrConfirmOptions:\n | TransactionConfirmationStrategy\n | ConfirmOptions\n | undefined,\n maybeConfirmOptions?: ConfirmOptions,\n): Promise {\n let confirmationStrategy: TransactionConfirmationStrategy | undefined;\n let options: ConfirmOptions | undefined;\n if (\n confirmationStrategyOrConfirmOptions &&\n Object.prototype.hasOwnProperty.call(\n confirmationStrategyOrConfirmOptions,\n 'lastValidBlockHeight',\n )\n ) {\n confirmationStrategy =\n confirmationStrategyOrConfirmOptions as BlockheightBasedTransactionConfirmationStrategy;\n options = maybeConfirmOptions;\n } else if (\n confirmationStrategyOrConfirmOptions &&\n Object.prototype.hasOwnProperty.call(\n confirmationStrategyOrConfirmOptions,\n 'nonceValue',\n )\n ) {\n confirmationStrategy =\n confirmationStrategyOrConfirmOptions as DurableNonceTransactionConfirmationStrategy;\n options = maybeConfirmOptions;\n } else {\n options = confirmationStrategyOrConfirmOptions as\n | ConfirmOptions\n | undefined;\n }\n const sendOptions = options && {\n skipPreflight: options.skipPreflight,\n preflightCommitment: options.preflightCommitment || options.commitment,\n minContextSlot: options.minContextSlot,\n };\n\n const signature = await connection.sendRawTransaction(\n rawTransaction,\n sendOptions,\n );\n\n const commitment = options && options.commitment;\n const confirmationPromise = confirmationStrategy\n ? connection.confirmTransaction(confirmationStrategy, commitment)\n : connection.confirmTransaction(signature, commitment);\n const status = (await confirmationPromise).value;\n\n if (status.err) {\n if (signature != null) {\n throw new SendTransactionError({\n action: sendOptions?.skipPreflight ? 'send' : 'simulate',\n signature: signature,\n transactionMessage: `Status: (${JSON.stringify(status)})`,\n });\n }\n throw new Error(\n `Raw transaction ${signature} failed (${JSON.stringify(status)})`,\n );\n }\n\n return signature;\n}\n","export * from './account';\nexport * from './blockhash';\nexport * from './bpf-loader-deprecated';\nexport * from './bpf-loader';\nexport * from './connection';\nexport * from './epoch-schedule';\nexport * from './errors';\nexport * from './fee-calculator';\nexport * from './keypair';\nexport * from './loader';\nexport * from './message';\nexport * from './nonce-account';\nexport * from './programs';\nexport * from './publickey';\nexport * from './transaction';\nexport * from './validator-info';\nexport * from './vote-account';\nexport * from './sysvar';\nexport * from './utils';\n\n/**\n * There are 1-billion lamports in one SOL\n */\nexport const LAMPORTS_PER_SOL = 1000000000;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.hash_to_ristretto255 = exports.hashToRistretto255 = exports.RistrettoPoint = exports.encodeToCurve = exports.hashToCurve = exports.edwardsToMontgomery = exports.x25519 = exports.ed25519ph = exports.ed25519ctx = exports.ed25519 = exports.ED25519_TORSION_SUBGROUP = void 0;\nexports.edwardsToMontgomeryPub = edwardsToMontgomeryPub;\nexports.edwardsToMontgomeryPriv = edwardsToMontgomeryPriv;\n/**\n * ed25519 Twisted Edwards curve with following addons:\n * - X25519 ECDH\n * - Ristretto cofactor elimination\n * - Elligator hash-to-group / point indistinguishability\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nconst sha512_1 = require(\"@noble/hashes/sha512\");\nconst utils_1 = require(\"@noble/hashes/utils\");\nconst curve_js_1 = require(\"./abstract/curve.js\");\nconst edwards_js_1 = require(\"./abstract/edwards.js\");\nconst hash_to_curve_js_1 = require(\"./abstract/hash-to-curve.js\");\nconst modular_js_1 = require(\"./abstract/modular.js\");\nconst montgomery_js_1 = require(\"./abstract/montgomery.js\");\nconst utils_js_1 = require(\"./abstract/utils.js\");\nconst ED25519_P = BigInt('57896044618658097711785492504343953926634992332820282019728792003956564819949');\n// √(-1) aka √(a) aka 2^((p-1)/4)\nconst ED25519_SQRT_M1 = /* @__PURE__ */ BigInt('19681161376707505956807079304988542015446066515923890162744021073123829784752');\n// prettier-ignore\nconst _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3);\n// prettier-ignore\nconst _5n = BigInt(5), _8n = BigInt(8);\nfunction ed25519_pow_2_252_3(x) {\n // prettier-ignore\n const _10n = BigInt(10), _20n = BigInt(20), _40n = BigInt(40), _80n = BigInt(80);\n const P = ED25519_P;\n const x2 = (x * x) % P;\n const b2 = (x2 * x) % P; // x^3, 11\n const b4 = ((0, modular_js_1.pow2)(b2, _2n, P) * b2) % P; // x^15, 1111\n const b5 = ((0, modular_js_1.pow2)(b4, _1n, P) * x) % P; // x^31\n const b10 = ((0, modular_js_1.pow2)(b5, _5n, P) * b5) % P;\n const b20 = ((0, modular_js_1.pow2)(b10, _10n, P) * b10) % P;\n const b40 = ((0, modular_js_1.pow2)(b20, _20n, P) * b20) % P;\n const b80 = ((0, modular_js_1.pow2)(b40, _40n, P) * b40) % P;\n const b160 = ((0, modular_js_1.pow2)(b80, _80n, P) * b80) % P;\n const b240 = ((0, modular_js_1.pow2)(b160, _80n, P) * b80) % P;\n const b250 = ((0, modular_js_1.pow2)(b240, _10n, P) * b10) % P;\n const pow_p_5_8 = ((0, modular_js_1.pow2)(b250, _2n, P) * x) % P;\n // ^ To pow to (p+3)/8, multiply it by x.\n return { pow_p_5_8, b2 };\n}\nfunction adjustScalarBytes(bytes) {\n // Section 5: For X25519, in order to decode 32 random bytes as an integer scalar,\n // set the three least significant bits of the first byte\n bytes[0] &= 248; // 0b1111_1000\n // and the most significant bit of the last to zero,\n bytes[31] &= 127; // 0b0111_1111\n // set the second most significant bit of the last byte to 1\n bytes[31] |= 64; // 0b0100_0000\n return bytes;\n}\n// sqrt(u/v)\nfunction uvRatio(u, v) {\n const P = ED25519_P;\n const v3 = (0, modular_js_1.mod)(v * v * v, P); // v³\n const v7 = (0, modular_js_1.mod)(v3 * v3 * v, P); // v⁷\n // (p+3)/8 and (p-5)/8\n const pow = ed25519_pow_2_252_3(u * v7).pow_p_5_8;\n let x = (0, modular_js_1.mod)(u * v3 * pow, P); // (uv³)(uv⁷)^(p-5)/8\n const vx2 = (0, modular_js_1.mod)(v * x * x, P); // vx²\n const root1 = x; // First root candidate\n const root2 = (0, modular_js_1.mod)(x * ED25519_SQRT_M1, P); // Second root candidate\n const useRoot1 = vx2 === u; // If vx² = u (mod p), x is a square root\n const useRoot2 = vx2 === (0, modular_js_1.mod)(-u, P); // If vx² = -u, set x <-- x * 2^((p-1)/4)\n const noRoot = vx2 === (0, modular_js_1.mod)(-u * ED25519_SQRT_M1, P); // There is no valid root, vx² = -u√(-1)\n if (useRoot1)\n x = root1;\n if (useRoot2 || noRoot)\n x = root2; // We return root2 anyway, for const-time\n if ((0, modular_js_1.isNegativeLE)(x, P))\n x = (0, modular_js_1.mod)(-x, P);\n return { isValid: useRoot1 || useRoot2, value: x };\n}\n// Just in case\nexports.ED25519_TORSION_SUBGROUP = [\n '0100000000000000000000000000000000000000000000000000000000000000',\n 'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a',\n '0000000000000000000000000000000000000000000000000000000000000080',\n '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05',\n 'ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f',\n '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85',\n '0000000000000000000000000000000000000000000000000000000000000000',\n 'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa',\n];\nconst Fp = /* @__PURE__ */ (() => (0, modular_js_1.Field)(ED25519_P, undefined, true))();\nconst ed25519Defaults = /* @__PURE__ */ (() => ({\n // Param: a\n a: BigInt(-1), // Fp.create(-1) is proper; our way still works and is faster\n // d is equal to -121665/121666 over finite field.\n // Negative number is P - number, and division is invert(number, P)\n d: BigInt('37095705934669439343138083508754565189542113879843219016388785533085940283555'),\n // Finite field 𝔽p over which we'll do calculations; 2n**255n - 19n\n Fp,\n // Subgroup order: how many points curve has\n // 2n**252n + 27742317777372353535851937790883648493n;\n n: BigInt('7237005577332262213973186563042994240857116359379907606001950938285454250989'),\n // Cofactor\n h: _8n,\n // Base point (x, y) aka generator point\n Gx: BigInt('15112221349535400772501151409588531511454012693041857206046113283949847762202'),\n Gy: BigInt('46316835694926478169428394003475163141307993866256225615783033603165251855960'),\n hash: sha512_1.sha512,\n randomBytes: utils_1.randomBytes,\n adjustScalarBytes,\n // dom2\n // Ratio of u to v. Allows us to combine inversion and square root. Uses algo from RFC8032 5.1.3.\n // Constant-time, u/√v\n uvRatio,\n}))();\n/**\n * ed25519 curve with EdDSA signatures.\n * @example\n * import { ed25519 } from '@noble/curves/ed25519';\n * const priv = ed25519.utils.randomPrivateKey();\n * const pub = ed25519.getPublicKey(priv);\n * const msg = new TextEncoder().encode('hello');\n * const sig = ed25519.sign(msg, priv);\n * ed25519.verify(sig, msg, pub); // Default mode: follows ZIP215\n * ed25519.verify(sig, msg, pub, { zip215: false }); // RFC8032 / FIPS 186-5\n */\nexports.ed25519 = (() => (0, edwards_js_1.twistedEdwards)(ed25519Defaults))();\nfunction ed25519_domain(data, ctx, phflag) {\n if (ctx.length > 255)\n throw new Error('Context is too big');\n return (0, utils_1.concatBytes)((0, utils_1.utf8ToBytes)('SigEd25519 no Ed25519 collisions'), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);\n}\nexports.ed25519ctx = (() => (0, edwards_js_1.twistedEdwards)({\n ...ed25519Defaults,\n domain: ed25519_domain,\n}))();\nexports.ed25519ph = (() => (0, edwards_js_1.twistedEdwards)(Object.assign({}, ed25519Defaults, {\n domain: ed25519_domain,\n prehash: sha512_1.sha512,\n})))();\n/**\n * ECDH using curve25519 aka x25519.\n * @example\n * import { x25519 } from '@noble/curves/ed25519';\n * const priv = 'a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4';\n * const pub = 'e6db6867583030db3594c1a424b15f7c726624ec26b3353b10a903a6d0ab1c4c';\n * x25519.getSharedSecret(priv, pub) === x25519.scalarMult(priv, pub); // aliases\n * x25519.getPublicKey(priv) === x25519.scalarMultBase(priv);\n * x25519.getPublicKey(x25519.utils.randomPrivateKey());\n */\nexports.x25519 = (() => (0, montgomery_js_1.montgomery)({\n P: ED25519_P,\n a: BigInt(486662),\n montgomeryBits: 255, // n is 253 bits\n nByteLength: 32,\n Gu: BigInt(9),\n powPminus2: (x) => {\n const P = ED25519_P;\n // x^(p-2) aka x^(2^255-21)\n const { pow_p_5_8, b2 } = ed25519_pow_2_252_3(x);\n return (0, modular_js_1.mod)((0, modular_js_1.pow2)(pow_p_5_8, _3n, P) * b2, P);\n },\n adjustScalarBytes,\n randomBytes: utils_1.randomBytes,\n}))();\n/**\n * Converts ed25519 public key to x25519 public key. Uses formula:\n * * `(u, v) = ((1+y)/(1-y), sqrt(-486664)*u/x)`\n * * `(x, y) = (sqrt(-486664)*u/v, (u-1)/(u+1))`\n * @example\n * const someonesPub = ed25519.getPublicKey(ed25519.utils.randomPrivateKey());\n * const aPriv = x25519.utils.randomPrivateKey();\n * x25519.getSharedSecret(aPriv, edwardsToMontgomeryPub(someonesPub))\n */\nfunction edwardsToMontgomeryPub(edwardsPub) {\n const { y } = exports.ed25519.ExtendedPoint.fromHex(edwardsPub);\n const _1n = BigInt(1);\n return Fp.toBytes(Fp.create((_1n + y) * Fp.inv(_1n - y)));\n}\nexports.edwardsToMontgomery = edwardsToMontgomeryPub; // deprecated\n/**\n * Converts ed25519 secret key to x25519 secret key.\n * @example\n * const someonesPub = x25519.getPublicKey(x25519.utils.randomPrivateKey());\n * const aPriv = ed25519.utils.randomPrivateKey();\n * x25519.getSharedSecret(edwardsToMontgomeryPriv(aPriv), someonesPub)\n */\nfunction edwardsToMontgomeryPriv(edwardsPriv) {\n const hashed = ed25519Defaults.hash(edwardsPriv.subarray(0, 32));\n return ed25519Defaults.adjustScalarBytes(hashed).subarray(0, 32);\n}\n// Hash To Curve Elligator2 Map (NOTE: different from ristretto255 elligator)\n// NOTE: very important part is usage of FpSqrtEven for ELL2_C1_EDWARDS, since\n// SageMath returns different root first and everything falls apart\nconst ELL2_C1 = /* @__PURE__ */ (() => (Fp.ORDER + _3n) / _8n)(); // 1. c1 = (q + 3) / 8 # Integer arithmetic\nconst ELL2_C2 = /* @__PURE__ */ (() => Fp.pow(_2n, ELL2_C1))(); // 2. c2 = 2^c1\nconst ELL2_C3 = /* @__PURE__ */ (() => Fp.sqrt(Fp.neg(Fp.ONE)))(); // 3. c3 = sqrt(-1)\n// prettier-ignore\nfunction map_to_curve_elligator2_curve25519(u) {\n const ELL2_C4 = (Fp.ORDER - _5n) / _8n; // 4. c4 = (q - 5) / 8 # Integer arithmetic\n const ELL2_J = BigInt(486662);\n let tv1 = Fp.sqr(u); // 1. tv1 = u^2\n tv1 = Fp.mul(tv1, _2n); // 2. tv1 = 2 * tv1\n let xd = Fp.add(tv1, Fp.ONE); // 3. xd = tv1 + 1 # Nonzero: -1 is square (mod p), tv1 is not\n let x1n = Fp.neg(ELL2_J); // 4. x1n = -J # x1 = x1n / xd = -J / (1 + 2 * u^2)\n let tv2 = Fp.sqr(xd); // 5. tv2 = xd^2\n let gxd = Fp.mul(tv2, xd); // 6. gxd = tv2 * xd # gxd = xd^3\n let gx1 = Fp.mul(tv1, ELL2_J); // 7. gx1 = J * tv1 # x1n + J * xd\n gx1 = Fp.mul(gx1, x1n); // 8. gx1 = gx1 * x1n # x1n^2 + J * x1n * xd\n gx1 = Fp.add(gx1, tv2); // 9. gx1 = gx1 + tv2 # x1n^2 + J * x1n * xd + xd^2\n gx1 = Fp.mul(gx1, x1n); // 10. gx1 = gx1 * x1n # x1n^3 + J * x1n^2 * xd + x1n * xd^2\n let tv3 = Fp.sqr(gxd); // 11. tv3 = gxd^2\n tv2 = Fp.sqr(tv3); // 12. tv2 = tv3^2 # gxd^4\n tv3 = Fp.mul(tv3, gxd); // 13. tv3 = tv3 * gxd # gxd^3\n tv3 = Fp.mul(tv3, gx1); // 14. tv3 = tv3 * gx1 # gx1 * gxd^3\n tv2 = Fp.mul(tv2, tv3); // 15. tv2 = tv2 * tv3 # gx1 * gxd^7\n let y11 = Fp.pow(tv2, ELL2_C4); // 16. y11 = tv2^c4 # (gx1 * gxd^7)^((p - 5) / 8)\n y11 = Fp.mul(y11, tv3); // 17. y11 = y11 * tv3 # gx1*gxd^3*(gx1*gxd^7)^((p-5)/8)\n let y12 = Fp.mul(y11, ELL2_C3); // 18. y12 = y11 * c3\n tv2 = Fp.sqr(y11); // 19. tv2 = y11^2\n tv2 = Fp.mul(tv2, gxd); // 20. tv2 = tv2 * gxd\n let e1 = Fp.eql(tv2, gx1); // 21. e1 = tv2 == gx1\n let y1 = Fp.cmov(y12, y11, e1); // 22. y1 = CMOV(y12, y11, e1) # If g(x1) is square, this is its sqrt\n let x2n = Fp.mul(x1n, tv1); // 23. x2n = x1n * tv1 # x2 = x2n / xd = 2 * u^2 * x1n / xd\n let y21 = Fp.mul(y11, u); // 24. y21 = y11 * u\n y21 = Fp.mul(y21, ELL2_C2); // 25. y21 = y21 * c2\n let y22 = Fp.mul(y21, ELL2_C3); // 26. y22 = y21 * c3\n let gx2 = Fp.mul(gx1, tv1); // 27. gx2 = gx1 * tv1 # g(x2) = gx2 / gxd = 2 * u^2 * g(x1)\n tv2 = Fp.sqr(y21); // 28. tv2 = y21^2\n tv2 = Fp.mul(tv2, gxd); // 29. tv2 = tv2 * gxd\n let e2 = Fp.eql(tv2, gx2); // 30. e2 = tv2 == gx2\n let y2 = Fp.cmov(y22, y21, e2); // 31. y2 = CMOV(y22, y21, e2) # If g(x2) is square, this is its sqrt\n tv2 = Fp.sqr(y1); // 32. tv2 = y1^2\n tv2 = Fp.mul(tv2, gxd); // 33. tv2 = tv2 * gxd\n let e3 = Fp.eql(tv2, gx1); // 34. e3 = tv2 == gx1\n let xn = Fp.cmov(x2n, x1n, e3); // 35. xn = CMOV(x2n, x1n, e3) # If e3, x = x1, else x = x2\n let y = Fp.cmov(y2, y1, e3); // 36. y = CMOV(y2, y1, e3) # If e3, y = y1, else y = y2\n let e4 = Fp.isOdd(y); // 37. e4 = sgn0(y) == 1 # Fix sign of y\n y = Fp.cmov(y, Fp.neg(y), e3 !== e4); // 38. y = CMOV(y, -y, e3 XOR e4)\n return { xMn: xn, xMd: xd, yMn: y, yMd: _1n }; // 39. return (xn, xd, y, 1)\n}\nconst ELL2_C1_EDWARDS = /* @__PURE__ */ (() => (0, modular_js_1.FpSqrtEven)(Fp, Fp.neg(BigInt(486664))))(); // sgn0(c1) MUST equal 0\nfunction map_to_curve_elligator2_edwards25519(u) {\n const { xMn, xMd, yMn, yMd } = map_to_curve_elligator2_curve25519(u); // 1. (xMn, xMd, yMn, yMd) =\n // map_to_curve_elligator2_curve25519(u)\n let xn = Fp.mul(xMn, yMd); // 2. xn = xMn * yMd\n xn = Fp.mul(xn, ELL2_C1_EDWARDS); // 3. xn = xn * c1\n let xd = Fp.mul(xMd, yMn); // 4. xd = xMd * yMn # xn / xd = c1 * xM / yM\n let yn = Fp.sub(xMn, xMd); // 5. yn = xMn - xMd\n let yd = Fp.add(xMn, xMd); // 6. yd = xMn + xMd # (n / d - 1) / (n / d + 1) = (n - d) / (n + d)\n let tv1 = Fp.mul(xd, yd); // 7. tv1 = xd * yd\n let e = Fp.eql(tv1, Fp.ZERO); // 8. e = tv1 == 0\n xn = Fp.cmov(xn, Fp.ZERO, e); // 9. xn = CMOV(xn, 0, e)\n xd = Fp.cmov(xd, Fp.ONE, e); // 10. xd = CMOV(xd, 1, e)\n yn = Fp.cmov(yn, Fp.ONE, e); // 11. yn = CMOV(yn, 1, e)\n yd = Fp.cmov(yd, Fp.ONE, e); // 12. yd = CMOV(yd, 1, e)\n const inv = Fp.invertBatch([xd, yd]); // batch division\n return { x: Fp.mul(xn, inv[0]), y: Fp.mul(yn, inv[1]) }; // 13. return (xn, xd, yn, yd)\n}\nconst htf = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.createHasher)(exports.ed25519.ExtendedPoint, (scalars) => map_to_curve_elligator2_edwards25519(scalars[0]), {\n DST: 'edwards25519_XMD:SHA-512_ELL2_RO_',\n encodeDST: 'edwards25519_XMD:SHA-512_ELL2_NU_',\n p: Fp.ORDER,\n m: 1,\n k: 128,\n expand: 'xmd',\n hash: sha512_1.sha512,\n}))();\nexports.hashToCurve = (() => htf.hashToCurve)();\nexports.encodeToCurve = (() => htf.encodeToCurve)();\nfunction assertRstPoint(other) {\n if (!(other instanceof RistPoint))\n throw new Error('RistrettoPoint expected');\n}\n// √(-1) aka √(a) aka 2^((p-1)/4)\nconst SQRT_M1 = ED25519_SQRT_M1;\n// √(ad - 1)\nconst SQRT_AD_MINUS_ONE = /* @__PURE__ */ BigInt('25063068953384623474111414158702152701244531502492656460079210482610430750235');\n// 1 / √(a-d)\nconst INVSQRT_A_MINUS_D = /* @__PURE__ */ BigInt('54469307008909316920995813868745141605393597292927456921205312896311721017578');\n// 1-d²\nconst ONE_MINUS_D_SQ = /* @__PURE__ */ BigInt('1159843021668779879193775521855586647937357759715417654439879720876111806838');\n// (d-1)²\nconst D_MINUS_ONE_SQ = /* @__PURE__ */ BigInt('40440834346308536858101042469323190826248399146238708352240133220865137265952');\n// Calculates 1/√(number)\nconst invertSqrt = (number) => uvRatio(_1n, number);\nconst MAX_255B = /* @__PURE__ */ BigInt('0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff');\nconst bytes255ToNumberLE = (bytes) => exports.ed25519.CURVE.Fp.create((0, utils_js_1.bytesToNumberLE)(bytes) & MAX_255B);\n// Computes Elligator map for Ristretto\n// https://ristretto.group/formulas/elligator.html\nfunction calcElligatorRistrettoMap(r0) {\n const { d } = exports.ed25519.CURVE;\n const P = exports.ed25519.CURVE.Fp.ORDER;\n const mod = exports.ed25519.CURVE.Fp.create;\n const r = mod(SQRT_M1 * r0 * r0); // 1\n const Ns = mod((r + _1n) * ONE_MINUS_D_SQ); // 2\n let c = BigInt(-1); // 3\n const D = mod((c - d * r) * mod(r + d)); // 4\n let { isValid: Ns_D_is_sq, value: s } = uvRatio(Ns, D); // 5\n let s_ = mod(s * r0); // 6\n if (!(0, modular_js_1.isNegativeLE)(s_, P))\n s_ = mod(-s_);\n if (!Ns_D_is_sq)\n s = s_; // 7\n if (!Ns_D_is_sq)\n c = r; // 8\n const Nt = mod(c * (r - _1n) * D_MINUS_ONE_SQ - D); // 9\n const s2 = s * s;\n const W0 = mod((s + s) * D); // 10\n const W1 = mod(Nt * SQRT_AD_MINUS_ONE); // 11\n const W2 = mod(_1n - s2); // 12\n const W3 = mod(_1n + s2); // 13\n return new exports.ed25519.ExtendedPoint(mod(W0 * W3), mod(W2 * W1), mod(W1 * W3), mod(W0 * W2));\n}\n/**\n * Each ed25519/ExtendedPoint has 8 different equivalent points. This can be\n * a source of bugs for protocols like ring signatures. Ristretto was created to solve this.\n * Ristretto point operates in X:Y:Z:T extended coordinates like ExtendedPoint,\n * but it should work in its own namespace: do not combine those two.\n * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-ristretto255-decaf448\n */\nclass RistPoint {\n // Private property to discourage combining ExtendedPoint + RistrettoPoint\n // Always use Ristretto encoding/decoding instead.\n constructor(ep) {\n this.ep = ep;\n }\n static fromAffine(ap) {\n return new RistPoint(exports.ed25519.ExtendedPoint.fromAffine(ap));\n }\n /**\n * Takes uniform output of 64-byte hash function like sha512 and converts it to `RistrettoPoint`.\n * The hash-to-group operation applies Elligator twice and adds the results.\n * **Note:** this is one-way map, there is no conversion from point to hash.\n * https://ristretto.group/formulas/elligator.html\n * @param hex 64-byte output of a hash function\n */\n static hashToCurve(hex) {\n hex = (0, utils_js_1.ensureBytes)('ristrettoHash', hex, 64);\n const r1 = bytes255ToNumberLE(hex.slice(0, 32));\n const R1 = calcElligatorRistrettoMap(r1);\n const r2 = bytes255ToNumberLE(hex.slice(32, 64));\n const R2 = calcElligatorRistrettoMap(r2);\n return new RistPoint(R1.add(R2));\n }\n /**\n * Converts ristretto-encoded string to ristretto point.\n * https://ristretto.group/formulas/decoding.html\n * @param hex Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding\n */\n static fromHex(hex) {\n hex = (0, utils_js_1.ensureBytes)('ristrettoHex', hex, 32);\n const { a, d } = exports.ed25519.CURVE;\n const P = exports.ed25519.CURVE.Fp.ORDER;\n const mod = exports.ed25519.CURVE.Fp.create;\n const emsg = 'RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint';\n const s = bytes255ToNumberLE(hex);\n // 1. Check that s_bytes is the canonical encoding of a field element, or else abort.\n // 3. Check that s is non-negative, or else abort\n if (!(0, utils_js_1.equalBytes)((0, utils_js_1.numberToBytesLE)(s, 32), hex) || (0, modular_js_1.isNegativeLE)(s, P))\n throw new Error(emsg);\n const s2 = mod(s * s);\n const u1 = mod(_1n + a * s2); // 4 (a is -1)\n const u2 = mod(_1n - a * s2); // 5\n const u1_2 = mod(u1 * u1);\n const u2_2 = mod(u2 * u2);\n const v = mod(a * d * u1_2 - u2_2); // 6\n const { isValid, value: I } = invertSqrt(mod(v * u2_2)); // 7\n const Dx = mod(I * u2); // 8\n const Dy = mod(I * Dx * v); // 9\n let x = mod((s + s) * Dx); // 10\n if ((0, modular_js_1.isNegativeLE)(x, P))\n x = mod(-x); // 10\n const y = mod(u1 * Dy); // 11\n const t = mod(x * y); // 12\n if (!isValid || (0, modular_js_1.isNegativeLE)(t, P) || y === _0n)\n throw new Error(emsg);\n return new RistPoint(new exports.ed25519.ExtendedPoint(x, y, _1n, t));\n }\n static msm(points, scalars) {\n const Fn = (0, modular_js_1.Field)(exports.ed25519.CURVE.n, exports.ed25519.CURVE.nBitLength);\n return (0, curve_js_1.pippenger)(RistPoint, Fn, points, scalars);\n }\n /**\n * Encodes ristretto point to Uint8Array.\n * https://ristretto.group/formulas/encoding.html\n */\n toRawBytes() {\n let { ex: x, ey: y, ez: z, et: t } = this.ep;\n const P = exports.ed25519.CURVE.Fp.ORDER;\n const mod = exports.ed25519.CURVE.Fp.create;\n const u1 = mod(mod(z + y) * mod(z - y)); // 1\n const u2 = mod(x * y); // 2\n // Square root always exists\n const u2sq = mod(u2 * u2);\n const { value: invsqrt } = invertSqrt(mod(u1 * u2sq)); // 3\n const D1 = mod(invsqrt * u1); // 4\n const D2 = mod(invsqrt * u2); // 5\n const zInv = mod(D1 * D2 * t); // 6\n let D; // 7\n if ((0, modular_js_1.isNegativeLE)(t * zInv, P)) {\n let _x = mod(y * SQRT_M1);\n let _y = mod(x * SQRT_M1);\n x = _x;\n y = _y;\n D = mod(D1 * INVSQRT_A_MINUS_D);\n }\n else {\n D = D2; // 8\n }\n if ((0, modular_js_1.isNegativeLE)(x * zInv, P))\n y = mod(-y); // 9\n let s = mod((z - y) * D); // 10 (check footer's note, no sqrt(-a))\n if ((0, modular_js_1.isNegativeLE)(s, P))\n s = mod(-s);\n return (0, utils_js_1.numberToBytesLE)(s, 32); // 11\n }\n toHex() {\n return (0, utils_js_1.bytesToHex)(this.toRawBytes());\n }\n toString() {\n return this.toHex();\n }\n // Compare one point to another.\n equals(other) {\n assertRstPoint(other);\n const { ex: X1, ey: Y1 } = this.ep;\n const { ex: X2, ey: Y2 } = other.ep;\n const mod = exports.ed25519.CURVE.Fp.create;\n // (x1 * y2 == y1 * x2) | (y1 * y2 == x1 * x2)\n const one = mod(X1 * Y2) === mod(Y1 * X2);\n const two = mod(Y1 * Y2) === mod(X1 * X2);\n return one || two;\n }\n add(other) {\n assertRstPoint(other);\n return new RistPoint(this.ep.add(other.ep));\n }\n subtract(other) {\n assertRstPoint(other);\n return new RistPoint(this.ep.subtract(other.ep));\n }\n multiply(scalar) {\n return new RistPoint(this.ep.multiply(scalar));\n }\n multiplyUnsafe(scalar) {\n return new RistPoint(this.ep.multiplyUnsafe(scalar));\n }\n double() {\n return new RistPoint(this.ep.double());\n }\n negate() {\n return new RistPoint(this.ep.negate());\n }\n}\nexports.RistrettoPoint = (() => {\n if (!RistPoint.BASE)\n RistPoint.BASE = new RistPoint(exports.ed25519.ExtendedPoint.BASE);\n if (!RistPoint.ZERO)\n RistPoint.ZERO = new RistPoint(exports.ed25519.ExtendedPoint.ZERO);\n return RistPoint;\n})();\n// Hashing to ristretto255. https://www.rfc-editor.org/rfc/rfc9380#appendix-B\nconst hashToRistretto255 = (msg, options) => {\n const d = options.DST;\n const DST = typeof d === 'string' ? (0, utils_1.utf8ToBytes)(d) : d;\n const uniform_bytes = (0, hash_to_curve_js_1.expand_message_xmd)(msg, DST, 64, sha512_1.sha512);\n const P = RistPoint.hashToCurve(uniform_bytes);\n return P;\n};\nexports.hashToRistretto255 = hashToRistretto255;\nexports.hash_to_ristretto255 = exports.hashToRistretto255; // legacy\n//# sourceMappingURL=ed25519.js.map","/**\n * ed25519 Twisted Edwards curve with following addons:\n * - X25519 ECDH\n * - Ristretto cofactor elimination\n * - Elligator hash-to-group / point indistinguishability\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nimport { sha512 } from '@noble/hashes/sha512';\nimport { concatBytes, randomBytes, utf8ToBytes } from '@noble/hashes/utils';\nimport { type AffinePoint, type Group, pippenger } from './abstract/curve.js';\nimport { type CurveFn, type ExtPointType, twistedEdwards } from './abstract/edwards.js';\nimport {\n createHasher,\n expand_message_xmd,\n type htfBasicOpts,\n type HTFMethod,\n} from './abstract/hash-to-curve.js';\nimport { Field, FpSqrtEven, isNegativeLE, mod, pow2 } from './abstract/modular.js';\nimport { montgomery, type CurveFn as XCurveFn } from './abstract/montgomery.js';\nimport {\n bytesToHex,\n bytesToNumberLE,\n ensureBytes,\n equalBytes,\n type Hex,\n numberToBytesLE,\n} from './abstract/utils.js';\n\nconst ED25519_P = BigInt(\n '57896044618658097711785492504343953926634992332820282019728792003956564819949'\n);\n// √(-1) aka √(a) aka 2^((p-1)/4)\nconst ED25519_SQRT_M1 = /* @__PURE__ */ BigInt(\n '19681161376707505956807079304988542015446066515923890162744021073123829784752'\n);\n\n// prettier-ignore\nconst _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3);\n// prettier-ignore\nconst _5n = BigInt(5), _8n = BigInt(8);\n\nfunction ed25519_pow_2_252_3(x: bigint) {\n // prettier-ignore\n const _10n = BigInt(10), _20n = BigInt(20), _40n = BigInt(40), _80n = BigInt(80);\n const P = ED25519_P;\n const x2 = (x * x) % P;\n const b2 = (x2 * x) % P; // x^3, 11\n const b4 = (pow2(b2, _2n, P) * b2) % P; // x^15, 1111\n const b5 = (pow2(b4, _1n, P) * x) % P; // x^31\n const b10 = (pow2(b5, _5n, P) * b5) % P;\n const b20 = (pow2(b10, _10n, P) * b10) % P;\n const b40 = (pow2(b20, _20n, P) * b20) % P;\n const b80 = (pow2(b40, _40n, P) * b40) % P;\n const b160 = (pow2(b80, _80n, P) * b80) % P;\n const b240 = (pow2(b160, _80n, P) * b80) % P;\n const b250 = (pow2(b240, _10n, P) * b10) % P;\n const pow_p_5_8 = (pow2(b250, _2n, P) * x) % P;\n // ^ To pow to (p+3)/8, multiply it by x.\n return { pow_p_5_8, b2 };\n}\n\nfunction adjustScalarBytes(bytes: Uint8Array): Uint8Array {\n // Section 5: For X25519, in order to decode 32 random bytes as an integer scalar,\n // set the three least significant bits of the first byte\n bytes[0] &= 248; // 0b1111_1000\n // and the most significant bit of the last to zero,\n bytes[31] &= 127; // 0b0111_1111\n // set the second most significant bit of the last byte to 1\n bytes[31] |= 64; // 0b0100_0000\n return bytes;\n}\n\n// sqrt(u/v)\nfunction uvRatio(u: bigint, v: bigint): { isValid: boolean; value: bigint } {\n const P = ED25519_P;\n const v3 = mod(v * v * v, P); // v³\n const v7 = mod(v3 * v3 * v, P); // v⁷\n // (p+3)/8 and (p-5)/8\n const pow = ed25519_pow_2_252_3(u * v7).pow_p_5_8;\n let x = mod(u * v3 * pow, P); // (uv³)(uv⁷)^(p-5)/8\n const vx2 = mod(v * x * x, P); // vx²\n const root1 = x; // First root candidate\n const root2 = mod(x * ED25519_SQRT_M1, P); // Second root candidate\n const useRoot1 = vx2 === u; // If vx² = u (mod p), x is a square root\n const useRoot2 = vx2 === mod(-u, P); // If vx² = -u, set x <-- x * 2^((p-1)/4)\n const noRoot = vx2 === mod(-u * ED25519_SQRT_M1, P); // There is no valid root, vx² = -u√(-1)\n if (useRoot1) x = root1;\n if (useRoot2 || noRoot) x = root2; // We return root2 anyway, for const-time\n if (isNegativeLE(x, P)) x = mod(-x, P);\n return { isValid: useRoot1 || useRoot2, value: x };\n}\n\n// Just in case\nexport const ED25519_TORSION_SUBGROUP: string[] = [\n '0100000000000000000000000000000000000000000000000000000000000000',\n 'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a',\n '0000000000000000000000000000000000000000000000000000000000000080',\n '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05',\n 'ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f',\n '26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85',\n '0000000000000000000000000000000000000000000000000000000000000000',\n 'c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa',\n];\n\nconst Fp = /* @__PURE__ */ (() => Field(ED25519_P, undefined, true))();\n\nconst ed25519Defaults = /* @__PURE__ */ (() =>\n ({\n // Param: a\n a: BigInt(-1), // Fp.create(-1) is proper; our way still works and is faster\n // d is equal to -121665/121666 over finite field.\n // Negative number is P - number, and division is invert(number, P)\n d: BigInt('37095705934669439343138083508754565189542113879843219016388785533085940283555'),\n // Finite field 𝔽p over which we'll do calculations; 2n**255n - 19n\n Fp,\n // Subgroup order: how many points curve has\n // 2n**252n + 27742317777372353535851937790883648493n;\n n: BigInt('7237005577332262213973186563042994240857116359379907606001950938285454250989'),\n // Cofactor\n h: _8n,\n // Base point (x, y) aka generator point\n Gx: BigInt('15112221349535400772501151409588531511454012693041857206046113283949847762202'),\n Gy: BigInt('46316835694926478169428394003475163141307993866256225615783033603165251855960'),\n hash: sha512,\n randomBytes,\n adjustScalarBytes,\n // dom2\n // Ratio of u to v. Allows us to combine inversion and square root. Uses algo from RFC8032 5.1.3.\n // Constant-time, u/√v\n uvRatio,\n }) as const)();\n\n/**\n * ed25519 curve with EdDSA signatures.\n * @example\n * import { ed25519 } from '@noble/curves/ed25519';\n * const priv = ed25519.utils.randomPrivateKey();\n * const pub = ed25519.getPublicKey(priv);\n * const msg = new TextEncoder().encode('hello');\n * const sig = ed25519.sign(msg, priv);\n * ed25519.verify(sig, msg, pub); // Default mode: follows ZIP215\n * ed25519.verify(sig, msg, pub, { zip215: false }); // RFC8032 / FIPS 186-5\n */\nexport const ed25519: CurveFn = /* @__PURE__ */ (() => twistedEdwards(ed25519Defaults))();\n\nfunction ed25519_domain(data: Uint8Array, ctx: Uint8Array, phflag: boolean) {\n if (ctx.length > 255) throw new Error('Context is too big');\n return concatBytes(\n utf8ToBytes('SigEd25519 no Ed25519 collisions'),\n new Uint8Array([phflag ? 1 : 0, ctx.length]),\n ctx,\n data\n );\n}\n\nexport const ed25519ctx: CurveFn = /* @__PURE__ */ (() =>\n twistedEdwards({\n ...ed25519Defaults,\n domain: ed25519_domain,\n }))();\nexport const ed25519ph: CurveFn = /* @__PURE__ */ (() =>\n twistedEdwards(\n Object.assign({}, ed25519Defaults, {\n domain: ed25519_domain,\n prehash: sha512,\n })\n ))();\n\n/**\n * ECDH using curve25519 aka x25519.\n * @example\n * import { x25519 } from '@noble/curves/ed25519';\n * const priv = 'a546e36bf0527c9d3b16154b82465edd62144c0ac1fc5a18506a2244ba449ac4';\n * const pub = 'e6db6867583030db3594c1a424b15f7c726624ec26b3353b10a903a6d0ab1c4c';\n * x25519.getSharedSecret(priv, pub) === x25519.scalarMult(priv, pub); // aliases\n * x25519.getPublicKey(priv) === x25519.scalarMultBase(priv);\n * x25519.getPublicKey(x25519.utils.randomPrivateKey());\n */\nexport const x25519: XCurveFn = /* @__PURE__ */ (() =>\n montgomery({\n P: ED25519_P,\n a: BigInt(486662),\n montgomeryBits: 255, // n is 253 bits\n nByteLength: 32,\n Gu: BigInt(9),\n powPminus2: (x: bigint): bigint => {\n const P = ED25519_P;\n // x^(p-2) aka x^(2^255-21)\n const { pow_p_5_8, b2 } = ed25519_pow_2_252_3(x);\n return mod(pow2(pow_p_5_8, _3n, P) * b2, P);\n },\n adjustScalarBytes,\n randomBytes,\n }))();\n\n/**\n * Converts ed25519 public key to x25519 public key. Uses formula:\n * * `(u, v) = ((1+y)/(1-y), sqrt(-486664)*u/x)`\n * * `(x, y) = (sqrt(-486664)*u/v, (u-1)/(u+1))`\n * @example\n * const someonesPub = ed25519.getPublicKey(ed25519.utils.randomPrivateKey());\n * const aPriv = x25519.utils.randomPrivateKey();\n * x25519.getSharedSecret(aPriv, edwardsToMontgomeryPub(someonesPub))\n */\nexport function edwardsToMontgomeryPub(edwardsPub: Hex): Uint8Array {\n const { y } = ed25519.ExtendedPoint.fromHex(edwardsPub);\n const _1n = BigInt(1);\n return Fp.toBytes(Fp.create((_1n + y) * Fp.inv(_1n - y)));\n}\nexport const edwardsToMontgomery: typeof edwardsToMontgomeryPub = edwardsToMontgomeryPub; // deprecated\n\n/**\n * Converts ed25519 secret key to x25519 secret key.\n * @example\n * const someonesPub = x25519.getPublicKey(x25519.utils.randomPrivateKey());\n * const aPriv = ed25519.utils.randomPrivateKey();\n * x25519.getSharedSecret(edwardsToMontgomeryPriv(aPriv), someonesPub)\n */\nexport function edwardsToMontgomeryPriv(edwardsPriv: Uint8Array): Uint8Array {\n const hashed = ed25519Defaults.hash(edwardsPriv.subarray(0, 32));\n return ed25519Defaults.adjustScalarBytes(hashed).subarray(0, 32);\n}\n\n// Hash To Curve Elligator2 Map (NOTE: different from ristretto255 elligator)\n// NOTE: very important part is usage of FpSqrtEven for ELL2_C1_EDWARDS, since\n// SageMath returns different root first and everything falls apart\n\nconst ELL2_C1 = /* @__PURE__ */ (() => (Fp.ORDER + _3n) / _8n)(); // 1. c1 = (q + 3) / 8 # Integer arithmetic\nconst ELL2_C2 = /* @__PURE__ */ (() => Fp.pow(_2n, ELL2_C1))(); // 2. c2 = 2^c1\nconst ELL2_C3 = /* @__PURE__ */ (() => Fp.sqrt(Fp.neg(Fp.ONE)))(); // 3. c3 = sqrt(-1)\n\n// prettier-ignore\nfunction map_to_curve_elligator2_curve25519(u: bigint) {\n const ELL2_C4 = (Fp.ORDER - _5n) / _8n; // 4. c4 = (q - 5) / 8 # Integer arithmetic\n const ELL2_J = BigInt(486662);\n\n let tv1 = Fp.sqr(u); // 1. tv1 = u^2\n tv1 = Fp.mul(tv1, _2n); // 2. tv1 = 2 * tv1\n let xd = Fp.add(tv1, Fp.ONE); // 3. xd = tv1 + 1 # Nonzero: -1 is square (mod p), tv1 is not\n let x1n = Fp.neg(ELL2_J); // 4. x1n = -J # x1 = x1n / xd = -J / (1 + 2 * u^2)\n let tv2 = Fp.sqr(xd); // 5. tv2 = xd^2\n let gxd = Fp.mul(tv2, xd); // 6. gxd = tv2 * xd # gxd = xd^3\n let gx1 = Fp.mul(tv1, ELL2_J);// 7. gx1 = J * tv1 # x1n + J * xd\n gx1 = Fp.mul(gx1, x1n); // 8. gx1 = gx1 * x1n # x1n^2 + J * x1n * xd\n gx1 = Fp.add(gx1, tv2); // 9. gx1 = gx1 + tv2 # x1n^2 + J * x1n * xd + xd^2\n gx1 = Fp.mul(gx1, x1n); // 10. gx1 = gx1 * x1n # x1n^3 + J * x1n^2 * xd + x1n * xd^2\n let tv3 = Fp.sqr(gxd); // 11. tv3 = gxd^2\n tv2 = Fp.sqr(tv3); // 12. tv2 = tv3^2 # gxd^4\n tv3 = Fp.mul(tv3, gxd); // 13. tv3 = tv3 * gxd # gxd^3\n tv3 = Fp.mul(tv3, gx1); // 14. tv3 = tv3 * gx1 # gx1 * gxd^3\n tv2 = Fp.mul(tv2, tv3); // 15. tv2 = tv2 * tv3 # gx1 * gxd^7\n let y11 = Fp.pow(tv2, ELL2_C4); // 16. y11 = tv2^c4 # (gx1 * gxd^7)^((p - 5) / 8)\n y11 = Fp.mul(y11, tv3); // 17. y11 = y11 * tv3 # gx1*gxd^3*(gx1*gxd^7)^((p-5)/8)\n let y12 = Fp.mul(y11, ELL2_C3); // 18. y12 = y11 * c3\n tv2 = Fp.sqr(y11); // 19. tv2 = y11^2\n tv2 = Fp.mul(tv2, gxd); // 20. tv2 = tv2 * gxd\n let e1 = Fp.eql(tv2, gx1); // 21. e1 = tv2 == gx1\n let y1 = Fp.cmov(y12, y11, e1); // 22. y1 = CMOV(y12, y11, e1) # If g(x1) is square, this is its sqrt\n let x2n = Fp.mul(x1n, tv1); // 23. x2n = x1n * tv1 # x2 = x2n / xd = 2 * u^2 * x1n / xd\n let y21 = Fp.mul(y11, u); // 24. y21 = y11 * u\n y21 = Fp.mul(y21, ELL2_C2); // 25. y21 = y21 * c2\n let y22 = Fp.mul(y21, ELL2_C3); // 26. y22 = y21 * c3\n let gx2 = Fp.mul(gx1, tv1); // 27. gx2 = gx1 * tv1 # g(x2) = gx2 / gxd = 2 * u^2 * g(x1)\n tv2 = Fp.sqr(y21); // 28. tv2 = y21^2\n tv2 = Fp.mul(tv2, gxd); // 29. tv2 = tv2 * gxd\n let e2 = Fp.eql(tv2, gx2); // 30. e2 = tv2 == gx2\n let y2 = Fp.cmov(y22, y21, e2); // 31. y2 = CMOV(y22, y21, e2) # If g(x2) is square, this is its sqrt\n tv2 = Fp.sqr(y1); // 32. tv2 = y1^2\n tv2 = Fp.mul(tv2, gxd); // 33. tv2 = tv2 * gxd\n let e3 = Fp.eql(tv2, gx1); // 34. e3 = tv2 == gx1\n let xn = Fp.cmov(x2n, x1n, e3); // 35. xn = CMOV(x2n, x1n, e3) # If e3, x = x1, else x = x2\n let y = Fp.cmov(y2, y1, e3); // 36. y = CMOV(y2, y1, e3) # If e3, y = y1, else y = y2\n let e4 = Fp.isOdd(y); // 37. e4 = sgn0(y) == 1 # Fix sign of y\n y = Fp.cmov(y, Fp.neg(y), e3 !== e4); // 38. y = CMOV(y, -y, e3 XOR e4)\n return { xMn: xn, xMd: xd, yMn: y, yMd: _1n }; // 39. return (xn, xd, y, 1)\n}\n\nconst ELL2_C1_EDWARDS = /* @__PURE__ */ (() => FpSqrtEven(Fp, Fp.neg(BigInt(486664))))(); // sgn0(c1) MUST equal 0\nfunction map_to_curve_elligator2_edwards25519(u: bigint) {\n const { xMn, xMd, yMn, yMd } = map_to_curve_elligator2_curve25519(u); // 1. (xMn, xMd, yMn, yMd) =\n // map_to_curve_elligator2_curve25519(u)\n let xn = Fp.mul(xMn, yMd); // 2. xn = xMn * yMd\n xn = Fp.mul(xn, ELL2_C1_EDWARDS); // 3. xn = xn * c1\n let xd = Fp.mul(xMd, yMn); // 4. xd = xMd * yMn # xn / xd = c1 * xM / yM\n let yn = Fp.sub(xMn, xMd); // 5. yn = xMn - xMd\n let yd = Fp.add(xMn, xMd); // 6. yd = xMn + xMd # (n / d - 1) / (n / d + 1) = (n - d) / (n + d)\n let tv1 = Fp.mul(xd, yd); // 7. tv1 = xd * yd\n let e = Fp.eql(tv1, Fp.ZERO); // 8. e = tv1 == 0\n xn = Fp.cmov(xn, Fp.ZERO, e); // 9. xn = CMOV(xn, 0, e)\n xd = Fp.cmov(xd, Fp.ONE, e); // 10. xd = CMOV(xd, 1, e)\n yn = Fp.cmov(yn, Fp.ONE, e); // 11. yn = CMOV(yn, 1, e)\n yd = Fp.cmov(yd, Fp.ONE, e); // 12. yd = CMOV(yd, 1, e)\n\n const inv = Fp.invertBatch([xd, yd]); // batch division\n return { x: Fp.mul(xn, inv[0]), y: Fp.mul(yn, inv[1]) }; // 13. return (xn, xd, yn, yd)\n}\n\nconst htf = /* @__PURE__ */ (() =>\n createHasher(\n ed25519.ExtendedPoint,\n (scalars: bigint[]) => map_to_curve_elligator2_edwards25519(scalars[0]),\n {\n DST: 'edwards25519_XMD:SHA-512_ELL2_RO_',\n encodeDST: 'edwards25519_XMD:SHA-512_ELL2_NU_',\n p: Fp.ORDER,\n m: 1,\n k: 128,\n expand: 'xmd',\n hash: sha512,\n }\n ))();\nexport const hashToCurve: HTFMethod = /* @__PURE__ */ (() => htf.hashToCurve)();\nexport const encodeToCurve: HTFMethod = /* @__PURE__ */ (() => htf.encodeToCurve)();\n\nfunction assertRstPoint(other: unknown) {\n if (!(other instanceof RistPoint)) throw new Error('RistrettoPoint expected');\n}\n\n// √(-1) aka √(a) aka 2^((p-1)/4)\nconst SQRT_M1 = ED25519_SQRT_M1;\n// √(ad - 1)\nconst SQRT_AD_MINUS_ONE = /* @__PURE__ */ BigInt(\n '25063068953384623474111414158702152701244531502492656460079210482610430750235'\n);\n// 1 / √(a-d)\nconst INVSQRT_A_MINUS_D = /* @__PURE__ */ BigInt(\n '54469307008909316920995813868745141605393597292927456921205312896311721017578'\n);\n// 1-d²\nconst ONE_MINUS_D_SQ = /* @__PURE__ */ BigInt(\n '1159843021668779879193775521855586647937357759715417654439879720876111806838'\n);\n// (d-1)²\nconst D_MINUS_ONE_SQ = /* @__PURE__ */ BigInt(\n '40440834346308536858101042469323190826248399146238708352240133220865137265952'\n);\n// Calculates 1/√(number)\nconst invertSqrt = (number: bigint) => uvRatio(_1n, number);\n\nconst MAX_255B = /* @__PURE__ */ BigInt(\n '0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'\n);\nconst bytes255ToNumberLE = (bytes: Uint8Array) =>\n ed25519.CURVE.Fp.create(bytesToNumberLE(bytes) & MAX_255B);\n\ntype ExtendedPoint = ExtPointType;\n\n// Computes Elligator map for Ristretto\n// https://ristretto.group/formulas/elligator.html\nfunction calcElligatorRistrettoMap(r0: bigint): ExtendedPoint {\n const { d } = ed25519.CURVE;\n const P = ed25519.CURVE.Fp.ORDER;\n const mod = ed25519.CURVE.Fp.create;\n const r = mod(SQRT_M1 * r0 * r0); // 1\n const Ns = mod((r + _1n) * ONE_MINUS_D_SQ); // 2\n let c = BigInt(-1); // 3\n const D = mod((c - d * r) * mod(r + d)); // 4\n let { isValid: Ns_D_is_sq, value: s } = uvRatio(Ns, D); // 5\n let s_ = mod(s * r0); // 6\n if (!isNegativeLE(s_, P)) s_ = mod(-s_);\n if (!Ns_D_is_sq) s = s_; // 7\n if (!Ns_D_is_sq) c = r; // 8\n const Nt = mod(c * (r - _1n) * D_MINUS_ONE_SQ - D); // 9\n const s2 = s * s;\n const W0 = mod((s + s) * D); // 10\n const W1 = mod(Nt * SQRT_AD_MINUS_ONE); // 11\n const W2 = mod(_1n - s2); // 12\n const W3 = mod(_1n + s2); // 13\n return new ed25519.ExtendedPoint(mod(W0 * W3), mod(W2 * W1), mod(W1 * W3), mod(W0 * W2));\n}\n\n/**\n * Each ed25519/ExtendedPoint has 8 different equivalent points. This can be\n * a source of bugs for protocols like ring signatures. Ristretto was created to solve this.\n * Ristretto point operates in X:Y:Z:T extended coordinates like ExtendedPoint,\n * but it should work in its own namespace: do not combine those two.\n * https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-ristretto255-decaf448\n */\nclass RistPoint implements Group {\n static BASE: RistPoint;\n static ZERO: RistPoint;\n // Private property to discourage combining ExtendedPoint + RistrettoPoint\n // Always use Ristretto encoding/decoding instead.\n constructor(private readonly ep: ExtendedPoint) {}\n\n static fromAffine(ap: AffinePoint): RistPoint {\n return new RistPoint(ed25519.ExtendedPoint.fromAffine(ap));\n }\n\n /**\n * Takes uniform output of 64-byte hash function like sha512 and converts it to `RistrettoPoint`.\n * The hash-to-group operation applies Elligator twice and adds the results.\n * **Note:** this is one-way map, there is no conversion from point to hash.\n * https://ristretto.group/formulas/elligator.html\n * @param hex 64-byte output of a hash function\n */\n static hashToCurve(hex: Hex): RistPoint {\n hex = ensureBytes('ristrettoHash', hex, 64);\n const r1 = bytes255ToNumberLE(hex.slice(0, 32));\n const R1 = calcElligatorRistrettoMap(r1);\n const r2 = bytes255ToNumberLE(hex.slice(32, 64));\n const R2 = calcElligatorRistrettoMap(r2);\n return new RistPoint(R1.add(R2));\n }\n\n /**\n * Converts ristretto-encoded string to ristretto point.\n * https://ristretto.group/formulas/decoding.html\n * @param hex Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding\n */\n static fromHex(hex: Hex): RistPoint {\n hex = ensureBytes('ristrettoHex', hex, 32);\n const { a, d } = ed25519.CURVE;\n const P = ed25519.CURVE.Fp.ORDER;\n const mod = ed25519.CURVE.Fp.create;\n const emsg = 'RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint';\n const s = bytes255ToNumberLE(hex);\n // 1. Check that s_bytes is the canonical encoding of a field element, or else abort.\n // 3. Check that s is non-negative, or else abort\n if (!equalBytes(numberToBytesLE(s, 32), hex) || isNegativeLE(s, P)) throw new Error(emsg);\n const s2 = mod(s * s);\n const u1 = mod(_1n + a * s2); // 4 (a is -1)\n const u2 = mod(_1n - a * s2); // 5\n const u1_2 = mod(u1 * u1);\n const u2_2 = mod(u2 * u2);\n const v = mod(a * d * u1_2 - u2_2); // 6\n const { isValid, value: I } = invertSqrt(mod(v * u2_2)); // 7\n const Dx = mod(I * u2); // 8\n const Dy = mod(I * Dx * v); // 9\n let x = mod((s + s) * Dx); // 10\n if (isNegativeLE(x, P)) x = mod(-x); // 10\n const y = mod(u1 * Dy); // 11\n const t = mod(x * y); // 12\n if (!isValid || isNegativeLE(t, P) || y === _0n) throw new Error(emsg);\n return new RistPoint(new ed25519.ExtendedPoint(x, y, _1n, t));\n }\n\n static msm(points: RistPoint[], scalars: bigint[]): RistPoint {\n const Fn = Field(ed25519.CURVE.n, ed25519.CURVE.nBitLength);\n return pippenger(RistPoint, Fn, points, scalars);\n }\n\n /**\n * Encodes ristretto point to Uint8Array.\n * https://ristretto.group/formulas/encoding.html\n */\n toRawBytes(): Uint8Array {\n let { ex: x, ey: y, ez: z, et: t } = this.ep;\n const P = ed25519.CURVE.Fp.ORDER;\n const mod = ed25519.CURVE.Fp.create;\n const u1 = mod(mod(z + y) * mod(z - y)); // 1\n const u2 = mod(x * y); // 2\n // Square root always exists\n const u2sq = mod(u2 * u2);\n const { value: invsqrt } = invertSqrt(mod(u1 * u2sq)); // 3\n const D1 = mod(invsqrt * u1); // 4\n const D2 = mod(invsqrt * u2); // 5\n const zInv = mod(D1 * D2 * t); // 6\n let D: bigint; // 7\n if (isNegativeLE(t * zInv, P)) {\n let _x = mod(y * SQRT_M1);\n let _y = mod(x * SQRT_M1);\n x = _x;\n y = _y;\n D = mod(D1 * INVSQRT_A_MINUS_D);\n } else {\n D = D2; // 8\n }\n if (isNegativeLE(x * zInv, P)) y = mod(-y); // 9\n let s = mod((z - y) * D); // 10 (check footer's note, no sqrt(-a))\n if (isNegativeLE(s, P)) s = mod(-s);\n return numberToBytesLE(s, 32); // 11\n }\n\n toHex(): string {\n return bytesToHex(this.toRawBytes());\n }\n\n toString(): string {\n return this.toHex();\n }\n\n // Compare one point to another.\n equals(other: RistPoint): boolean {\n assertRstPoint(other);\n const { ex: X1, ey: Y1 } = this.ep;\n const { ex: X2, ey: Y2 } = other.ep;\n const mod = ed25519.CURVE.Fp.create;\n // (x1 * y2 == y1 * x2) | (y1 * y2 == x1 * x2)\n const one = mod(X1 * Y2) === mod(Y1 * X2);\n const two = mod(Y1 * Y2) === mod(X1 * X2);\n return one || two;\n }\n\n add(other: RistPoint): RistPoint {\n assertRstPoint(other);\n return new RistPoint(this.ep.add(other.ep));\n }\n\n subtract(other: RistPoint): RistPoint {\n assertRstPoint(other);\n return new RistPoint(this.ep.subtract(other.ep));\n }\n\n multiply(scalar: bigint): RistPoint {\n return new RistPoint(this.ep.multiply(scalar));\n }\n\n multiplyUnsafe(scalar: bigint): RistPoint {\n return new RistPoint(this.ep.multiplyUnsafe(scalar));\n }\n\n double(): RistPoint {\n return new RistPoint(this.ep.double());\n }\n\n negate(): RistPoint {\n return new RistPoint(this.ep.negate());\n }\n}\nexport const RistrettoPoint: typeof RistPoint = /* @__PURE__ */ (() => {\n if (!RistPoint.BASE) RistPoint.BASE = new RistPoint(ed25519.ExtendedPoint.BASE);\n if (!RistPoint.ZERO) RistPoint.ZERO = new RistPoint(ed25519.ExtendedPoint.ZERO);\n return RistPoint;\n})();\n\n// Hashing to ristretto255. https://www.rfc-editor.org/rfc/rfc9380#appendix-B\nexport const hashToRistretto255 = (msg: Uint8Array, options: htfBasicOpts): RistPoint => {\n const d = options.DST;\n const DST = typeof d === 'string' ? utf8ToBytes(d) : d;\n const uniform_bytes = expand_message_xmd(msg, DST, 64, sha512);\n const P = RistPoint.hashToCurve(uniform_bytes);\n return P;\n};\nexport const hash_to_ristretto255: (msg: Uint8Array, options: htfBasicOpts) => RistPoint =\n hashToRistretto255; // legacy\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.sha384 = exports.sha512_256 = exports.sha512_224 = exports.sha512 = exports.SHA384 = exports.SHA512_256 = exports.SHA512_224 = exports.SHA512 = void 0;\n/**\n * SHA2-512 a.k.a. sha512 and sha384. It is slower than sha256 in js because u64 operations are slow.\n *\n * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and\n * [the paper on truncated SHA512/256](https://eprint.iacr.org/2010/548.pdf).\n * @module\n */\nconst _md_js_1 = require(\"./_md.js\");\nconst _u64_js_1 = require(\"./_u64.js\");\nconst utils_js_1 = require(\"./utils.js\");\n// Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409):\n// prettier-ignore\nconst [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => _u64_js_1.default.split([\n '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',\n '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',\n '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',\n '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694',\n '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65',\n '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5',\n '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4',\n '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70',\n '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df',\n '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b',\n '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30',\n '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8',\n '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8',\n '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3',\n '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec',\n '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b',\n '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178',\n '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b',\n '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c',\n '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'\n].map(n => BigInt(n))))();\n// Temporary buffer, not used to store anything between runs\nconst SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);\nconst SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);\nclass SHA512 extends _md_js_1.HashMD {\n constructor() {\n super(128, 64, 16, false);\n // We cannot use array here since array allows indexing by variable which means optimizer/compiler cannot use registers.\n // Also looks cleaner and easier to verify with spec.\n // Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0x6a09e667 | 0;\n this.Al = 0xf3bcc908 | 0;\n this.Bh = 0xbb67ae85 | 0;\n this.Bl = 0x84caa73b | 0;\n this.Ch = 0x3c6ef372 | 0;\n this.Cl = 0xfe94f82b | 0;\n this.Dh = 0xa54ff53a | 0;\n this.Dl = 0x5f1d36f1 | 0;\n this.Eh = 0x510e527f | 0;\n this.El = 0xade682d1 | 0;\n this.Fh = 0x9b05688c | 0;\n this.Fl = 0x2b3e6c1f | 0;\n this.Gh = 0x1f83d9ab | 0;\n this.Gl = 0xfb41bd6b | 0;\n this.Hh = 0x5be0cd19 | 0;\n this.Hl = 0x137e2179 | 0;\n }\n // prettier-ignore\n get() {\n const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];\n }\n // prettier-ignore\n set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {\n this.Ah = Ah | 0;\n this.Al = Al | 0;\n this.Bh = Bh | 0;\n this.Bl = Bl | 0;\n this.Ch = Ch | 0;\n this.Cl = Cl | 0;\n this.Dh = Dh | 0;\n this.Dl = Dl | 0;\n this.Eh = Eh | 0;\n this.El = El | 0;\n this.Fh = Fh | 0;\n this.Fl = Fl | 0;\n this.Gh = Gh | 0;\n this.Gl = Gl | 0;\n this.Hh = Hh | 0;\n this.Hl = Hl | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) {\n SHA512_W_H[i] = view.getUint32(offset);\n SHA512_W_L[i] = view.getUint32((offset += 4));\n }\n for (let i = 16; i < 80; i++) {\n // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)\n const W15h = SHA512_W_H[i - 15] | 0;\n const W15l = SHA512_W_L[i - 15] | 0;\n const s0h = _u64_js_1.default.rotrSH(W15h, W15l, 1) ^ _u64_js_1.default.rotrSH(W15h, W15l, 8) ^ _u64_js_1.default.shrSH(W15h, W15l, 7);\n const s0l = _u64_js_1.default.rotrSL(W15h, W15l, 1) ^ _u64_js_1.default.rotrSL(W15h, W15l, 8) ^ _u64_js_1.default.shrSL(W15h, W15l, 7);\n // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)\n const W2h = SHA512_W_H[i - 2] | 0;\n const W2l = SHA512_W_L[i - 2] | 0;\n const s1h = _u64_js_1.default.rotrSH(W2h, W2l, 19) ^ _u64_js_1.default.rotrBH(W2h, W2l, 61) ^ _u64_js_1.default.shrSH(W2h, W2l, 6);\n const s1l = _u64_js_1.default.rotrSL(W2h, W2l, 19) ^ _u64_js_1.default.rotrBL(W2h, W2l, 61) ^ _u64_js_1.default.shrSL(W2h, W2l, 6);\n // SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];\n const SUMl = _u64_js_1.default.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);\n const SUMh = _u64_js_1.default.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);\n SHA512_W_H[i] = SUMh | 0;\n SHA512_W_L[i] = SUMl | 0;\n }\n let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n // Compression function main loop, 80 rounds\n for (let i = 0; i < 80; i++) {\n // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)\n const sigma1h = _u64_js_1.default.rotrSH(Eh, El, 14) ^ _u64_js_1.default.rotrSH(Eh, El, 18) ^ _u64_js_1.default.rotrBH(Eh, El, 41);\n const sigma1l = _u64_js_1.default.rotrSL(Eh, El, 14) ^ _u64_js_1.default.rotrSL(Eh, El, 18) ^ _u64_js_1.default.rotrBL(Eh, El, 41);\n //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const CHIh = (Eh & Fh) ^ (~Eh & Gh);\n const CHIl = (El & Fl) ^ (~El & Gl);\n // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]\n // prettier-ignore\n const T1ll = _u64_js_1.default.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);\n const T1h = _u64_js_1.default.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);\n const T1l = T1ll | 0;\n // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)\n const sigma0h = _u64_js_1.default.rotrSH(Ah, Al, 28) ^ _u64_js_1.default.rotrBH(Ah, Al, 34) ^ _u64_js_1.default.rotrBH(Ah, Al, 39);\n const sigma0l = _u64_js_1.default.rotrSL(Ah, Al, 28) ^ _u64_js_1.default.rotrBL(Ah, Al, 34) ^ _u64_js_1.default.rotrBL(Ah, Al, 39);\n const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);\n const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);\n Hh = Gh | 0;\n Hl = Gl | 0;\n Gh = Fh | 0;\n Gl = Fl | 0;\n Fh = Eh | 0;\n Fl = El | 0;\n ({ h: Eh, l: El } = _u64_js_1.default.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));\n Dh = Ch | 0;\n Dl = Cl | 0;\n Ch = Bh | 0;\n Cl = Bl | 0;\n Bh = Ah | 0;\n Bl = Al | 0;\n const All = _u64_js_1.default.add3L(T1l, sigma0l, MAJl);\n Ah = _u64_js_1.default.add3H(All, T1h, sigma0h, MAJh);\n Al = All | 0;\n }\n // Add the compressed chunk to the current hash value\n ({ h: Ah, l: Al } = _u64_js_1.default.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));\n ({ h: Bh, l: Bl } = _u64_js_1.default.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));\n ({ h: Ch, l: Cl } = _u64_js_1.default.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));\n ({ h: Dh, l: Dl } = _u64_js_1.default.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));\n ({ h: Eh, l: El } = _u64_js_1.default.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));\n ({ h: Fh, l: Fl } = _u64_js_1.default.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));\n ({ h: Gh, l: Gl } = _u64_js_1.default.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));\n ({ h: Hh, l: Hl } = _u64_js_1.default.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));\n this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);\n }\n roundClean() {\n SHA512_W_H.fill(0);\n SHA512_W_L.fill(0);\n }\n destroy() {\n this.buffer.fill(0);\n this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n }\n}\nexports.SHA512 = SHA512;\nclass SHA512_224 extends SHA512 {\n constructor() {\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0x8c3d37c8 | 0;\n this.Al = 0x19544da2 | 0;\n this.Bh = 0x73e19966 | 0;\n this.Bl = 0x89dcd4d6 | 0;\n this.Ch = 0x1dfab7ae | 0;\n this.Cl = 0x32ff9c82 | 0;\n this.Dh = 0x679dd514 | 0;\n this.Dl = 0x582f9fcf | 0;\n this.Eh = 0x0f6d2b69 | 0;\n this.El = 0x7bd44da8 | 0;\n this.Fh = 0x77e36f73 | 0;\n this.Fl = 0x04c48942 | 0;\n this.Gh = 0x3f9d85a8 | 0;\n this.Gl = 0x6a1d36c8 | 0;\n this.Hh = 0x1112e6ad | 0;\n this.Hl = 0x91d692a1 | 0;\n this.outputLen = 28;\n }\n}\nexports.SHA512_224 = SHA512_224;\nclass SHA512_256 extends SHA512 {\n constructor() {\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0x22312194 | 0;\n this.Al = 0xfc2bf72c | 0;\n this.Bh = 0x9f555fa3 | 0;\n this.Bl = 0xc84c64c2 | 0;\n this.Ch = 0x2393b86b | 0;\n this.Cl = 0x6f53b151 | 0;\n this.Dh = 0x96387719 | 0;\n this.Dl = 0x5940eabd | 0;\n this.Eh = 0x96283ee2 | 0;\n this.El = 0xa88effe3 | 0;\n this.Fh = 0xbe5e1e25 | 0;\n this.Fl = 0x53863992 | 0;\n this.Gh = 0x2b0199fc | 0;\n this.Gl = 0x2c85b8aa | 0;\n this.Hh = 0x0eb72ddc | 0;\n this.Hl = 0x81c52ca2 | 0;\n this.outputLen = 32;\n }\n}\nexports.SHA512_256 = SHA512_256;\nclass SHA384 extends SHA512 {\n constructor() {\n super();\n // h -- high 32 bits, l -- low 32 bits\n this.Ah = 0xcbbb9d5d | 0;\n this.Al = 0xc1059ed8 | 0;\n this.Bh = 0x629a292a | 0;\n this.Bl = 0x367cd507 | 0;\n this.Ch = 0x9159015a | 0;\n this.Cl = 0x3070dd17 | 0;\n this.Dh = 0x152fecd8 | 0;\n this.Dl = 0xf70e5939 | 0;\n this.Eh = 0x67332667 | 0;\n this.El = 0xffc00b31 | 0;\n this.Fh = 0x8eb44a87 | 0;\n this.Fl = 0x68581511 | 0;\n this.Gh = 0xdb0c2e0d | 0;\n this.Gl = 0x64f98fa7 | 0;\n this.Hh = 0x47b5481d | 0;\n this.Hl = 0xbefa4fa4 | 0;\n this.outputLen = 48;\n }\n}\nexports.SHA384 = SHA384;\n/** SHA2-512 hash function. */\nexports.sha512 = (0, utils_js_1.wrapConstructor)(() => new SHA512());\n/** SHA2-512/224 \"truncated\" hash function, with improved resistance to length extension attacks. */\nexports.sha512_224 = (0, utils_js_1.wrapConstructor)(() => new SHA512_224());\n/** SHA2-512/256 \"truncated\" hash function, with improved resistance to length extension attacks. */\nexports.sha512_256 = (0, utils_js_1.wrapConstructor)(() => new SHA512_256());\n/** SHA2-384 hash function. */\nexports.sha384 = (0, utils_js_1.wrapConstructor)(() => new SHA384());\n//# sourceMappingURL=sha512.js.map","/**\n * SHA2-512 a.k.a. sha512 and sha384. It is slower than sha256 in js because u64 operations are slow.\n *\n * Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and\n * [the paper on truncated SHA512/256](https://eprint.iacr.org/2010/548.pdf).\n * @module\n */\nimport { HashMD } from './_md.js';\nimport u64 from './_u64.js';\nimport { type CHash, wrapConstructor } from './utils.js';\n\n// Round contants (first 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409):\n// prettier-ignore\nconst [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64.split([\n '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',\n '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',\n '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',\n '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694',\n '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65',\n '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5',\n '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4',\n '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70',\n '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df',\n '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b',\n '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30',\n '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8',\n '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8',\n '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3',\n '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec',\n '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b',\n '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178',\n '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b',\n '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c',\n '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'\n].map(n => BigInt(n))))();\n\n// Temporary buffer, not used to store anything between runs\nconst SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);\nconst SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);\nexport class SHA512 extends HashMD {\n // We cannot use array here since array allows indexing by variable which means optimizer/compiler cannot use registers.\n // Also looks cleaner and easier to verify with spec.\n // Initial state (first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19):\n // h -- high 32 bits, l -- low 32 bits\n protected Ah: number = 0x6a09e667 | 0;\n protected Al: number = 0xf3bcc908 | 0;\n protected Bh: number = 0xbb67ae85 | 0;\n protected Bl: number = 0x84caa73b | 0;\n protected Ch: number = 0x3c6ef372 | 0;\n protected Cl: number = 0xfe94f82b | 0;\n protected Dh: number = 0xa54ff53a | 0;\n protected Dl: number = 0x5f1d36f1 | 0;\n protected Eh: number = 0x510e527f | 0;\n protected El: number = 0xade682d1 | 0;\n protected Fh: number = 0x9b05688c | 0;\n protected Fl: number = 0x2b3e6c1f | 0;\n protected Gh: number = 0x1f83d9ab | 0;\n protected Gl: number = 0xfb41bd6b | 0;\n protected Hh: number = 0x5be0cd19 | 0;\n protected Hl: number = 0x137e2179 | 0;\n\n constructor() {\n super(128, 64, 16, false);\n }\n // prettier-ignore\n protected get(): [\n number, number, number, number, number, number, number, number,\n number, number, number, number, number, number, number, number\n ] {\n const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];\n }\n // prettier-ignore\n protected set(\n Ah: number, Al: number, Bh: number, Bl: number, Ch: number, Cl: number, Dh: number, Dl: number,\n Eh: number, El: number, Fh: number, Fl: number, Gh: number, Gl: number, Hh: number, Hl: number\n ): void {\n this.Ah = Ah | 0;\n this.Al = Al | 0;\n this.Bh = Bh | 0;\n this.Bl = Bl | 0;\n this.Ch = Ch | 0;\n this.Cl = Cl | 0;\n this.Dh = Dh | 0;\n this.Dl = Dl | 0;\n this.Eh = Eh | 0;\n this.El = El | 0;\n this.Fh = Fh | 0;\n this.Fl = Fl | 0;\n this.Gh = Gh | 0;\n this.Gl = Gl | 0;\n this.Hh = Hh | 0;\n this.Hl = Hl | 0;\n }\n protected process(view: DataView, offset: number): void {\n // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) {\n SHA512_W_H[i] = view.getUint32(offset);\n SHA512_W_L[i] = view.getUint32((offset += 4));\n }\n for (let i = 16; i < 80; i++) {\n // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)\n const W15h = SHA512_W_H[i - 15] | 0;\n const W15l = SHA512_W_L[i - 15] | 0;\n const s0h = u64.rotrSH(W15h, W15l, 1) ^ u64.rotrSH(W15h, W15l, 8) ^ u64.shrSH(W15h, W15l, 7);\n const s0l = u64.rotrSL(W15h, W15l, 1) ^ u64.rotrSL(W15h, W15l, 8) ^ u64.shrSL(W15h, W15l, 7);\n // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)\n const W2h = SHA512_W_H[i - 2] | 0;\n const W2l = SHA512_W_L[i - 2] | 0;\n const s1h = u64.rotrSH(W2h, W2l, 19) ^ u64.rotrBH(W2h, W2l, 61) ^ u64.shrSH(W2h, W2l, 6);\n const s1l = u64.rotrSL(W2h, W2l, 19) ^ u64.rotrBL(W2h, W2l, 61) ^ u64.shrSL(W2h, W2l, 6);\n // SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];\n const SUMl = u64.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);\n const SUMh = u64.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);\n SHA512_W_H[i] = SUMh | 0;\n SHA512_W_L[i] = SUMl | 0;\n }\n let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;\n // Compression function main loop, 80 rounds\n for (let i = 0; i < 80; i++) {\n // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)\n const sigma1h = u64.rotrSH(Eh, El, 14) ^ u64.rotrSH(Eh, El, 18) ^ u64.rotrBH(Eh, El, 41);\n const sigma1l = u64.rotrSL(Eh, El, 14) ^ u64.rotrSL(Eh, El, 18) ^ u64.rotrBL(Eh, El, 41);\n //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const CHIh = (Eh & Fh) ^ (~Eh & Gh);\n const CHIl = (El & Fl) ^ (~El & Gl);\n // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]\n // prettier-ignore\n const T1ll = u64.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);\n const T1h = u64.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);\n const T1l = T1ll | 0;\n // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)\n const sigma0h = u64.rotrSH(Ah, Al, 28) ^ u64.rotrBH(Ah, Al, 34) ^ u64.rotrBH(Ah, Al, 39);\n const sigma0l = u64.rotrSL(Ah, Al, 28) ^ u64.rotrBL(Ah, Al, 34) ^ u64.rotrBL(Ah, Al, 39);\n const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);\n const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);\n Hh = Gh | 0;\n Hl = Gl | 0;\n Gh = Fh | 0;\n Gl = Fl | 0;\n Fh = Eh | 0;\n Fl = El | 0;\n ({ h: Eh, l: El } = u64.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));\n Dh = Ch | 0;\n Dl = Cl | 0;\n Ch = Bh | 0;\n Cl = Bl | 0;\n Bh = Ah | 0;\n Bl = Al | 0;\n const All = u64.add3L(T1l, sigma0l, MAJl);\n Ah = u64.add3H(All, T1h, sigma0h, MAJh);\n Al = All | 0;\n }\n // Add the compressed chunk to the current hash value\n ({ h: Ah, l: Al } = u64.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));\n ({ h: Bh, l: Bl } = u64.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));\n ({ h: Ch, l: Cl } = u64.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));\n ({ h: Dh, l: Dl } = u64.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));\n ({ h: Eh, l: El } = u64.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));\n ({ h: Fh, l: Fl } = u64.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));\n ({ h: Gh, l: Gl } = u64.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));\n ({ h: Hh, l: Hl } = u64.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));\n this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);\n }\n protected roundClean(): void {\n SHA512_W_H.fill(0);\n SHA512_W_L.fill(0);\n }\n destroy(): void {\n this.buffer.fill(0);\n this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);\n }\n}\n\nexport class SHA512_224 extends SHA512 {\n // h -- high 32 bits, l -- low 32 bits\n protected Ah: number = 0x8c3d37c8 | 0;\n protected Al: number = 0x19544da2 | 0;\n protected Bh: number = 0x73e19966 | 0;\n protected Bl: number = 0x89dcd4d6 | 0;\n protected Ch: number = 0x1dfab7ae | 0;\n protected Cl: number = 0x32ff9c82 | 0;\n protected Dh: number = 0x679dd514 | 0;\n protected Dl: number = 0x582f9fcf | 0;\n protected Eh: number = 0x0f6d2b69 | 0;\n protected El: number = 0x7bd44da8 | 0;\n protected Fh: number = 0x77e36f73 | 0;\n protected Fl: number = 0x04c48942 | 0;\n protected Gh: number = 0x3f9d85a8 | 0;\n protected Gl: number = 0x6a1d36c8 | 0;\n protected Hh: number = 0x1112e6ad | 0;\n protected Hl: number = 0x91d692a1 | 0;\n\n constructor() {\n super();\n this.outputLen = 28;\n }\n}\n\nexport class SHA512_256 extends SHA512 {\n // h -- high 32 bits, l -- low 32 bits\n protected Ah: number = 0x22312194 | 0;\n protected Al: number = 0xfc2bf72c | 0;\n protected Bh: number = 0x9f555fa3 | 0;\n protected Bl: number = 0xc84c64c2 | 0;\n protected Ch: number = 0x2393b86b | 0;\n protected Cl: number = 0x6f53b151 | 0;\n protected Dh: number = 0x96387719 | 0;\n protected Dl: number = 0x5940eabd | 0;\n protected Eh: number = 0x96283ee2 | 0;\n protected El: number = 0xa88effe3 | 0;\n protected Fh: number = 0xbe5e1e25 | 0;\n protected Fl: number = 0x53863992 | 0;\n protected Gh: number = 0x2b0199fc | 0;\n protected Gl: number = 0x2c85b8aa | 0;\n protected Hh: number = 0x0eb72ddc | 0;\n protected Hl: number = 0x81c52ca2 | 0;\n\n constructor() {\n super();\n this.outputLen = 32;\n }\n}\n\nexport class SHA384 extends SHA512 {\n // h -- high 32 bits, l -- low 32 bits\n protected Ah: number = 0xcbbb9d5d | 0;\n protected Al: number = 0xc1059ed8 | 0;\n protected Bh: number = 0x629a292a | 0;\n protected Bl: number = 0x367cd507 | 0;\n protected Ch: number = 0x9159015a | 0;\n protected Cl: number = 0x3070dd17 | 0;\n protected Dh: number = 0x152fecd8 | 0;\n protected Dl: number = 0xf70e5939 | 0;\n protected Eh: number = 0x67332667 | 0;\n protected El: number = 0xffc00b31 | 0;\n protected Fh: number = 0x8eb44a87 | 0;\n protected Fl: number = 0x68581511 | 0;\n protected Gh: number = 0xdb0c2e0d | 0;\n protected Gl: number = 0x64f98fa7 | 0;\n protected Hh: number = 0x47b5481d | 0;\n protected Hl: number = 0xbefa4fa4 | 0;\n\n constructor() {\n super();\n this.outputLen = 48;\n }\n}\n\n/** SHA2-512 hash function. */\nexport const sha512: CHash = /* @__PURE__ */ wrapConstructor(() => new SHA512());\n/** SHA2-512/224 \"truncated\" hash function, with improved resistance to length extension attacks. */\nexport const sha512_224: CHash = /* @__PURE__ */ wrapConstructor(() => new SHA512_224());\n/** SHA2-512/256 \"truncated\" hash function, with improved resistance to length extension attacks. */\nexport const sha512_256: CHash = /* @__PURE__ */ wrapConstructor(() => new SHA512_256());\n/** SHA2-384 hash function. */\nexport const sha384: CHash = /* @__PURE__ */ wrapConstructor(() => new SHA384());\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.HashMD = void 0;\nexports.setBigUint64 = setBigUint64;\nexports.Chi = Chi;\nexports.Maj = Maj;\n/**\n * Internal Merkle-Damgard hash utils.\n * @module\n */\nconst _assert_js_1 = require(\"./_assert.js\");\nconst utils_js_1 = require(\"./utils.js\");\n/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */\nfunction setBigUint64(view, byteOffset, value, isLE) {\n if (typeof view.setBigUint64 === 'function')\n return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n/** Choice: a ? b : c */\nfunction Chi(a, b, c) {\n return (a & b) ^ (~a & c);\n}\n/** Majority function, true if any two inputs is true. */\nfunction Maj(a, b, c) {\n return (a & b) ^ (a & c) ^ (b & c);\n}\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */\nclass HashMD extends utils_js_1.Hash {\n constructor(blockLen, outputLen, padOffset, isLE) {\n super();\n this.blockLen = blockLen;\n this.outputLen = outputLen;\n this.padOffset = padOffset;\n this.isLE = isLE;\n this.finished = false;\n this.length = 0;\n this.pos = 0;\n this.destroyed = false;\n this.buffer = new Uint8Array(blockLen);\n this.view = (0, utils_js_1.createView)(this.buffer);\n }\n update(data) {\n (0, _assert_js_1.aexists)(this);\n const { view, buffer, blockLen } = this;\n data = (0, utils_js_1.toBytes)(data);\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = (0, utils_js_1.createView)(data);\n for (; blockLen <= len - pos; pos += blockLen)\n this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out) {\n (0, _assert_js_1.aexists)(this);\n (0, _assert_js_1.aoutput)(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n this.buffer.subarray(pos).fill(0);\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++)\n buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = (0, utils_js_1.createView)(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4)\n throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length)\n throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++)\n oview.setUint32(4 * i, state[i], isLE);\n }\n digest() {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to) {\n to || (to = new this.constructor());\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.length = length;\n to.pos = pos;\n to.finished = finished;\n to.destroyed = destroyed;\n if (length % blockLen)\n to.buffer.set(buffer);\n return to;\n }\n}\nexports.HashMD = HashMD;\n//# sourceMappingURL=_md.js.map","/**\n * Internal Merkle-Damgard hash utils.\n * @module\n */\nimport { aexists, aoutput } from './_assert.js';\nimport { type Input, Hash, createView, toBytes } from './utils.js';\n\n/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */\nexport function setBigUint64(\n view: DataView,\n byteOffset: number,\n value: bigint,\n isLE: boolean\n): void {\n if (typeof view.setBigUint64 === 'function') return view.setBigUint64(byteOffset, value, isLE);\n const _32n = BigInt(32);\n const _u32_max = BigInt(0xffffffff);\n const wh = Number((value >> _32n) & _u32_max);\n const wl = Number(value & _u32_max);\n const h = isLE ? 4 : 0;\n const l = isLE ? 0 : 4;\n view.setUint32(byteOffset + h, wh, isLE);\n view.setUint32(byteOffset + l, wl, isLE);\n}\n\n/** Choice: a ? b : c */\nexport function Chi(a: number, b: number, c: number): number {\n return (a & b) ^ (~a & c);\n}\n\n/** Majority function, true if any two inputs is true. */\nexport function Maj(a: number, b: number, c: number): number {\n return (a & b) ^ (a & c) ^ (b & c);\n}\n\n/**\n * Merkle-Damgard hash construction base class.\n * Could be used to create MD5, RIPEMD, SHA1, SHA2.\n */\nexport abstract class HashMD> extends Hash {\n protected abstract process(buf: DataView, offset: number): void;\n protected abstract get(): number[];\n protected abstract set(...args: number[]): void;\n abstract destroy(): void;\n protected abstract roundClean(): void;\n // For partial updates less than block size\n protected buffer: Uint8Array;\n protected view: DataView;\n protected finished = false;\n protected length = 0;\n protected pos = 0;\n protected destroyed = false;\n\n constructor(\n readonly blockLen: number,\n public outputLen: number,\n readonly padOffset: number,\n readonly isLE: boolean\n ) {\n super();\n this.buffer = new Uint8Array(blockLen);\n this.view = createView(this.buffer);\n }\n update(data: Input): this {\n aexists(this);\n const { view, buffer, blockLen } = this;\n data = toBytes(data);\n const len = data.length;\n for (let pos = 0; pos < len; ) {\n const take = Math.min(blockLen - this.pos, len - pos);\n // Fast path: we have at least one block in input, cast it to view and process\n if (take === blockLen) {\n const dataView = createView(data);\n for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);\n continue;\n }\n buffer.set(data.subarray(pos, pos + take), this.pos);\n this.pos += take;\n pos += take;\n if (this.pos === blockLen) {\n this.process(view, 0);\n this.pos = 0;\n }\n }\n this.length += data.length;\n this.roundClean();\n return this;\n }\n digestInto(out: Uint8Array): void {\n aexists(this);\n aoutput(out, this);\n this.finished = true;\n // Padding\n // We can avoid allocation of buffer for padding completely if it\n // was previously not allocated here. But it won't change performance.\n const { buffer, view, blockLen, isLE } = this;\n let { pos } = this;\n // append the bit '1' to the message\n buffer[pos++] = 0b10000000;\n this.buffer.subarray(pos).fill(0);\n // we have less than padOffset left in buffer, so we cannot put length in\n // current block, need process it and pad again\n if (this.padOffset > blockLen - pos) {\n this.process(view, 0);\n pos = 0;\n }\n // Pad until full block byte with zeros\n for (let i = pos; i < blockLen; i++) buffer[i] = 0;\n // Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that\n // You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.\n // So we just write lowest 64 bits of that value.\n setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);\n this.process(view, 0);\n const oview = createView(out);\n const len = this.outputLen;\n // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT\n if (len % 4) throw new Error('_sha2: outputLen should be aligned to 32bit');\n const outLen = len / 4;\n const state = this.get();\n if (outLen > state.length) throw new Error('_sha2: outputLen bigger than state');\n for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);\n }\n digest(): Uint8Array {\n const { buffer, outputLen } = this;\n this.digestInto(buffer);\n const res = buffer.slice(0, outputLen);\n this.destroy();\n return res;\n }\n _cloneInto(to?: T): T {\n to ||= new (this.constructor as any)() as T;\n to.set(...this.get());\n const { blockLen, buffer, length, finished, destroyed, pos } = this;\n to.length = length;\n to.pos = pos;\n to.finished = finished;\n to.destroyed = destroyed;\n if (length % blockLen) to.buffer.set(buffer);\n return to;\n }\n}\n","\"use strict\";\n/**\n * Internal assertion helpers.\n * @module\n */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.anumber = anumber;\nexports.abytes = abytes;\nexports.ahash = ahash;\nexports.aexists = aexists;\nexports.aoutput = aoutput;\n/** Asserts something is positive integer. */\nfunction anumber(n) {\n if (!Number.isSafeInteger(n) || n < 0)\n throw new Error('positive integer expected, got ' + n);\n}\n/** Is number an Uint8Array? Copied from utils for perf. */\nfunction isBytes(a) {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n/** Asserts something is Uint8Array. */\nfunction abytes(b, ...lengths) {\n if (!isBytes(b))\n throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\n/** Asserts something is hash */\nfunction ahash(h) {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.wrapConstructor');\n anumber(h.outputLen);\n anumber(h.blockLen);\n}\n/** Asserts a hash instance has not been destroyed / finished */\nfunction aexists(instance, checkFinished = true) {\n if (instance.destroyed)\n throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished)\n throw new Error('Hash#digest() has already been called');\n}\n/** Asserts output is properly-sized byte array */\nfunction aoutput(out, instance) {\n abytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error('digestInto() expects output buffer of length at least ' + min);\n }\n}\n//# sourceMappingURL=_assert.js.map","/**\n * Internal assertion helpers.\n * @module\n */\n\n/** Asserts something is positive integer. */\nfunction anumber(n: number): void {\n if (!Number.isSafeInteger(n) || n < 0) throw new Error('positive integer expected, got ' + n);\n}\n\n/** Is number an Uint8Array? Copied from utils for perf. */\nfunction isBytes(a: unknown): a is Uint8Array {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n\n/** Asserts something is Uint8Array. */\nfunction abytes(b: Uint8Array | undefined, ...lengths: number[]): void {\n if (!isBytes(b)) throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\n\n/** Hash interface. */\nexport type Hash = {\n (data: Uint8Array): Uint8Array;\n blockLen: number;\n outputLen: number;\n create: any;\n};\n\n/** Asserts something is hash */\nfunction ahash(h: Hash): void {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.wrapConstructor');\n anumber(h.outputLen);\n anumber(h.blockLen);\n}\n\n/** Asserts a hash instance has not been destroyed / finished */\nfunction aexists(instance: any, checkFinished = true): void {\n if (instance.destroyed) throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called');\n}\n\n/** Asserts output is properly-sized byte array */\nfunction aoutput(out: any, instance: any): void {\n abytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error('digestInto() expects output buffer of length at least ' + min);\n }\n}\n\nexport { anumber, abytes, ahash, aexists, aoutput };\n","\"use strict\";\n/**\n * Utilities for hex, bytes, CSPRNG.\n * @module\n */\n/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.Hash = exports.nextTick = exports.byteSwapIfBE = exports.isLE = void 0;\nexports.isBytes = isBytes;\nexports.u8 = u8;\nexports.u32 = u32;\nexports.createView = createView;\nexports.rotr = rotr;\nexports.rotl = rotl;\nexports.byteSwap = byteSwap;\nexports.byteSwap32 = byteSwap32;\nexports.bytesToHex = bytesToHex;\nexports.hexToBytes = hexToBytes;\nexports.asyncLoop = asyncLoop;\nexports.utf8ToBytes = utf8ToBytes;\nexports.toBytes = toBytes;\nexports.concatBytes = concatBytes;\nexports.checkOpts = checkOpts;\nexports.wrapConstructor = wrapConstructor;\nexports.wrapConstructorWithOpts = wrapConstructorWithOpts;\nexports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts;\nexports.randomBytes = randomBytes;\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nconst crypto_1 = require(\"@noble/hashes/crypto\");\nconst _assert_js_1 = require(\"./_assert.js\");\n// export { isBytes } from './_assert.js';\n// We can't reuse isBytes from _assert, because somehow this causes huge perf issues\nfunction isBytes(a) {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n// Cast array to different type\nfunction u8(arr) {\n return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\n}\nfunction u32(arr) {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\n// Cast array to view\nfunction createView(arr) {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n/** The rotate right (circular right shift) operation for uint32 */\nfunction rotr(word, shift) {\n return (word << (32 - shift)) | (word >>> shift);\n}\n/** The rotate left (circular left shift) operation for uint32 */\nfunction rotl(word, shift) {\n return (word << shift) | ((word >>> (32 - shift)) >>> 0);\n}\n/** Is current platform little-endian? Most are. Big-Endian platform: IBM */\nexports.isLE = (() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n// The byte swap operation for uint32\nfunction byteSwap(word) {\n return (((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff));\n}\n/** Conditionally byte swap if on a big-endian platform */\nexports.byteSwapIfBE = exports.isLE\n ? (n) => n\n : (n) => byteSwap(n);\n/** In place byte swap for Uint32Array */\nfunction byteSwap32(arr) {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n}\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * Convert byte array to hex string.\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nfunction bytesToHex(bytes) {\n (0, _assert_js_1.abytes)(bytes);\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };\nfunction asciiToBase16(ch) {\n if (ch >= asciis._0 && ch <= asciis._9)\n return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F)\n return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f)\n return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n/**\n * Convert hex string to byte array.\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nfunction hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n/**\n * There is no setImmediate in browser and setTimeout is slow.\n * Call of async fn will return Promise, which will be fullfiled only on\n * next scheduler queue processing step and this is exactly what we need.\n */\nconst nextTick = async () => { };\nexports.nextTick = nextTick;\n/** Returns control to thread each 'tick' ms to avoid blocking. */\nasync function asyncLoop(iters, tick, cb) {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick)\n continue;\n await (0, exports.nextTick)();\n ts += diff;\n }\n}\n/**\n * Convert JS string to byte array.\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nfunction utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error('utf8ToBytes expected string, got ' + typeof str);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nfunction toBytes(data) {\n if (typeof data === 'string')\n data = utf8ToBytes(data);\n (0, _assert_js_1.abytes)(data);\n return data;\n}\n/**\n * Copies several Uint8Arrays into one.\n */\nfunction concatBytes(...arrays) {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n (0, _assert_js_1.abytes)(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n/** For runtime check if class implements interface */\nclass Hash {\n // Safe version that clones internal state\n clone() {\n return this._cloneInto();\n }\n}\nexports.Hash = Hash;\nfunction checkOpts(defaults, opts) {\n if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')\n throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged;\n}\n/** Wraps hash function, creating an interface on top of it */\nfunction wrapConstructor(hashCons) {\n const hashC = (msg) => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\nfunction wrapConstructorWithOpts(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\nfunction wrapXOFConstructorWithOpts(hashCons) {\n const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({});\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts) => hashCons(opts);\n return hashC;\n}\n/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */\nfunction randomBytes(bytesLength = 32) {\n if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === 'function') {\n return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === 'function') {\n return crypto_1.crypto.randomBytes(bytesLength);\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n//# sourceMappingURL=utils.js.map","/**\n * Utilities for hex, bytes, CSPRNG.\n * @module\n */\n/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\nimport { abytes } from './_assert.js';\n// export { isBytes } from './_assert.js';\n// We can't reuse isBytes from _assert, because somehow this causes huge perf issues\nexport function isBytes(a: unknown): a is Uint8Array {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n\n// prettier-ignore\nexport type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array |\n Uint16Array | Int16Array | Uint32Array | Int32Array;\n\n// Cast array to different type\nexport function u8(arr: TypedArray): Uint8Array {\n return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\n}\nexport function u32(arr: TypedArray): Uint32Array {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\n\n// Cast array to view\nexport function createView(arr: TypedArray): DataView {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n\n/** The rotate right (circular right shift) operation for uint32 */\nexport function rotr(word: number, shift: number): number {\n return (word << (32 - shift)) | (word >>> shift);\n}\n/** The rotate left (circular left shift) operation for uint32 */\nexport function rotl(word: number, shift: number): number {\n return (word << shift) | ((word >>> (32 - shift)) >>> 0);\n}\n\n/** Is current platform little-endian? Most are. Big-Endian platform: IBM */\nexport const isLE: boolean = /* @__PURE__ */ (() =>\n new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n// The byte swap operation for uint32\nexport function byteSwap(word: number): number {\n return (\n ((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff)\n );\n}\n/** Conditionally byte swap if on a big-endian platform */\nexport const byteSwapIfBE: (n: number) => number = isLE\n ? (n: number) => n\n : (n: number) => byteSwap(n);\n\n/** In place byte swap for Uint32Array */\nexport function byteSwap32(arr: Uint32Array): void {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n}\n\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) =>\n i.toString(16).padStart(2, '0')\n);\n/**\n * Convert byte array to hex string.\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n abytes(bytes);\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 } as const;\nfunction asciiToBase16(ch: number): number | undefined {\n if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n\n/**\n * Convert hex string to byte array.\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex: string): Uint8Array {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2) throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n\n/**\n * There is no setImmediate in browser and setTimeout is slow.\n * Call of async fn will return Promise, which will be fullfiled only on\n * next scheduler queue processing step and this is exactly what we need.\n */\nexport const nextTick = async (): Promise => {};\n\n/** Returns control to thread each 'tick' ms to avoid blocking. */\nexport async function asyncLoop(\n iters: number,\n tick: number,\n cb: (i: number) => void\n): Promise {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick) continue;\n await nextTick();\n ts += diff;\n }\n}\n\n// Global symbols in both browsers and Node.js since v11\n// See https://github.com/microsoft/TypeScript/issues/31535\ndeclare const TextEncoder: any;\n\n/**\n * Convert JS string to byte array.\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nexport function utf8ToBytes(str: string): Uint8Array {\n if (typeof str !== 'string') throw new Error('utf8ToBytes expected string, got ' + typeof str);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n\n/** Accepted input of hash functions. Strings are converted to byte arrays. */\nexport type Input = Uint8Array | string;\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data: Input): Uint8Array {\n if (typeof data === 'string') data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n\n/**\n * Copies several Uint8Arrays into one.\n */\nexport function concatBytes(...arrays: Uint8Array[]): Uint8Array {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n\n/** For runtime check if class implements interface */\nexport abstract class Hash> {\n abstract blockLen: number; // Bytes per block\n abstract outputLen: number; // Bytes in output\n abstract update(buf: Input): this;\n // Writes digest into buf\n abstract digestInto(buf: Uint8Array): void;\n abstract digest(): Uint8Array;\n /**\n * Resets internal state. Makes Hash instance unusable.\n * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed\n * by user, they will need to manually call `destroy()` when zeroing is necessary.\n */\n abstract destroy(): void;\n /**\n * Clones hash instance. Unsafe: doesn't check whether `to` is valid. Can be used as `clone()`\n * when no options are passed.\n * Reasons to use `_cloneInto` instead of clone: 1) performance 2) reuse instance => all internal\n * buffers are overwritten => causes buffer overwrite which is used for digest in some cases.\n * There are no guarantees for clean-up because it's impossible in JS.\n */\n abstract _cloneInto(to?: T): T;\n // Safe version that clones internal state\n clone(): T {\n return this._cloneInto();\n }\n}\n\n/**\n * XOF: streaming API to read digest in chunks.\n * Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name.\n * When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot\n * destroy state, next call can require more bytes.\n */\nexport type HashXOF> = Hash & {\n xof(bytes: number): Uint8Array; // Read 'bytes' bytes from digest stream\n xofInto(buf: Uint8Array): Uint8Array; // read buf.length bytes from digest stream into buf\n};\n\ntype EmptyObj = {};\nexport function checkOpts(\n defaults: T1,\n opts?: T2\n): T1 & T2 {\n if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')\n throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged as T1 & T2;\n}\n\n/** Hash function */\nexport type CHash = ReturnType;\n/** Hash function with output */\nexport type CHashO = ReturnType;\n/** XOF with output */\nexport type CHashXO = ReturnType;\n\n/** Wraps hash function, creating an interface on top of it */\nexport function wrapConstructor>(\n hashCons: () => Hash\n): {\n (msg: Input): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(): Hash;\n} {\n const hashC = (msg: Input): Uint8Array => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\n\nexport function wrapConstructorWithOpts, T extends Object>(\n hashCons: (opts?: T) => Hash\n): {\n (msg: Input, opts?: T): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(opts: T): Hash;\n} {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts: T) => hashCons(opts);\n return hashC;\n}\n\nexport function wrapXOFConstructorWithOpts, T extends Object>(\n hashCons: (opts?: T) => HashXOF\n): {\n (msg: Input, opts?: T): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(opts: T): HashXOF;\n} {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts: T) => hashCons(opts);\n return hashC;\n}\n\n/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */\nexport function randomBytes(bytesLength = 32): Uint8Array {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return crypto.randomBytes(bytesLength);\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.crypto = void 0;\nexports.crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;\n//# sourceMappingURL=crypto.js.map","/**\n * Internal webcrypto alias.\n * We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n * See utils.ts for details.\n * @module\n */\ndeclare const globalThis: Record | undefined;\nexport const crypto: any =\n typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.add5L = exports.add5H = exports.add4H = exports.add4L = exports.add3H = exports.add3L = exports.rotlBL = exports.rotlBH = exports.rotlSL = exports.rotlSH = exports.rotr32L = exports.rotr32H = exports.rotrBL = exports.rotrBH = exports.rotrSL = exports.rotrSH = exports.shrSL = exports.shrSH = exports.toBig = void 0;\nexports.fromBig = fromBig;\nexports.split = split;\nexports.add = add;\n/**\n * Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.\n * @todo re-check https://issues.chromium.org/issues/42212588\n * @module\n */\nconst U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);\nconst _32n = /* @__PURE__ */ BigInt(32);\nfunction fromBig(n, le = false) {\n if (le)\n return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };\n return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };\n}\nfunction split(lst, le = false) {\n let Ah = new Uint32Array(lst.length);\n let Al = new Uint32Array(lst.length);\n for (let i = 0; i < lst.length; i++) {\n const { h, l } = fromBig(lst[i], le);\n [Ah[i], Al[i]] = [h, l];\n }\n return [Ah, Al];\n}\nconst toBig = (h, l) => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);\nexports.toBig = toBig;\n// for Shift in [0, 32)\nconst shrSH = (h, _l, s) => h >>> s;\nexports.shrSH = shrSH;\nconst shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\nexports.shrSL = shrSL;\n// Right rotate for Shift in [1, 32)\nconst rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));\nexports.rotrSH = rotrSH;\nconst rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);\nexports.rotrSL = rotrSL;\n// Right rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));\nexports.rotrBH = rotrBH;\nconst rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));\nexports.rotrBL = rotrBL;\n// Right rotate for shift===32 (just swaps l&h)\nconst rotr32H = (_h, l) => l;\nexports.rotr32H = rotr32H;\nconst rotr32L = (h, _l) => h;\nexports.rotr32L = rotr32L;\n// Left rotate for Shift in [1, 32)\nconst rotlSH = (h, l, s) => (h << s) | (l >>> (32 - s));\nexports.rotlSH = rotlSH;\nconst rotlSL = (h, l, s) => (l << s) | (h >>> (32 - s));\nexports.rotlSL = rotlSL;\n// Left rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst rotlBH = (h, l, s) => (l << (s - 32)) | (h >>> (64 - s));\nexports.rotlBH = rotlBH;\nconst rotlBL = (h, l, s) => (h << (s - 32)) | (l >>> (64 - s));\nexports.rotlBL = rotlBL;\n// JS uses 32-bit signed integers for bitwise operations which means we cannot\n// simple take carry out of low bit sum by shift, we need to use division.\nfunction add(Ah, Al, Bh, Bl) {\n const l = (Al >>> 0) + (Bl >>> 0);\n return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };\n}\n// Addition with more than 2 elements\nconst add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);\nexports.add3L = add3L;\nconst add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;\nexports.add3H = add3H;\nconst add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);\nexports.add4L = add4L;\nconst add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;\nexports.add4H = add4H;\nconst add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);\nexports.add5L = add5L;\nconst add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;\nexports.add5H = add5H;\n// prettier-ignore\nconst u64 = {\n fromBig, split, toBig,\n shrSH, shrSL,\n rotrSH, rotrSL, rotrBH, rotrBL,\n rotr32H, rotr32L,\n rotlSH, rotlSL, rotlBH, rotlBL,\n add, add3L, add3H, add4L, add4H, add5H, add5L,\n};\nexports.default = u64;\n//# sourceMappingURL=_u64.js.map","/**\n * Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.\n * @todo re-check https://issues.chromium.org/issues/42212588\n * @module\n */\nconst U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);\nconst _32n = /* @__PURE__ */ BigInt(32);\n\nfunction fromBig(\n n: bigint,\n le = false\n): {\n h: number;\n l: number;\n} {\n if (le) return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };\n return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };\n}\n\nfunction split(lst: bigint[], le = false): Uint32Array[] {\n let Ah = new Uint32Array(lst.length);\n let Al = new Uint32Array(lst.length);\n for (let i = 0; i < lst.length; i++) {\n const { h, l } = fromBig(lst[i], le);\n [Ah[i], Al[i]] = [h, l];\n }\n return [Ah, Al];\n}\n\nconst toBig = (h: number, l: number): bigint => (BigInt(h >>> 0) << _32n) | BigInt(l >>> 0);\n// for Shift in [0, 32)\nconst shrSH = (h: number, _l: number, s: number): number => h >>> s;\nconst shrSL = (h: number, l: number, s: number): number => (h << (32 - s)) | (l >>> s);\n// Right rotate for Shift in [1, 32)\nconst rotrSH = (h: number, l: number, s: number): number => (h >>> s) | (l << (32 - s));\nconst rotrSL = (h: number, l: number, s: number): number => (h << (32 - s)) | (l >>> s);\n// Right rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst rotrBH = (h: number, l: number, s: number): number => (h << (64 - s)) | (l >>> (s - 32));\nconst rotrBL = (h: number, l: number, s: number): number => (h >>> (s - 32)) | (l << (64 - s));\n// Right rotate for shift===32 (just swaps l&h)\nconst rotr32H = (_h: number, l: number): number => l;\nconst rotr32L = (h: number, _l: number): number => h;\n// Left rotate for Shift in [1, 32)\nconst rotlSH = (h: number, l: number, s: number): number => (h << s) | (l >>> (32 - s));\nconst rotlSL = (h: number, l: number, s: number): number => (l << s) | (h >>> (32 - s));\n// Left rotate for Shift in (32, 64), NOTE: 32 is special case.\nconst rotlBH = (h: number, l: number, s: number): number => (l << (s - 32)) | (h >>> (64 - s));\nconst rotlBL = (h: number, l: number, s: number): number => (h << (s - 32)) | (l >>> (64 - s));\n\n// JS uses 32-bit signed integers for bitwise operations which means we cannot\n// simple take carry out of low bit sum by shift, we need to use division.\nfunction add(\n Ah: number,\n Al: number,\n Bh: number,\n Bl: number\n): {\n h: number;\n l: number;\n} {\n const l = (Al >>> 0) + (Bl >>> 0);\n return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };\n}\n// Addition with more than 2 elements\nconst add3L = (Al: number, Bl: number, Cl: number): number => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);\nconst add3H = (low: number, Ah: number, Bh: number, Ch: number): number =>\n (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;\nconst add4L = (Al: number, Bl: number, Cl: number, Dl: number): number =>\n (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);\nconst add4H = (low: number, Ah: number, Bh: number, Ch: number, Dh: number): number =>\n (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;\nconst add5L = (Al: number, Bl: number, Cl: number, Dl: number, El: number): number =>\n (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);\nconst add5H = (low: number, Ah: number, Bh: number, Ch: number, Dh: number, Eh: number): number =>\n (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;\n\n// prettier-ignore\nexport {\n fromBig, split, toBig,\n shrSH, shrSL,\n rotrSH, rotrSL, rotrBH, rotrBL,\n rotr32H, rotr32L,\n rotlSH, rotlSL, rotlBH, rotlBL,\n add, add3L, add3H, add4L, add4H, add5H, add5L,\n};\n// prettier-ignore\nconst u64: { fromBig: typeof fromBig; split: typeof split; toBig: (h: number, l: number) => bigint; shrSH: (h: number, _l: number, s: number) => number; shrSL: (h: number, l: number, s: number) => number; rotrSH: (h: number, l: number, s: number) => number; rotrSL: (h: number, l: number, s: number) => number; rotrBH: (h: number, l: number, s: number) => number; rotrBL: (h: number, l: number, s: number) => number; rotr32H: (_h: number, l: number) => number; rotr32L: (h: number, _l: number) => number; rotlSH: (h: number, l: number, s: number) => number; rotlSL: (h: number, l: number, s: number) => number; rotlBH: (h: number, l: number, s: number) => number; rotlBL: (h: number, l: number, s: number) => number; add: typeof add; add3L: (Al: number, Bl: number, Cl: number) => number; add3H: (low: number, Ah: number, Bh: number, Ch: number) => number; add4L: (Al: number, Bl: number, Cl: number, Dl: number) => number; add4H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number) => number; add5H: (low: number, Ah: number, Bh: number, Ch: number, Dh: number, Eh: number) => number; add5L: (Al: number, Bl: number, Cl: number, Dl: number, El: number) => number; } = {\n fromBig, split, toBig,\n shrSH, shrSL,\n rotrSH, rotrSL, rotrBH, rotrBL,\n rotr32H, rotr32L,\n rotlSH, rotlSL, rotlBH, rotlBL,\n add, add3L, add3H, add4L, add4H, add5H, add5L,\n};\nexport default u64;\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.wNAF = wNAF;\nexports.pippenger = pippenger;\nexports.precomputeMSMUnsafe = precomputeMSMUnsafe;\nexports.validateBasic = validateBasic;\n/**\n * Methods for elliptic curve multiplication by scalars.\n * Contains wNAF, pippenger\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nconst modular_js_1 = require(\"./modular.js\");\nconst utils_js_1 = require(\"./utils.js\");\nconst _0n = BigInt(0);\nconst _1n = BigInt(1);\nfunction constTimeNegate(condition, item) {\n const neg = item.negate();\n return condition ? neg : item;\n}\nfunction validateW(W, bits) {\n if (!Number.isSafeInteger(W) || W <= 0 || W > bits)\n throw new Error('invalid window size, expected [1..' + bits + '], got W=' + W);\n}\nfunction calcWOpts(W, bits) {\n validateW(W, bits);\n const windows = Math.ceil(bits / W) + 1; // +1, because\n const windowSize = 2 ** (W - 1); // -1 because we skip zero\n return { windows, windowSize };\n}\nfunction validateMSMPoints(points, c) {\n if (!Array.isArray(points))\n throw new Error('array expected');\n points.forEach((p, i) => {\n if (!(p instanceof c))\n throw new Error('invalid point at index ' + i);\n });\n}\nfunction validateMSMScalars(scalars, field) {\n if (!Array.isArray(scalars))\n throw new Error('array of scalars expected');\n scalars.forEach((s, i) => {\n if (!field.isValid(s))\n throw new Error('invalid scalar at index ' + i);\n });\n}\n// Since points in different groups cannot be equal (different object constructor),\n// we can have single place to store precomputes\nconst pointPrecomputes = new WeakMap();\nconst pointWindowSizes = new WeakMap(); // This allows use make points immutable (nothing changes inside)\nfunction getW(P) {\n return pointWindowSizes.get(P) || 1;\n}\n/**\n * Elliptic curve multiplication of Point by scalar. Fragile.\n * Scalars should always be less than curve order: this should be checked inside of a curve itself.\n * Creates precomputation tables for fast multiplication:\n * - private scalar is split by fixed size windows of W bits\n * - every window point is collected from window's table & added to accumulator\n * - since windows are different, same point inside tables won't be accessed more than once per calc\n * - each multiplication is 'Math.ceil(CURVE_ORDER / 𝑊) + 1' point additions (fixed for any scalar)\n * - +1 window is neccessary for wNAF\n * - wNAF reduces table size: 2x less memory + 2x faster generation, but 10% slower multiplication\n *\n * @todo Research returning 2d JS array of windows, instead of a single window.\n * This would allow windows to be in different memory locations\n */\nfunction wNAF(c, bits) {\n return {\n constTimeNegate,\n hasPrecomputes(elm) {\n return getW(elm) !== 1;\n },\n // non-const time multiplication ladder\n unsafeLadder(elm, n, p = c.ZERO) {\n let d = elm;\n while (n > _0n) {\n if (n & _1n)\n p = p.add(d);\n d = d.double();\n n >>= _1n;\n }\n return p;\n },\n /**\n * Creates a wNAF precomputation window. Used for caching.\n * Default window size is set by `utils.precompute()` and is equal to 8.\n * Number of precomputed points depends on the curve size:\n * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:\n * - 𝑊 is the window size\n * - 𝑛 is the bitlength of the curve order.\n * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.\n * @param elm Point instance\n * @param W window size\n * @returns precomputed point tables flattened to a single array\n */\n precomputeWindow(elm, W) {\n const { windows, windowSize } = calcWOpts(W, bits);\n const points = [];\n let p = elm;\n let base = p;\n for (let window = 0; window < windows; window++) {\n base = p;\n points.push(base);\n // =1, because we skip zero\n for (let i = 1; i < windowSize; i++) {\n base = base.add(p);\n points.push(base);\n }\n p = base.double();\n }\n return points;\n },\n /**\n * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.\n * @param W window size\n * @param precomputes precomputed tables\n * @param n scalar (we don't check here, but should be less than curve order)\n * @returns real and fake (for const-time) points\n */\n wNAF(W, precomputes, n) {\n // TODO: maybe check that scalar is less than group order? wNAF behavious is undefined otherwise\n // But need to carefully remove other checks before wNAF. ORDER == bits here\n const { windows, windowSize } = calcWOpts(W, bits);\n let p = c.ZERO;\n let f = c.BASE;\n const mask = BigInt(2 ** W - 1); // Create mask with W ones: 0b1111 for W=4 etc.\n const maxNumber = 2 ** W;\n const shiftBy = BigInt(W);\n for (let window = 0; window < windows; window++) {\n const offset = window * windowSize;\n // Extract W bits.\n let wbits = Number(n & mask);\n // Shift number by W bits.\n n >>= shiftBy;\n // If the bits are bigger than max size, we'll split those.\n // +224 => 256 - 32\n if (wbits > windowSize) {\n wbits -= maxNumber;\n n += _1n;\n }\n // This code was first written with assumption that 'f' and 'p' will never be infinity point:\n // since each addition is multiplied by 2 ** W, it cannot cancel each other. However,\n // there is negate now: it is possible that negated element from low value\n // would be the same as high element, which will create carry into next window.\n // It's not obvious how this can fail, but still worth investigating later.\n // Check if we're onto Zero point.\n // Add random point inside current window to f.\n const offset1 = offset;\n const offset2 = offset + Math.abs(wbits) - 1; // -1 because we skip zero\n const cond1 = window % 2 !== 0;\n const cond2 = wbits < 0;\n if (wbits === 0) {\n // The most important part for const-time getPublicKey\n f = f.add(constTimeNegate(cond1, precomputes[offset1]));\n }\n else {\n p = p.add(constTimeNegate(cond2, precomputes[offset2]));\n }\n }\n // JIT-compiler should not eliminate f here, since it will later be used in normalizeZ()\n // Even if the variable is still unused, there are some checks which will\n // throw an exception, so compiler needs to prove they won't happen, which is hard.\n // At this point there is a way to F be infinity-point even if p is not,\n // which makes it less const-time: around 1 bigint multiply.\n return { p, f };\n },\n /**\n * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.\n * @param W window size\n * @param precomputes precomputed tables\n * @param n scalar (we don't check here, but should be less than curve order)\n * @param acc accumulator point to add result of multiplication\n * @returns point\n */\n wNAFUnsafe(W, precomputes, n, acc = c.ZERO) {\n const { windows, windowSize } = calcWOpts(W, bits);\n const mask = BigInt(2 ** W - 1); // Create mask with W ones: 0b1111 for W=4 etc.\n const maxNumber = 2 ** W;\n const shiftBy = BigInt(W);\n for (let window = 0; window < windows; window++) {\n const offset = window * windowSize;\n if (n === _0n)\n break; // No need to go over empty scalar\n // Extract W bits.\n let wbits = Number(n & mask);\n // Shift number by W bits.\n n >>= shiftBy;\n // If the bits are bigger than max size, we'll split those.\n // +224 => 256 - 32\n if (wbits > windowSize) {\n wbits -= maxNumber;\n n += _1n;\n }\n if (wbits === 0)\n continue;\n let curr = precomputes[offset + Math.abs(wbits) - 1]; // -1 because we skip zero\n if (wbits < 0)\n curr = curr.negate();\n // NOTE: by re-using acc, we can save a lot of additions in case of MSM\n acc = acc.add(curr);\n }\n return acc;\n },\n getPrecomputes(W, P, transform) {\n // Calculate precomputes on a first run, reuse them after\n let comp = pointPrecomputes.get(P);\n if (!comp) {\n comp = this.precomputeWindow(P, W);\n if (W !== 1)\n pointPrecomputes.set(P, transform(comp));\n }\n return comp;\n },\n wNAFCached(P, n, transform) {\n const W = getW(P);\n return this.wNAF(W, this.getPrecomputes(W, P, transform), n);\n },\n wNAFCachedUnsafe(P, n, transform, prev) {\n const W = getW(P);\n if (W === 1)\n return this.unsafeLadder(P, n, prev); // For W=1 ladder is ~x2 faster\n return this.wNAFUnsafe(W, this.getPrecomputes(W, P, transform), n, prev);\n },\n // We calculate precomputes for elliptic curve point multiplication\n // using windowed method. This specifies window size and\n // stores precomputed values. Usually only base point would be precomputed.\n setWindowSize(P, W) {\n validateW(W, bits);\n pointWindowSizes.set(P, W);\n pointPrecomputes.delete(P);\n },\n };\n}\n/**\n * Pippenger algorithm for multi-scalar multiplication (MSM, Pa + Qb + Rc + ...).\n * 30x faster vs naive addition on L=4096, 10x faster with precomputes.\n * For N=254bit, L=1, it does: 1024 ADD + 254 DBL. For L=5: 1536 ADD + 254 DBL.\n * Algorithmically constant-time (for same L), even when 1 point + scalar, or when scalar = 0.\n * @param c Curve Point constructor\n * @param fieldN field over CURVE.N - important that it's not over CURVE.P\n * @param points array of L curve points\n * @param scalars array of L scalars (aka private keys / bigints)\n */\nfunction pippenger(c, fieldN, points, scalars) {\n // If we split scalars by some window (let's say 8 bits), every chunk will only\n // take 256 buckets even if there are 4096 scalars, also re-uses double.\n // TODO:\n // - https://eprint.iacr.org/2024/750.pdf\n // - https://tches.iacr.org/index.php/TCHES/article/view/10287\n // 0 is accepted in scalars\n validateMSMPoints(points, c);\n validateMSMScalars(scalars, fieldN);\n if (points.length !== scalars.length)\n throw new Error('arrays of points and scalars must have equal length');\n const zero = c.ZERO;\n const wbits = (0, utils_js_1.bitLen)(BigInt(points.length));\n const windowSize = wbits > 12 ? wbits - 3 : wbits > 4 ? wbits - 2 : wbits ? 2 : 1; // in bits\n const MASK = (1 << windowSize) - 1;\n const buckets = new Array(MASK + 1).fill(zero); // +1 for zero array\n const lastBits = Math.floor((fieldN.BITS - 1) / windowSize) * windowSize;\n let sum = zero;\n for (let i = lastBits; i >= 0; i -= windowSize) {\n buckets.fill(zero);\n for (let j = 0; j < scalars.length; j++) {\n const scalar = scalars[j];\n const wbits = Number((scalar >> BigInt(i)) & BigInt(MASK));\n buckets[wbits] = buckets[wbits].add(points[j]);\n }\n let resI = zero; // not using this will do small speed-up, but will lose ct\n // Skip first bucket, because it is zero\n for (let j = buckets.length - 1, sumI = zero; j > 0; j--) {\n sumI = sumI.add(buckets[j]);\n resI = resI.add(sumI);\n }\n sum = sum.add(resI);\n if (i !== 0)\n for (let j = 0; j < windowSize; j++)\n sum = sum.double();\n }\n return sum;\n}\n/**\n * Precomputed multi-scalar multiplication (MSM, Pa + Qb + Rc + ...).\n * @param c Curve Point constructor\n * @param fieldN field over CURVE.N - important that it's not over CURVE.P\n * @param points array of L curve points\n * @returns function which multiplies points with scaars\n */\nfunction precomputeMSMUnsafe(c, fieldN, points, windowSize) {\n /**\n * Performance Analysis of Window-based Precomputation\n *\n * Base Case (256-bit scalar, 8-bit window):\n * - Standard precomputation requires:\n * - 31 additions per scalar × 256 scalars = 7,936 ops\n * - Plus 255 summary additions = 8,191 total ops\n * Note: Summary additions can be optimized via accumulator\n *\n * Chunked Precomputation Analysis:\n * - Using 32 chunks requires:\n * - 255 additions per chunk\n * - 256 doublings\n * - Total: (255 × 32) + 256 = 8,416 ops\n *\n * Memory Usage Comparison:\n * Window Size | Standard Points | Chunked Points\n * ------------|-----------------|---------------\n * 4-bit | 520 | 15\n * 8-bit | 4,224 | 255\n * 10-bit | 13,824 | 1,023\n * 16-bit | 557,056 | 65,535\n *\n * Key Advantages:\n * 1. Enables larger window sizes due to reduced memory overhead\n * 2. More efficient for smaller scalar counts:\n * - 16 chunks: (16 × 255) + 256 = 4,336 ops\n * - ~2x faster than standard 8,191 ops\n *\n * Limitations:\n * - Not suitable for plain precomputes (requires 256 constant doublings)\n * - Performance degrades with larger scalar counts:\n * - Optimal for ~256 scalars\n * - Less efficient for 4096+ scalars (Pippenger preferred)\n */\n validateW(windowSize, fieldN.BITS);\n validateMSMPoints(points, c);\n const zero = c.ZERO;\n const tableSize = 2 ** windowSize - 1; // table size (without zero)\n const chunks = Math.ceil(fieldN.BITS / windowSize); // chunks of item\n const MASK = BigInt((1 << windowSize) - 1);\n const tables = points.map((p) => {\n const res = [];\n for (let i = 0, acc = p; i < tableSize; i++) {\n res.push(acc);\n acc = acc.add(p);\n }\n return res;\n });\n return (scalars) => {\n validateMSMScalars(scalars, fieldN);\n if (scalars.length > points.length)\n throw new Error('array of scalars must be smaller than array of points');\n let res = zero;\n for (let i = 0; i < chunks; i++) {\n // No need to double if accumulator is still zero.\n if (res !== zero)\n for (let j = 0; j < windowSize; j++)\n res = res.double();\n const shiftBy = BigInt(chunks * windowSize - (i + 1) * windowSize);\n for (let j = 0; j < scalars.length; j++) {\n const n = scalars[j];\n const curr = Number((n >> shiftBy) & MASK);\n if (!curr)\n continue; // skip zero scalars chunks\n res = res.add(tables[j][curr - 1]);\n }\n }\n return res;\n };\n}\nfunction validateBasic(curve) {\n (0, modular_js_1.validateField)(curve.Fp);\n (0, utils_js_1.validateObject)(curve, {\n n: 'bigint',\n h: 'bigint',\n Gx: 'field',\n Gy: 'field',\n }, {\n nBitLength: 'isSafeInteger',\n nByteLength: 'isSafeInteger',\n });\n // Set defaults\n return Object.freeze({\n ...(0, modular_js_1.nLength)(curve.n, curve.nBitLength),\n ...curve,\n ...{ p: curve.Fp.ORDER },\n });\n}\n//# sourceMappingURL=curve.js.map","/**\n * Methods for elliptic curve multiplication by scalars.\n * Contains wNAF, pippenger\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nimport { type IField, nLength, validateField } from './modular.js';\nimport { bitLen, validateObject } from './utils.js';\n\nconst _0n = BigInt(0);\nconst _1n = BigInt(1);\n\nexport type AffinePoint = {\n x: T;\n y: T;\n} & { z?: never; t?: never };\n\nexport interface Group> {\n double(): T;\n negate(): T;\n add(other: T): T;\n subtract(other: T): T;\n equals(other: T): boolean;\n multiply(scalar: bigint): T;\n}\n\nexport type GroupConstructor = {\n BASE: T;\n ZERO: T;\n};\nexport type Mapper = (i: T[]) => T[];\n\nfunction constTimeNegate>(condition: boolean, item: T): T {\n const neg = item.negate();\n return condition ? neg : item;\n}\n\nfunction validateW(W: number, bits: number) {\n if (!Number.isSafeInteger(W) || W <= 0 || W > bits)\n throw new Error('invalid window size, expected [1..' + bits + '], got W=' + W);\n}\n\nfunction calcWOpts(W: number, bits: number) {\n validateW(W, bits);\n const windows = Math.ceil(bits / W) + 1; // +1, because\n const windowSize = 2 ** (W - 1); // -1 because we skip zero\n return { windows, windowSize };\n}\n\nfunction validateMSMPoints(points: any[], c: any) {\n if (!Array.isArray(points)) throw new Error('array expected');\n points.forEach((p, i) => {\n if (!(p instanceof c)) throw new Error('invalid point at index ' + i);\n });\n}\nfunction validateMSMScalars(scalars: any[], field: any) {\n if (!Array.isArray(scalars)) throw new Error('array of scalars expected');\n scalars.forEach((s, i) => {\n if (!field.isValid(s)) throw new Error('invalid scalar at index ' + i);\n });\n}\n\n// Since points in different groups cannot be equal (different object constructor),\n// we can have single place to store precomputes\nconst pointPrecomputes = new WeakMap();\nconst pointWindowSizes = new WeakMap(); // This allows use make points immutable (nothing changes inside)\n\nfunction getW(P: any): number {\n return pointWindowSizes.get(P) || 1;\n}\n\nexport type IWNAF> = {\n constTimeNegate: >(condition: boolean, item: T) => T;\n hasPrecomputes(elm: T): boolean;\n unsafeLadder(elm: T, n: bigint, p?: T): T;\n precomputeWindow(elm: T, W: number): Group[];\n wNAF(W: number, precomputes: T[], n: bigint): { p: T; f: T };\n wNAFUnsafe(W: number, precomputes: T[], n: bigint, acc?: T): T;\n getPrecomputes(W: number, P: T, transform: Mapper): T[];\n wNAFCached(P: T, n: bigint, transform: Mapper): { p: T; f: T };\n wNAFCachedUnsafe(P: T, n: bigint, transform: Mapper, prev?: T): T;\n setWindowSize(P: T, W: number): void;\n};\n\n/**\n * Elliptic curve multiplication of Point by scalar. Fragile.\n * Scalars should always be less than curve order: this should be checked inside of a curve itself.\n * Creates precomputation tables for fast multiplication:\n * - private scalar is split by fixed size windows of W bits\n * - every window point is collected from window's table & added to accumulator\n * - since windows are different, same point inside tables won't be accessed more than once per calc\n * - each multiplication is 'Math.ceil(CURVE_ORDER / 𝑊) + 1' point additions (fixed for any scalar)\n * - +1 window is neccessary for wNAF\n * - wNAF reduces table size: 2x less memory + 2x faster generation, but 10% slower multiplication\n *\n * @todo Research returning 2d JS array of windows, instead of a single window.\n * This would allow windows to be in different memory locations\n */\nexport function wNAF>(c: GroupConstructor, bits: number): IWNAF {\n return {\n constTimeNegate,\n\n hasPrecomputes(elm: T) {\n return getW(elm) !== 1;\n },\n\n // non-const time multiplication ladder\n unsafeLadder(elm: T, n: bigint, p = c.ZERO) {\n let d: T = elm;\n while (n > _0n) {\n if (n & _1n) p = p.add(d);\n d = d.double();\n n >>= _1n;\n }\n return p;\n },\n\n /**\n * Creates a wNAF precomputation window. Used for caching.\n * Default window size is set by `utils.precompute()` and is equal to 8.\n * Number of precomputed points depends on the curve size:\n * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:\n * - 𝑊 is the window size\n * - 𝑛 is the bitlength of the curve order.\n * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.\n * @param elm Point instance\n * @param W window size\n * @returns precomputed point tables flattened to a single array\n */\n precomputeWindow(elm: T, W: number): Group[] {\n const { windows, windowSize } = calcWOpts(W, bits);\n const points: T[] = [];\n let p: T = elm;\n let base = p;\n for (let window = 0; window < windows; window++) {\n base = p;\n points.push(base);\n // =1, because we skip zero\n for (let i = 1; i < windowSize; i++) {\n base = base.add(p);\n points.push(base);\n }\n p = base.double();\n }\n return points;\n },\n\n /**\n * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.\n * @param W window size\n * @param precomputes precomputed tables\n * @param n scalar (we don't check here, but should be less than curve order)\n * @returns real and fake (for const-time) points\n */\n wNAF(W: number, precomputes: T[], n: bigint): { p: T; f: T } {\n // TODO: maybe check that scalar is less than group order? wNAF behavious is undefined otherwise\n // But need to carefully remove other checks before wNAF. ORDER == bits here\n const { windows, windowSize } = calcWOpts(W, bits);\n\n let p = c.ZERO;\n let f = c.BASE;\n\n const mask = BigInt(2 ** W - 1); // Create mask with W ones: 0b1111 for W=4 etc.\n const maxNumber = 2 ** W;\n const shiftBy = BigInt(W);\n\n for (let window = 0; window < windows; window++) {\n const offset = window * windowSize;\n // Extract W bits.\n let wbits = Number(n & mask);\n\n // Shift number by W bits.\n n >>= shiftBy;\n\n // If the bits are bigger than max size, we'll split those.\n // +224 => 256 - 32\n if (wbits > windowSize) {\n wbits -= maxNumber;\n n += _1n;\n }\n\n // This code was first written with assumption that 'f' and 'p' will never be infinity point:\n // since each addition is multiplied by 2 ** W, it cannot cancel each other. However,\n // there is negate now: it is possible that negated element from low value\n // would be the same as high element, which will create carry into next window.\n // It's not obvious how this can fail, but still worth investigating later.\n\n // Check if we're onto Zero point.\n // Add random point inside current window to f.\n const offset1 = offset;\n const offset2 = offset + Math.abs(wbits) - 1; // -1 because we skip zero\n const cond1 = window % 2 !== 0;\n const cond2 = wbits < 0;\n if (wbits === 0) {\n // The most important part for const-time getPublicKey\n f = f.add(constTimeNegate(cond1, precomputes[offset1]));\n } else {\n p = p.add(constTimeNegate(cond2, precomputes[offset2]));\n }\n }\n // JIT-compiler should not eliminate f here, since it will later be used in normalizeZ()\n // Even if the variable is still unused, there are some checks which will\n // throw an exception, so compiler needs to prove they won't happen, which is hard.\n // At this point there is a way to F be infinity-point even if p is not,\n // which makes it less const-time: around 1 bigint multiply.\n return { p, f };\n },\n\n /**\n * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.\n * @param W window size\n * @param precomputes precomputed tables\n * @param n scalar (we don't check here, but should be less than curve order)\n * @param acc accumulator point to add result of multiplication\n * @returns point\n */\n wNAFUnsafe(W: number, precomputes: T[], n: bigint, acc: T = c.ZERO): T {\n const { windows, windowSize } = calcWOpts(W, bits);\n const mask = BigInt(2 ** W - 1); // Create mask with W ones: 0b1111 for W=4 etc.\n const maxNumber = 2 ** W;\n const shiftBy = BigInt(W);\n for (let window = 0; window < windows; window++) {\n const offset = window * windowSize;\n if (n === _0n) break; // No need to go over empty scalar\n // Extract W bits.\n let wbits = Number(n & mask);\n // Shift number by W bits.\n n >>= shiftBy;\n // If the bits are bigger than max size, we'll split those.\n // +224 => 256 - 32\n if (wbits > windowSize) {\n wbits -= maxNumber;\n n += _1n;\n }\n if (wbits === 0) continue;\n let curr = precomputes[offset + Math.abs(wbits) - 1]; // -1 because we skip zero\n if (wbits < 0) curr = curr.negate();\n // NOTE: by re-using acc, we can save a lot of additions in case of MSM\n acc = acc.add(curr);\n }\n return acc;\n },\n\n getPrecomputes(W: number, P: T, transform: Mapper): T[] {\n // Calculate precomputes on a first run, reuse them after\n let comp = pointPrecomputes.get(P);\n if (!comp) {\n comp = this.precomputeWindow(P, W) as T[];\n if (W !== 1) pointPrecomputes.set(P, transform(comp));\n }\n return comp;\n },\n\n wNAFCached(P: T, n: bigint, transform: Mapper): { p: T; f: T } {\n const W = getW(P);\n return this.wNAF(W, this.getPrecomputes(W, P, transform), n);\n },\n\n wNAFCachedUnsafe(P: T, n: bigint, transform: Mapper, prev?: T): T {\n const W = getW(P);\n if (W === 1) return this.unsafeLadder(P, n, prev); // For W=1 ladder is ~x2 faster\n return this.wNAFUnsafe(W, this.getPrecomputes(W, P, transform), n, prev);\n },\n\n // We calculate precomputes for elliptic curve point multiplication\n // using windowed method. This specifies window size and\n // stores precomputed values. Usually only base point would be precomputed.\n\n setWindowSize(P: T, W: number) {\n validateW(W, bits);\n pointWindowSizes.set(P, W);\n pointPrecomputes.delete(P);\n },\n };\n}\n\n/**\n * Pippenger algorithm for multi-scalar multiplication (MSM, Pa + Qb + Rc + ...).\n * 30x faster vs naive addition on L=4096, 10x faster with precomputes.\n * For N=254bit, L=1, it does: 1024 ADD + 254 DBL. For L=5: 1536 ADD + 254 DBL.\n * Algorithmically constant-time (for same L), even when 1 point + scalar, or when scalar = 0.\n * @param c Curve Point constructor\n * @param fieldN field over CURVE.N - important that it's not over CURVE.P\n * @param points array of L curve points\n * @param scalars array of L scalars (aka private keys / bigints)\n */\nexport function pippenger>(\n c: GroupConstructor,\n fieldN: IField,\n points: T[],\n scalars: bigint[]\n): T {\n // If we split scalars by some window (let's say 8 bits), every chunk will only\n // take 256 buckets even if there are 4096 scalars, also re-uses double.\n // TODO:\n // - https://eprint.iacr.org/2024/750.pdf\n // - https://tches.iacr.org/index.php/TCHES/article/view/10287\n // 0 is accepted in scalars\n validateMSMPoints(points, c);\n validateMSMScalars(scalars, fieldN);\n if (points.length !== scalars.length)\n throw new Error('arrays of points and scalars must have equal length');\n const zero = c.ZERO;\n const wbits = bitLen(BigInt(points.length));\n const windowSize = wbits > 12 ? wbits - 3 : wbits > 4 ? wbits - 2 : wbits ? 2 : 1; // in bits\n const MASK = (1 << windowSize) - 1;\n const buckets = new Array(MASK + 1).fill(zero); // +1 for zero array\n const lastBits = Math.floor((fieldN.BITS - 1) / windowSize) * windowSize;\n let sum = zero;\n for (let i = lastBits; i >= 0; i -= windowSize) {\n buckets.fill(zero);\n for (let j = 0; j < scalars.length; j++) {\n const scalar = scalars[j];\n const wbits = Number((scalar >> BigInt(i)) & BigInt(MASK));\n buckets[wbits] = buckets[wbits].add(points[j]);\n }\n let resI = zero; // not using this will do small speed-up, but will lose ct\n // Skip first bucket, because it is zero\n for (let j = buckets.length - 1, sumI = zero; j > 0; j--) {\n sumI = sumI.add(buckets[j]);\n resI = resI.add(sumI);\n }\n sum = sum.add(resI);\n if (i !== 0) for (let j = 0; j < windowSize; j++) sum = sum.double();\n }\n return sum as T;\n}\n/**\n * Precomputed multi-scalar multiplication (MSM, Pa + Qb + Rc + ...).\n * @param c Curve Point constructor\n * @param fieldN field over CURVE.N - important that it's not over CURVE.P\n * @param points array of L curve points\n * @returns function which multiplies points with scaars\n */\nexport function precomputeMSMUnsafe>(\n c: GroupConstructor,\n fieldN: IField,\n points: T[],\n windowSize: number\n): (scalars: bigint[]) => T {\n /**\n * Performance Analysis of Window-based Precomputation\n *\n * Base Case (256-bit scalar, 8-bit window):\n * - Standard precomputation requires:\n * - 31 additions per scalar × 256 scalars = 7,936 ops\n * - Plus 255 summary additions = 8,191 total ops\n * Note: Summary additions can be optimized via accumulator\n *\n * Chunked Precomputation Analysis:\n * - Using 32 chunks requires:\n * - 255 additions per chunk\n * - 256 doublings\n * - Total: (255 × 32) + 256 = 8,416 ops\n *\n * Memory Usage Comparison:\n * Window Size | Standard Points | Chunked Points\n * ------------|-----------------|---------------\n * 4-bit | 520 | 15\n * 8-bit | 4,224 | 255\n * 10-bit | 13,824 | 1,023\n * 16-bit | 557,056 | 65,535\n *\n * Key Advantages:\n * 1. Enables larger window sizes due to reduced memory overhead\n * 2. More efficient for smaller scalar counts:\n * - 16 chunks: (16 × 255) + 256 = 4,336 ops\n * - ~2x faster than standard 8,191 ops\n *\n * Limitations:\n * - Not suitable for plain precomputes (requires 256 constant doublings)\n * - Performance degrades with larger scalar counts:\n * - Optimal for ~256 scalars\n * - Less efficient for 4096+ scalars (Pippenger preferred)\n */\n validateW(windowSize, fieldN.BITS);\n validateMSMPoints(points, c);\n const zero = c.ZERO;\n const tableSize = 2 ** windowSize - 1; // table size (without zero)\n const chunks = Math.ceil(fieldN.BITS / windowSize); // chunks of item\n const MASK = BigInt((1 << windowSize) - 1);\n const tables = points.map((p: T) => {\n const res = [];\n for (let i = 0, acc = p; i < tableSize; i++) {\n res.push(acc);\n acc = acc.add(p);\n }\n return res;\n });\n return (scalars: bigint[]): T => {\n validateMSMScalars(scalars, fieldN);\n if (scalars.length > points.length)\n throw new Error('array of scalars must be smaller than array of points');\n let res = zero;\n for (let i = 0; i < chunks; i++) {\n // No need to double if accumulator is still zero.\n if (res !== zero) for (let j = 0; j < windowSize; j++) res = res.double();\n const shiftBy = BigInt(chunks * windowSize - (i + 1) * windowSize);\n for (let j = 0; j < scalars.length; j++) {\n const n = scalars[j];\n const curr = Number((n >> shiftBy) & MASK);\n if (!curr) continue; // skip zero scalars chunks\n res = res.add(tables[j][curr - 1]);\n }\n }\n return res;\n };\n}\n\n/**\n * Generic BasicCurve interface: works even for polynomial fields (BLS): P, n, h would be ok.\n * Though generator can be different (Fp2 / Fp6 for BLS).\n */\nexport type BasicCurve = {\n Fp: IField; // Field over which we'll do calculations (Fp)\n n: bigint; // Curve order, total count of valid points in the field\n nBitLength?: number; // bit length of curve order\n nByteLength?: number; // byte length of curve order\n h: bigint; // cofactor. we can assign default=1, but users will just ignore it w/o validation\n hEff?: bigint; // Number to multiply to clear cofactor\n Gx: T; // base point X coordinate\n Gy: T; // base point Y coordinate\n allowInfinityPoint?: boolean; // bls12-381 requires it. ZERO point is valid, but invalid pubkey\n};\n\nexport function validateBasic(\n curve: BasicCurve & T\n): Readonly<\n {\n readonly nBitLength: number;\n readonly nByteLength: number;\n } & BasicCurve &\n T & {\n p: bigint;\n }\n> {\n validateField(curve.Fp);\n validateObject(\n curve,\n {\n n: 'bigint',\n h: 'bigint',\n Gx: 'field',\n Gy: 'field',\n },\n {\n nBitLength: 'isSafeInteger',\n nByteLength: 'isSafeInteger',\n }\n );\n // Set defaults\n return Object.freeze({\n ...nLength(curve.n, curve.nBitLength),\n ...curve,\n ...{ p: curve.Fp.ORDER },\n } as const);\n}\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.isNegativeLE = void 0;\nexports.mod = mod;\nexports.pow = pow;\nexports.pow2 = pow2;\nexports.invert = invert;\nexports.tonelliShanks = tonelliShanks;\nexports.FpSqrt = FpSqrt;\nexports.validateField = validateField;\nexports.FpPow = FpPow;\nexports.FpInvertBatch = FpInvertBatch;\nexports.FpDiv = FpDiv;\nexports.FpLegendre = FpLegendre;\nexports.FpIsSquare = FpIsSquare;\nexports.nLength = nLength;\nexports.Field = Field;\nexports.FpSqrtOdd = FpSqrtOdd;\nexports.FpSqrtEven = FpSqrtEven;\nexports.hashToPrivateScalar = hashToPrivateScalar;\nexports.getFieldBytesLength = getFieldBytesLength;\nexports.getMinHashLength = getMinHashLength;\nexports.mapHashToField = mapHashToField;\n/**\n * Utils for modular division and finite fields.\n * A finite field over 11 is integer number operations `mod 11`.\n * There is no division: it is replaced by modular multiplicative inverse.\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nconst utils_js_1 = require(\"./utils.js\");\n// prettier-ignore\nconst _0n = BigInt(0), _1n = BigInt(1), _2n = /* @__PURE__ */ BigInt(2), _3n = /* @__PURE__ */ BigInt(3);\n// prettier-ignore\nconst _4n = /* @__PURE__ */ BigInt(4), _5n = /* @__PURE__ */ BigInt(5), _8n = /* @__PURE__ */ BigInt(8);\n// prettier-ignore\nconst _9n = /* @__PURE__ */ BigInt(9), _16n = /* @__PURE__ */ BigInt(16);\n// Calculates a modulo b\nfunction mod(a, b) {\n const result = a % b;\n return result >= _0n ? result : b + result;\n}\n/**\n * Efficiently raise num to power and do modular division.\n * Unsafe in some contexts: uses ladder, so can expose bigint bits.\n * @todo use field version && remove\n * @example\n * pow(2n, 6n, 11n) // 64n % 11n == 9n\n */\nfunction pow(num, power, modulo) {\n if (power < _0n)\n throw new Error('invalid exponent, negatives unsupported');\n if (modulo <= _0n)\n throw new Error('invalid modulus');\n if (modulo === _1n)\n return _0n;\n let res = _1n;\n while (power > _0n) {\n if (power & _1n)\n res = (res * num) % modulo;\n num = (num * num) % modulo;\n power >>= _1n;\n }\n return res;\n}\n/** Does `x^(2^power)` mod p. `pow2(30, 4)` == `30^(2^4)` */\nfunction pow2(x, power, modulo) {\n let res = x;\n while (power-- > _0n) {\n res *= res;\n res %= modulo;\n }\n return res;\n}\n/**\n * Inverses number over modulo.\n * Implemented using [Euclidean GCD](https://brilliant.org/wiki/extended-euclidean-algorithm/).\n */\nfunction invert(number, modulo) {\n if (number === _0n)\n throw new Error('invert: expected non-zero number');\n if (modulo <= _0n)\n throw new Error('invert: expected positive modulus, got ' + modulo);\n // Fermat's little theorem \"CT-like\" version inv(n) = n^(m-2) mod m is 30x slower.\n let a = mod(number, modulo);\n let b = modulo;\n // prettier-ignore\n let x = _0n, y = _1n, u = _1n, v = _0n;\n while (a !== _0n) {\n // JIT applies optimization if those two lines follow each other\n const q = b / a;\n const r = b % a;\n const m = x - u * q;\n const n = y - v * q;\n // prettier-ignore\n b = a, a = r, x = u, y = v, u = m, v = n;\n }\n const gcd = b;\n if (gcd !== _1n)\n throw new Error('invert: does not exist');\n return mod(x, modulo);\n}\n/**\n * Tonelli-Shanks square root search algorithm.\n * 1. https://eprint.iacr.org/2012/685.pdf (page 12)\n * 2. Square Roots from 1; 24, 51, 10 to Dan Shanks\n * Will start an infinite loop if field order P is not prime.\n * @param P field order\n * @returns function that takes field Fp (created from P) and number n\n */\nfunction tonelliShanks(P) {\n // Legendre constant: used to calculate Legendre symbol (a | p),\n // which denotes the value of a^((p-1)/2) (mod p).\n // (a | p) ≡ 1 if a is a square (mod p)\n // (a | p) ≡ -1 if a is not a square (mod p)\n // (a | p) ≡ 0 if a ≡ 0 (mod p)\n const legendreC = (P - _1n) / _2n;\n let Q, S, Z;\n // Step 1: By factoring out powers of 2 from p - 1,\n // find q and s such that p - 1 = q*(2^s) with q odd\n for (Q = P - _1n, S = 0; Q % _2n === _0n; Q /= _2n, S++)\n ;\n // Step 2: Select a non-square z such that (z | p) ≡ -1 and set c ≡ zq\n for (Z = _2n; Z < P && pow(Z, legendreC, P) !== P - _1n; Z++) {\n // Crash instead of infinity loop, we cannot reasonable count until P.\n if (Z > 1000)\n throw new Error('Cannot find square root: likely non-prime P');\n }\n // Fast-path\n if (S === 1) {\n const p1div4 = (P + _1n) / _4n;\n return function tonelliFast(Fp, n) {\n const root = Fp.pow(n, p1div4);\n if (!Fp.eql(Fp.sqr(root), n))\n throw new Error('Cannot find square root');\n return root;\n };\n }\n // Slow-path\n const Q1div2 = (Q + _1n) / _2n;\n return function tonelliSlow(Fp, n) {\n // Step 0: Check that n is indeed a square: (n | p) should not be ≡ -1\n if (Fp.pow(n, legendreC) === Fp.neg(Fp.ONE))\n throw new Error('Cannot find square root');\n let r = S;\n // TODO: will fail at Fp2/etc\n let g = Fp.pow(Fp.mul(Fp.ONE, Z), Q); // will update both x and b\n let x = Fp.pow(n, Q1div2); // first guess at the square root\n let b = Fp.pow(n, Q); // first guess at the fudge factor\n while (!Fp.eql(b, Fp.ONE)) {\n if (Fp.eql(b, Fp.ZERO))\n return Fp.ZERO; // https://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm (4. If t = 0, return r = 0)\n // Find m such b^(2^m)==1\n let m = 1;\n for (let t2 = Fp.sqr(b); m < r; m++) {\n if (Fp.eql(t2, Fp.ONE))\n break;\n t2 = Fp.sqr(t2); // t2 *= t2\n }\n // NOTE: r-m-1 can be bigger than 32, need to convert to bigint before shift, otherwise there will be overflow\n const ge = Fp.pow(g, _1n << BigInt(r - m - 1)); // ge = 2^(r-m-1)\n g = Fp.sqr(ge); // g = ge * ge\n x = Fp.mul(x, ge); // x *= ge\n b = Fp.mul(b, g); // b *= g\n r = m;\n }\n return x;\n };\n}\n/**\n * Square root for a finite field. It will try to check if optimizations are applicable and fall back to 4:\n *\n * 1. P ≡ 3 (mod 4)\n * 2. P ≡ 5 (mod 8)\n * 3. P ≡ 9 (mod 16)\n * 4. Tonelli-Shanks algorithm\n *\n * Different algorithms can give different roots, it is up to user to decide which one they want.\n * For example there is FpSqrtOdd/FpSqrtEven to choice root based on oddness (used for hash-to-curve).\n */\nfunction FpSqrt(P) {\n // P ≡ 3 (mod 4)\n // √n = n^((P+1)/4)\n if (P % _4n === _3n) {\n // Not all roots possible!\n // const ORDER =\n // 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn;\n // const NUM = 72057594037927816n;\n const p1div4 = (P + _1n) / _4n;\n return function sqrt3mod4(Fp, n) {\n const root = Fp.pow(n, p1div4);\n // Throw if root**2 != n\n if (!Fp.eql(Fp.sqr(root), n))\n throw new Error('Cannot find square root');\n return root;\n };\n }\n // Atkin algorithm for q ≡ 5 (mod 8), https://eprint.iacr.org/2012/685.pdf (page 10)\n if (P % _8n === _5n) {\n const c1 = (P - _5n) / _8n;\n return function sqrt5mod8(Fp, n) {\n const n2 = Fp.mul(n, _2n);\n const v = Fp.pow(n2, c1);\n const nv = Fp.mul(n, v);\n const i = Fp.mul(Fp.mul(nv, _2n), v);\n const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));\n if (!Fp.eql(Fp.sqr(root), n))\n throw new Error('Cannot find square root');\n return root;\n };\n }\n // P ≡ 9 (mod 16)\n if (P % _16n === _9n) {\n // NOTE: tonelli is too slow for bls-Fp2 calculations even on start\n // Means we cannot use sqrt for constants at all!\n //\n // const c1 = Fp.sqrt(Fp.negate(Fp.ONE)); // 1. c1 = sqrt(-1) in F, i.e., (c1^2) == -1 in F\n // const c2 = Fp.sqrt(c1); // 2. c2 = sqrt(c1) in F, i.e., (c2^2) == c1 in F\n // const c3 = Fp.sqrt(Fp.negate(c1)); // 3. c3 = sqrt(-c1) in F, i.e., (c3^2) == -c1 in F\n // const c4 = (P + _7n) / _16n; // 4. c4 = (q + 7) / 16 # Integer arithmetic\n // sqrt = (x) => {\n // let tv1 = Fp.pow(x, c4); // 1. tv1 = x^c4\n // let tv2 = Fp.mul(c1, tv1); // 2. tv2 = c1 * tv1\n // const tv3 = Fp.mul(c2, tv1); // 3. tv3 = c2 * tv1\n // let tv4 = Fp.mul(c3, tv1); // 4. tv4 = c3 * tv1\n // const e1 = Fp.equals(Fp.square(tv2), x); // 5. e1 = (tv2^2) == x\n // const e2 = Fp.equals(Fp.square(tv3), x); // 6. e2 = (tv3^2) == x\n // tv1 = Fp.cmov(tv1, tv2, e1); // 7. tv1 = CMOV(tv1, tv2, e1) # Select tv2 if (tv2^2) == x\n // tv2 = Fp.cmov(tv4, tv3, e2); // 8. tv2 = CMOV(tv4, tv3, e2) # Select tv3 if (tv3^2) == x\n // const e3 = Fp.equals(Fp.square(tv2), x); // 9. e3 = (tv2^2) == x\n // return Fp.cmov(tv1, tv2, e3); // 10. z = CMOV(tv1, tv2, e3) # Select the sqrt from tv1 and tv2\n // }\n }\n // Other cases: Tonelli-Shanks algorithm\n return tonelliShanks(P);\n}\n// Little-endian check for first LE bit (last BE bit);\nconst isNegativeLE = (num, modulo) => (mod(num, modulo) & _1n) === _1n;\nexports.isNegativeLE = isNegativeLE;\n// prettier-ignore\nconst FIELD_FIELDS = [\n 'create', 'isValid', 'is0', 'neg', 'inv', 'sqrt', 'sqr',\n 'eql', 'add', 'sub', 'mul', 'pow', 'div',\n 'addN', 'subN', 'mulN', 'sqrN'\n];\nfunction validateField(field) {\n const initial = {\n ORDER: 'bigint',\n MASK: 'bigint',\n BYTES: 'isSafeInteger',\n BITS: 'isSafeInteger',\n };\n const opts = FIELD_FIELDS.reduce((map, val) => {\n map[val] = 'function';\n return map;\n }, initial);\n return (0, utils_js_1.validateObject)(field, opts);\n}\n// Generic field functions\n/**\n * Same as `pow` but for Fp: non-constant-time.\n * Unsafe in some contexts: uses ladder, so can expose bigint bits.\n */\nfunction FpPow(f, num, power) {\n // Should have same speed as pow for bigints\n // TODO: benchmark!\n if (power < _0n)\n throw new Error('invalid exponent, negatives unsupported');\n if (power === _0n)\n return f.ONE;\n if (power === _1n)\n return num;\n let p = f.ONE;\n let d = num;\n while (power > _0n) {\n if (power & _1n)\n p = f.mul(p, d);\n d = f.sqr(d);\n power >>= _1n;\n }\n return p;\n}\n/**\n * Efficiently invert an array of Field elements.\n * `inv(0)` will return `undefined` here: make sure to throw an error.\n */\nfunction FpInvertBatch(f, nums) {\n const tmp = new Array(nums.length);\n // Walk from first to last, multiply them by each other MOD p\n const lastMultiplied = nums.reduce((acc, num, i) => {\n if (f.is0(num))\n return acc;\n tmp[i] = acc;\n return f.mul(acc, num);\n }, f.ONE);\n // Invert last element\n const inverted = f.inv(lastMultiplied);\n // Walk from last to first, multiply them by inverted each other MOD p\n nums.reduceRight((acc, num, i) => {\n if (f.is0(num))\n return acc;\n tmp[i] = f.mul(acc, tmp[i]);\n return f.mul(acc, num);\n }, inverted);\n return tmp;\n}\nfunction FpDiv(f, lhs, rhs) {\n return f.mul(lhs, typeof rhs === 'bigint' ? invert(rhs, f.ORDER) : f.inv(rhs));\n}\n/**\n * Legendre symbol.\n * * (a | p) ≡ 1 if a is a square (mod p), quadratic residue\n * * (a | p) ≡ -1 if a is not a square (mod p), quadratic non residue\n * * (a | p) ≡ 0 if a ≡ 0 (mod p)\n */\nfunction FpLegendre(order) {\n const legendreConst = (order - _1n) / _2n; // Integer arithmetic\n return (f, x) => f.pow(x, legendreConst);\n}\n// This function returns True whenever the value x is a square in the field F.\nfunction FpIsSquare(f) {\n const legendre = FpLegendre(f.ORDER);\n return (x) => {\n const p = legendre(f, x);\n return f.eql(p, f.ZERO) || f.eql(p, f.ONE);\n };\n}\n// CURVE.n lengths\nfunction nLength(n, nBitLength) {\n // Bit size, byte size of CURVE.n\n const _nBitLength = nBitLength !== undefined ? nBitLength : n.toString(2).length;\n const nByteLength = Math.ceil(_nBitLength / 8);\n return { nBitLength: _nBitLength, nByteLength };\n}\n/**\n * Initializes a finite field over prime.\n * Major performance optimizations:\n * * a) denormalized operations like mulN instead of mul\n * * b) same object shape: never add or remove keys\n * * c) Object.freeze\n * Fragile: always run a benchmark on a change.\n * Security note: operations don't check 'isValid' for all elements for performance reasons,\n * it is caller responsibility to check this.\n * This is low-level code, please make sure you know what you're doing.\n * @param ORDER prime positive bigint\n * @param bitLen how many bits the field consumes\n * @param isLE (def: false) if encoding / decoding should be in little-endian\n * @param redef optional faster redefinitions of sqrt and other methods\n */\nfunction Field(ORDER, bitLen, isLE = false, redef = {}) {\n if (ORDER <= _0n)\n throw new Error('invalid field: expected ORDER > 0, got ' + ORDER);\n const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen);\n if (BYTES > 2048)\n throw new Error('invalid field: expected ORDER of <= 2048 bytes');\n let sqrtP; // cached sqrtP\n const f = Object.freeze({\n ORDER,\n isLE,\n BITS,\n BYTES,\n MASK: (0, utils_js_1.bitMask)(BITS),\n ZERO: _0n,\n ONE: _1n,\n create: (num) => mod(num, ORDER),\n isValid: (num) => {\n if (typeof num !== 'bigint')\n throw new Error('invalid field element: expected bigint, got ' + typeof num);\n return _0n <= num && num < ORDER; // 0 is valid element, but it's not invertible\n },\n is0: (num) => num === _0n,\n isOdd: (num) => (num & _1n) === _1n,\n neg: (num) => mod(-num, ORDER),\n eql: (lhs, rhs) => lhs === rhs,\n sqr: (num) => mod(num * num, ORDER),\n add: (lhs, rhs) => mod(lhs + rhs, ORDER),\n sub: (lhs, rhs) => mod(lhs - rhs, ORDER),\n mul: (lhs, rhs) => mod(lhs * rhs, ORDER),\n pow: (num, power) => FpPow(f, num, power),\n div: (lhs, rhs) => mod(lhs * invert(rhs, ORDER), ORDER),\n // Same as above, but doesn't normalize\n sqrN: (num) => num * num,\n addN: (lhs, rhs) => lhs + rhs,\n subN: (lhs, rhs) => lhs - rhs,\n mulN: (lhs, rhs) => lhs * rhs,\n inv: (num) => invert(num, ORDER),\n sqrt: redef.sqrt ||\n ((n) => {\n if (!sqrtP)\n sqrtP = FpSqrt(ORDER);\n return sqrtP(f, n);\n }),\n invertBatch: (lst) => FpInvertBatch(f, lst),\n // TODO: do we really need constant cmov?\n // We don't have const-time bigints anyway, so probably will be not very useful\n cmov: (a, b, c) => (c ? b : a),\n toBytes: (num) => (isLE ? (0, utils_js_1.numberToBytesLE)(num, BYTES) : (0, utils_js_1.numberToBytesBE)(num, BYTES)),\n fromBytes: (bytes) => {\n if (bytes.length !== BYTES)\n throw new Error('Field.fromBytes: expected ' + BYTES + ' bytes, got ' + bytes.length);\n return isLE ? (0, utils_js_1.bytesToNumberLE)(bytes) : (0, utils_js_1.bytesToNumberBE)(bytes);\n },\n });\n return Object.freeze(f);\n}\nfunction FpSqrtOdd(Fp, elm) {\n if (!Fp.isOdd)\n throw new Error(\"Field doesn't have isOdd\");\n const root = Fp.sqrt(elm);\n return Fp.isOdd(root) ? root : Fp.neg(root);\n}\nfunction FpSqrtEven(Fp, elm) {\n if (!Fp.isOdd)\n throw new Error(\"Field doesn't have isOdd\");\n const root = Fp.sqrt(elm);\n return Fp.isOdd(root) ? Fp.neg(root) : root;\n}\n/**\n * \"Constant-time\" private key generation utility.\n * Same as mapKeyToField, but accepts less bytes (40 instead of 48 for 32-byte field).\n * Which makes it slightly more biased, less secure.\n * @deprecated use `mapKeyToField` instead\n */\nfunction hashToPrivateScalar(hash, groupOrder, isLE = false) {\n hash = (0, utils_js_1.ensureBytes)('privateHash', hash);\n const hashLen = hash.length;\n const minLen = nLength(groupOrder).nByteLength + 8;\n if (minLen < 24 || hashLen < minLen || hashLen > 1024)\n throw new Error('hashToPrivateScalar: expected ' + minLen + '-1024 bytes of input, got ' + hashLen);\n const num = isLE ? (0, utils_js_1.bytesToNumberLE)(hash) : (0, utils_js_1.bytesToNumberBE)(hash);\n return mod(num, groupOrder - _1n) + _1n;\n}\n/**\n * Returns total number of bytes consumed by the field element.\n * For example, 32 bytes for usual 256-bit weierstrass curve.\n * @param fieldOrder number of field elements, usually CURVE.n\n * @returns byte length of field\n */\nfunction getFieldBytesLength(fieldOrder) {\n if (typeof fieldOrder !== 'bigint')\n throw new Error('field order must be bigint');\n const bitLength = fieldOrder.toString(2).length;\n return Math.ceil(bitLength / 8);\n}\n/**\n * Returns minimal amount of bytes that can be safely reduced\n * by field order.\n * Should be 2^-128 for 128-bit curve such as P256.\n * @param fieldOrder number of field elements, usually CURVE.n\n * @returns byte length of target hash\n */\nfunction getMinHashLength(fieldOrder) {\n const length = getFieldBytesLength(fieldOrder);\n return length + Math.ceil(length / 2);\n}\n/**\n * \"Constant-time\" private key generation utility.\n * Can take (n + n/2) or more bytes of uniform input e.g. from CSPRNG or KDF\n * and convert them into private scalar, with the modulo bias being negligible.\n * Needs at least 48 bytes of input for 32-byte private key.\n * https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/\n * FIPS 186-5, A.2 https://csrc.nist.gov/publications/detail/fips/186/5/final\n * RFC 9380, https://www.rfc-editor.org/rfc/rfc9380#section-5\n * @param hash hash output from SHA3 or a similar function\n * @param groupOrder size of subgroup - (e.g. secp256k1.CURVE.n)\n * @param isLE interpret hash bytes as LE num\n * @returns valid private scalar\n */\nfunction mapHashToField(key, fieldOrder, isLE = false) {\n const len = key.length;\n const fieldLen = getFieldBytesLength(fieldOrder);\n const minLen = getMinHashLength(fieldOrder);\n // No small numbers: need to understand bias story. No huge numbers: easier to detect JS timings.\n if (len < 16 || len < minLen || len > 1024)\n throw new Error('expected ' + minLen + '-1024 bytes of input, got ' + len);\n const num = isLE ? (0, utils_js_1.bytesToNumberLE)(key) : (0, utils_js_1.bytesToNumberBE)(key);\n // `mod(x, 11)` can sometimes produce 0. `mod(x, 10) + 1` is the same, but no 0\n const reduced = mod(num, fieldOrder - _1n) + _1n;\n return isLE ? (0, utils_js_1.numberToBytesLE)(reduced, fieldLen) : (0, utils_js_1.numberToBytesBE)(reduced, fieldLen);\n}\n//# sourceMappingURL=modular.js.map","/**\n * Utils for modular division and finite fields.\n * A finite field over 11 is integer number operations `mod 11`.\n * There is no division: it is replaced by modular multiplicative inverse.\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nimport {\n bitMask,\n bytesToNumberBE,\n bytesToNumberLE,\n ensureBytes,\n numberToBytesBE,\n numberToBytesLE,\n validateObject,\n} from './utils.js';\n\n// prettier-ignore\nconst _0n = BigInt(0), _1n = BigInt(1), _2n = /* @__PURE__ */ BigInt(2), _3n = /* @__PURE__ */ BigInt(3);\n// prettier-ignore\nconst _4n = /* @__PURE__ */ BigInt(4), _5n = /* @__PURE__ */ BigInt(5), _8n = /* @__PURE__ */ BigInt(8);\n// prettier-ignore\nconst _9n =/* @__PURE__ */ BigInt(9), _16n = /* @__PURE__ */ BigInt(16);\n\n// Calculates a modulo b\nexport function mod(a: bigint, b: bigint): bigint {\n const result = a % b;\n return result >= _0n ? result : b + result;\n}\n/**\n * Efficiently raise num to power and do modular division.\n * Unsafe in some contexts: uses ladder, so can expose bigint bits.\n * @todo use field version && remove\n * @example\n * pow(2n, 6n, 11n) // 64n % 11n == 9n\n */\nexport function pow(num: bigint, power: bigint, modulo: bigint): bigint {\n if (power < _0n) throw new Error('invalid exponent, negatives unsupported');\n if (modulo <= _0n) throw new Error('invalid modulus');\n if (modulo === _1n) return _0n;\n let res = _1n;\n while (power > _0n) {\n if (power & _1n) res = (res * num) % modulo;\n num = (num * num) % modulo;\n power >>= _1n;\n }\n return res;\n}\n\n/** Does `x^(2^power)` mod p. `pow2(30, 4)` == `30^(2^4)` */\nexport function pow2(x: bigint, power: bigint, modulo: bigint): bigint {\n let res = x;\n while (power-- > _0n) {\n res *= res;\n res %= modulo;\n }\n return res;\n}\n\n/**\n * Inverses number over modulo.\n * Implemented using [Euclidean GCD](https://brilliant.org/wiki/extended-euclidean-algorithm/).\n */\nexport function invert(number: bigint, modulo: bigint): bigint {\n if (number === _0n) throw new Error('invert: expected non-zero number');\n if (modulo <= _0n) throw new Error('invert: expected positive modulus, got ' + modulo);\n // Fermat's little theorem \"CT-like\" version inv(n) = n^(m-2) mod m is 30x slower.\n let a = mod(number, modulo);\n let b = modulo;\n // prettier-ignore\n let x = _0n, y = _1n, u = _1n, v = _0n;\n while (a !== _0n) {\n // JIT applies optimization if those two lines follow each other\n const q = b / a;\n const r = b % a;\n const m = x - u * q;\n const n = y - v * q;\n // prettier-ignore\n b = a, a = r, x = u, y = v, u = m, v = n;\n }\n const gcd = b;\n if (gcd !== _1n) throw new Error('invert: does not exist');\n return mod(x, modulo);\n}\n\n/**\n * Tonelli-Shanks square root search algorithm.\n * 1. https://eprint.iacr.org/2012/685.pdf (page 12)\n * 2. Square Roots from 1; 24, 51, 10 to Dan Shanks\n * Will start an infinite loop if field order P is not prime.\n * @param P field order\n * @returns function that takes field Fp (created from P) and number n\n */\nexport function tonelliShanks(P: bigint): (Fp: IField, n: T) => T {\n // Legendre constant: used to calculate Legendre symbol (a | p),\n // which denotes the value of a^((p-1)/2) (mod p).\n // (a | p) ≡ 1 if a is a square (mod p)\n // (a | p) ≡ -1 if a is not a square (mod p)\n // (a | p) ≡ 0 if a ≡ 0 (mod p)\n const legendreC = (P - _1n) / _2n;\n\n let Q: bigint, S: number, Z: bigint;\n // Step 1: By factoring out powers of 2 from p - 1,\n // find q and s such that p - 1 = q*(2^s) with q odd\n for (Q = P - _1n, S = 0; Q % _2n === _0n; Q /= _2n, S++);\n\n // Step 2: Select a non-square z such that (z | p) ≡ -1 and set c ≡ zq\n for (Z = _2n; Z < P && pow(Z, legendreC, P) !== P - _1n; Z++) {\n // Crash instead of infinity loop, we cannot reasonable count until P.\n if (Z > 1000) throw new Error('Cannot find square root: likely non-prime P');\n }\n\n // Fast-path\n if (S === 1) {\n const p1div4 = (P + _1n) / _4n;\n return function tonelliFast(Fp: IField, n: T) {\n const root = Fp.pow(n, p1div4);\n if (!Fp.eql(Fp.sqr(root), n)) throw new Error('Cannot find square root');\n return root;\n };\n }\n\n // Slow-path\n const Q1div2 = (Q + _1n) / _2n;\n return function tonelliSlow(Fp: IField, n: T): T {\n // Step 0: Check that n is indeed a square: (n | p) should not be ≡ -1\n if (Fp.pow(n, legendreC) === Fp.neg(Fp.ONE)) throw new Error('Cannot find square root');\n let r = S;\n // TODO: will fail at Fp2/etc\n let g = Fp.pow(Fp.mul(Fp.ONE, Z), Q); // will update both x and b\n let x = Fp.pow(n, Q1div2); // first guess at the square root\n let b = Fp.pow(n, Q); // first guess at the fudge factor\n\n while (!Fp.eql(b, Fp.ONE)) {\n if (Fp.eql(b, Fp.ZERO)) return Fp.ZERO; // https://en.wikipedia.org/wiki/Tonelli%E2%80%93Shanks_algorithm (4. If t = 0, return r = 0)\n // Find m such b^(2^m)==1\n let m = 1;\n for (let t2 = Fp.sqr(b); m < r; m++) {\n if (Fp.eql(t2, Fp.ONE)) break;\n t2 = Fp.sqr(t2); // t2 *= t2\n }\n // NOTE: r-m-1 can be bigger than 32, need to convert to bigint before shift, otherwise there will be overflow\n const ge = Fp.pow(g, _1n << BigInt(r - m - 1)); // ge = 2^(r-m-1)\n g = Fp.sqr(ge); // g = ge * ge\n x = Fp.mul(x, ge); // x *= ge\n b = Fp.mul(b, g); // b *= g\n r = m;\n }\n return x;\n };\n}\n\n/**\n * Square root for a finite field. It will try to check if optimizations are applicable and fall back to 4:\n *\n * 1. P ≡ 3 (mod 4)\n * 2. P ≡ 5 (mod 8)\n * 3. P ≡ 9 (mod 16)\n * 4. Tonelli-Shanks algorithm\n *\n * Different algorithms can give different roots, it is up to user to decide which one they want.\n * For example there is FpSqrtOdd/FpSqrtEven to choice root based on oddness (used for hash-to-curve).\n */\nexport function FpSqrt(P: bigint): (Fp: IField, n: T) => T {\n // P ≡ 3 (mod 4)\n // √n = n^((P+1)/4)\n if (P % _4n === _3n) {\n // Not all roots possible!\n // const ORDER =\n // 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaabn;\n // const NUM = 72057594037927816n;\n const p1div4 = (P + _1n) / _4n;\n return function sqrt3mod4(Fp: IField, n: T) {\n const root = Fp.pow(n, p1div4);\n // Throw if root**2 != n\n if (!Fp.eql(Fp.sqr(root), n)) throw new Error('Cannot find square root');\n return root;\n };\n }\n\n // Atkin algorithm for q ≡ 5 (mod 8), https://eprint.iacr.org/2012/685.pdf (page 10)\n if (P % _8n === _5n) {\n const c1 = (P - _5n) / _8n;\n return function sqrt5mod8(Fp: IField, n: T) {\n const n2 = Fp.mul(n, _2n);\n const v = Fp.pow(n2, c1);\n const nv = Fp.mul(n, v);\n const i = Fp.mul(Fp.mul(nv, _2n), v);\n const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));\n if (!Fp.eql(Fp.sqr(root), n)) throw new Error('Cannot find square root');\n return root;\n };\n }\n\n // P ≡ 9 (mod 16)\n if (P % _16n === _9n) {\n // NOTE: tonelli is too slow for bls-Fp2 calculations even on start\n // Means we cannot use sqrt for constants at all!\n //\n // const c1 = Fp.sqrt(Fp.negate(Fp.ONE)); // 1. c1 = sqrt(-1) in F, i.e., (c1^2) == -1 in F\n // const c2 = Fp.sqrt(c1); // 2. c2 = sqrt(c1) in F, i.e., (c2^2) == c1 in F\n // const c3 = Fp.sqrt(Fp.negate(c1)); // 3. c3 = sqrt(-c1) in F, i.e., (c3^2) == -c1 in F\n // const c4 = (P + _7n) / _16n; // 4. c4 = (q + 7) / 16 # Integer arithmetic\n // sqrt = (x) => {\n // let tv1 = Fp.pow(x, c4); // 1. tv1 = x^c4\n // let tv2 = Fp.mul(c1, tv1); // 2. tv2 = c1 * tv1\n // const tv3 = Fp.mul(c2, tv1); // 3. tv3 = c2 * tv1\n // let tv4 = Fp.mul(c3, tv1); // 4. tv4 = c3 * tv1\n // const e1 = Fp.equals(Fp.square(tv2), x); // 5. e1 = (tv2^2) == x\n // const e2 = Fp.equals(Fp.square(tv3), x); // 6. e2 = (tv3^2) == x\n // tv1 = Fp.cmov(tv1, tv2, e1); // 7. tv1 = CMOV(tv1, tv2, e1) # Select tv2 if (tv2^2) == x\n // tv2 = Fp.cmov(tv4, tv3, e2); // 8. tv2 = CMOV(tv4, tv3, e2) # Select tv3 if (tv3^2) == x\n // const e3 = Fp.equals(Fp.square(tv2), x); // 9. e3 = (tv2^2) == x\n // return Fp.cmov(tv1, tv2, e3); // 10. z = CMOV(tv1, tv2, e3) # Select the sqrt from tv1 and tv2\n // }\n }\n // Other cases: Tonelli-Shanks algorithm\n return tonelliShanks(P);\n}\n\n// Little-endian check for first LE bit (last BE bit);\nexport const isNegativeLE = (num: bigint, modulo: bigint): boolean =>\n (mod(num, modulo) & _1n) === _1n;\n\n/** Field is not always over prime: for example, Fp2 has ORDER(q)=p^m. */\nexport interface IField {\n ORDER: bigint;\n isLE: boolean;\n BYTES: number;\n BITS: number;\n MASK: bigint;\n ZERO: T;\n ONE: T;\n // 1-arg\n create: (num: T) => T;\n isValid: (num: T) => boolean;\n is0: (num: T) => boolean;\n neg(num: T): T;\n inv(num: T): T;\n sqrt(num: T): T;\n sqr(num: T): T;\n // 2-args\n eql(lhs: T, rhs: T): boolean;\n add(lhs: T, rhs: T): T;\n sub(lhs: T, rhs: T): T;\n mul(lhs: T, rhs: T | bigint): T;\n pow(lhs: T, power: bigint): T;\n div(lhs: T, rhs: T | bigint): T;\n // N for NonNormalized (for now)\n addN(lhs: T, rhs: T): T;\n subN(lhs: T, rhs: T): T;\n mulN(lhs: T, rhs: T | bigint): T;\n sqrN(num: T): T;\n\n // Optional\n // Should be same as sgn0 function in\n // [RFC9380](https://www.rfc-editor.org/rfc/rfc9380#section-4.1).\n // NOTE: sgn0 is 'negative in LE', which is same as odd. And negative in LE is kinda strange definition anyway.\n isOdd?(num: T): boolean; // Odd instead of even since we have it for Fp2\n // legendre?(num: T): T;\n pow(lhs: T, power: bigint): T;\n invertBatch: (lst: T[]) => T[];\n toBytes(num: T): Uint8Array;\n fromBytes(bytes: Uint8Array): T;\n // If c is False, CMOV returns a, otherwise it returns b.\n cmov(a: T, b: T, c: boolean): T;\n}\n// prettier-ignore\nconst FIELD_FIELDS = [\n 'create', 'isValid', 'is0', 'neg', 'inv', 'sqrt', 'sqr',\n 'eql', 'add', 'sub', 'mul', 'pow', 'div',\n 'addN', 'subN', 'mulN', 'sqrN'\n] as const;\nexport function validateField(field: IField): IField {\n const initial = {\n ORDER: 'bigint',\n MASK: 'bigint',\n BYTES: 'isSafeInteger',\n BITS: 'isSafeInteger',\n } as Record;\n const opts = FIELD_FIELDS.reduce((map, val: string) => {\n map[val] = 'function';\n return map;\n }, initial);\n return validateObject(field, opts);\n}\n\n// Generic field functions\n\n/**\n * Same as `pow` but for Fp: non-constant-time.\n * Unsafe in some contexts: uses ladder, so can expose bigint bits.\n */\nexport function FpPow(f: IField, num: T, power: bigint): T {\n // Should have same speed as pow for bigints\n // TODO: benchmark!\n if (power < _0n) throw new Error('invalid exponent, negatives unsupported');\n if (power === _0n) return f.ONE;\n if (power === _1n) return num;\n let p = f.ONE;\n let d = num;\n while (power > _0n) {\n if (power & _1n) p = f.mul(p, d);\n d = f.sqr(d);\n power >>= _1n;\n }\n return p;\n}\n\n/**\n * Efficiently invert an array of Field elements.\n * `inv(0)` will return `undefined` here: make sure to throw an error.\n */\nexport function FpInvertBatch(f: IField, nums: T[]): T[] {\n const tmp = new Array(nums.length);\n // Walk from first to last, multiply them by each other MOD p\n const lastMultiplied = nums.reduce((acc, num, i) => {\n if (f.is0(num)) return acc;\n tmp[i] = acc;\n return f.mul(acc, num);\n }, f.ONE);\n // Invert last element\n const inverted = f.inv(lastMultiplied);\n // Walk from last to first, multiply them by inverted each other MOD p\n nums.reduceRight((acc, num, i) => {\n if (f.is0(num)) return acc;\n tmp[i] = f.mul(acc, tmp[i]);\n return f.mul(acc, num);\n }, inverted);\n return tmp;\n}\n\nexport function FpDiv(f: IField, lhs: T, rhs: T | bigint): T {\n return f.mul(lhs, typeof rhs === 'bigint' ? invert(rhs, f.ORDER) : f.inv(rhs));\n}\n\n/**\n * Legendre symbol.\n * * (a | p) ≡ 1 if a is a square (mod p), quadratic residue\n * * (a | p) ≡ -1 if a is not a square (mod p), quadratic non residue\n * * (a | p) ≡ 0 if a ≡ 0 (mod p)\n */\nexport function FpLegendre(order: bigint): (f: IField, x: T) => T {\n const legendreConst = (order - _1n) / _2n; // Integer arithmetic\n return (f: IField, x: T): T => f.pow(x, legendreConst);\n}\n\n// This function returns True whenever the value x is a square in the field F.\nexport function FpIsSquare(f: IField): (x: T) => boolean {\n const legendre = FpLegendre(f.ORDER);\n return (x: T): boolean => {\n const p = legendre(f, x);\n return f.eql(p, f.ZERO) || f.eql(p, f.ONE);\n };\n}\n\n// CURVE.n lengths\nexport function nLength(\n n: bigint,\n nBitLength?: number\n): {\n nBitLength: number;\n nByteLength: number;\n} {\n // Bit size, byte size of CURVE.n\n const _nBitLength = nBitLength !== undefined ? nBitLength : n.toString(2).length;\n const nByteLength = Math.ceil(_nBitLength / 8);\n return { nBitLength: _nBitLength, nByteLength };\n}\n\ntype FpField = IField & Required, 'isOdd'>>;\n/**\n * Initializes a finite field over prime.\n * Major performance optimizations:\n * * a) denormalized operations like mulN instead of mul\n * * b) same object shape: never add or remove keys\n * * c) Object.freeze\n * Fragile: always run a benchmark on a change.\n * Security note: operations don't check 'isValid' for all elements for performance reasons,\n * it is caller responsibility to check this.\n * This is low-level code, please make sure you know what you're doing.\n * @param ORDER prime positive bigint\n * @param bitLen how many bits the field consumes\n * @param isLE (def: false) if encoding / decoding should be in little-endian\n * @param redef optional faster redefinitions of sqrt and other methods\n */\nexport function Field(\n ORDER: bigint,\n bitLen?: number,\n isLE = false,\n redef: Partial> = {}\n): Readonly {\n if (ORDER <= _0n) throw new Error('invalid field: expected ORDER > 0, got ' + ORDER);\n const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen);\n if (BYTES > 2048) throw new Error('invalid field: expected ORDER of <= 2048 bytes');\n let sqrtP: ReturnType; // cached sqrtP\n const f: Readonly = Object.freeze({\n ORDER,\n isLE,\n BITS,\n BYTES,\n MASK: bitMask(BITS),\n ZERO: _0n,\n ONE: _1n,\n create: (num) => mod(num, ORDER),\n isValid: (num) => {\n if (typeof num !== 'bigint')\n throw new Error('invalid field element: expected bigint, got ' + typeof num);\n return _0n <= num && num < ORDER; // 0 is valid element, but it's not invertible\n },\n is0: (num) => num === _0n,\n isOdd: (num) => (num & _1n) === _1n,\n neg: (num) => mod(-num, ORDER),\n eql: (lhs, rhs) => lhs === rhs,\n\n sqr: (num) => mod(num * num, ORDER),\n add: (lhs, rhs) => mod(lhs + rhs, ORDER),\n sub: (lhs, rhs) => mod(lhs - rhs, ORDER),\n mul: (lhs, rhs) => mod(lhs * rhs, ORDER),\n pow: (num, power) => FpPow(f, num, power),\n div: (lhs, rhs) => mod(lhs * invert(rhs, ORDER), ORDER),\n\n // Same as above, but doesn't normalize\n sqrN: (num) => num * num,\n addN: (lhs, rhs) => lhs + rhs,\n subN: (lhs, rhs) => lhs - rhs,\n mulN: (lhs, rhs) => lhs * rhs,\n\n inv: (num) => invert(num, ORDER),\n sqrt:\n redef.sqrt ||\n ((n) => {\n if (!sqrtP) sqrtP = FpSqrt(ORDER);\n return sqrtP(f, n);\n }),\n invertBatch: (lst) => FpInvertBatch(f, lst),\n // TODO: do we really need constant cmov?\n // We don't have const-time bigints anyway, so probably will be not very useful\n cmov: (a, b, c) => (c ? b : a),\n toBytes: (num) => (isLE ? numberToBytesLE(num, BYTES) : numberToBytesBE(num, BYTES)),\n fromBytes: (bytes) => {\n if (bytes.length !== BYTES)\n throw new Error('Field.fromBytes: expected ' + BYTES + ' bytes, got ' + bytes.length);\n return isLE ? bytesToNumberLE(bytes) : bytesToNumberBE(bytes);\n },\n } as FpField);\n return Object.freeze(f);\n}\n\nexport function FpSqrtOdd(Fp: IField, elm: T): T {\n if (!Fp.isOdd) throw new Error(\"Field doesn't have isOdd\");\n const root = Fp.sqrt(elm);\n return Fp.isOdd(root) ? root : Fp.neg(root);\n}\n\nexport function FpSqrtEven(Fp: IField, elm: T): T {\n if (!Fp.isOdd) throw new Error(\"Field doesn't have isOdd\");\n const root = Fp.sqrt(elm);\n return Fp.isOdd(root) ? Fp.neg(root) : root;\n}\n\n/**\n * \"Constant-time\" private key generation utility.\n * Same as mapKeyToField, but accepts less bytes (40 instead of 48 for 32-byte field).\n * Which makes it slightly more biased, less secure.\n * @deprecated use `mapKeyToField` instead\n */\nexport function hashToPrivateScalar(\n hash: string | Uint8Array,\n groupOrder: bigint,\n isLE = false\n): bigint {\n hash = ensureBytes('privateHash', hash);\n const hashLen = hash.length;\n const minLen = nLength(groupOrder).nByteLength + 8;\n if (minLen < 24 || hashLen < minLen || hashLen > 1024)\n throw new Error(\n 'hashToPrivateScalar: expected ' + minLen + '-1024 bytes of input, got ' + hashLen\n );\n const num = isLE ? bytesToNumberLE(hash) : bytesToNumberBE(hash);\n return mod(num, groupOrder - _1n) + _1n;\n}\n\n/**\n * Returns total number of bytes consumed by the field element.\n * For example, 32 bytes for usual 256-bit weierstrass curve.\n * @param fieldOrder number of field elements, usually CURVE.n\n * @returns byte length of field\n */\nexport function getFieldBytesLength(fieldOrder: bigint): number {\n if (typeof fieldOrder !== 'bigint') throw new Error('field order must be bigint');\n const bitLength = fieldOrder.toString(2).length;\n return Math.ceil(bitLength / 8);\n}\n\n/**\n * Returns minimal amount of bytes that can be safely reduced\n * by field order.\n * Should be 2^-128 for 128-bit curve such as P256.\n * @param fieldOrder number of field elements, usually CURVE.n\n * @returns byte length of target hash\n */\nexport function getMinHashLength(fieldOrder: bigint): number {\n const length = getFieldBytesLength(fieldOrder);\n return length + Math.ceil(length / 2);\n}\n\n/**\n * \"Constant-time\" private key generation utility.\n * Can take (n + n/2) or more bytes of uniform input e.g. from CSPRNG or KDF\n * and convert them into private scalar, with the modulo bias being negligible.\n * Needs at least 48 bytes of input for 32-byte private key.\n * https://research.kudelskisecurity.com/2020/07/28/the-definitive-guide-to-modulo-bias-and-how-to-avoid-it/\n * FIPS 186-5, A.2 https://csrc.nist.gov/publications/detail/fips/186/5/final\n * RFC 9380, https://www.rfc-editor.org/rfc/rfc9380#section-5\n * @param hash hash output from SHA3 or a similar function\n * @param groupOrder size of subgroup - (e.g. secp256k1.CURVE.n)\n * @param isLE interpret hash bytes as LE num\n * @returns valid private scalar\n */\nexport function mapHashToField(key: Uint8Array, fieldOrder: bigint, isLE = false): Uint8Array {\n const len = key.length;\n const fieldLen = getFieldBytesLength(fieldOrder);\n const minLen = getMinHashLength(fieldOrder);\n // No small numbers: need to understand bias story. No huge numbers: easier to detect JS timings.\n if (len < 16 || len < minLen || len > 1024)\n throw new Error('expected ' + minLen + '-1024 bytes of input, got ' + len);\n const num = isLE ? bytesToNumberLE(key) : bytesToNumberBE(key);\n // `mod(x, 11)` can sometimes produce 0. `mod(x, 10) + 1` is the same, but no 0\n const reduced = mod(num, fieldOrder - _1n) + _1n;\n return isLE ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);\n}\n","\"use strict\";\n/**\n * Hex, bytes and number utilities.\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.notImplemented = exports.bitMask = void 0;\nexports.isBytes = isBytes;\nexports.abytes = abytes;\nexports.abool = abool;\nexports.bytesToHex = bytesToHex;\nexports.numberToHexUnpadded = numberToHexUnpadded;\nexports.hexToNumber = hexToNumber;\nexports.hexToBytes = hexToBytes;\nexports.bytesToNumberBE = bytesToNumberBE;\nexports.bytesToNumberLE = bytesToNumberLE;\nexports.numberToBytesBE = numberToBytesBE;\nexports.numberToBytesLE = numberToBytesLE;\nexports.numberToVarBytesBE = numberToVarBytesBE;\nexports.ensureBytes = ensureBytes;\nexports.concatBytes = concatBytes;\nexports.equalBytes = equalBytes;\nexports.utf8ToBytes = utf8ToBytes;\nexports.inRange = inRange;\nexports.aInRange = aInRange;\nexports.bitLen = bitLen;\nexports.bitGet = bitGet;\nexports.bitSet = bitSet;\nexports.createHmacDrbg = createHmacDrbg;\nexports.validateObject = validateObject;\nexports.memoized = memoized;\n// 100 lines of code in the file are duplicated from noble-hashes (utils).\n// This is OK: `abstract` directory does not use noble-hashes.\n// User may opt-in into using different hashing library. This way, noble-hashes\n// won't be included into their bundle.\nconst _0n = /* @__PURE__ */ BigInt(0);\nconst _1n = /* @__PURE__ */ BigInt(1);\nconst _2n = /* @__PURE__ */ BigInt(2);\nfunction isBytes(a) {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\nfunction abytes(item) {\n if (!isBytes(item))\n throw new Error('Uint8Array expected');\n}\nfunction abool(title, value) {\n if (typeof value !== 'boolean')\n throw new Error(title + ' boolean expected, got ' + value);\n}\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));\n/**\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nfunction bytesToHex(bytes) {\n abytes(bytes);\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\nfunction numberToHexUnpadded(num) {\n const hex = num.toString(16);\n return hex.length & 1 ? '0' + hex : hex;\n}\nfunction hexToNumber(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n return hex === '' ? _0n : BigInt('0x' + hex); // Big Endian\n}\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };\nfunction asciiToBase16(ch) {\n if (ch >= asciis._0 && ch <= asciis._9)\n return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F)\n return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f)\n return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n/**\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nfunction hexToBytes(hex) {\n if (typeof hex !== 'string')\n throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2)\n throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n// BE: Big Endian, LE: Little Endian\nfunction bytesToNumberBE(bytes) {\n return hexToNumber(bytesToHex(bytes));\n}\nfunction bytesToNumberLE(bytes) {\n abytes(bytes);\n return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse()));\n}\nfunction numberToBytesBE(n, len) {\n return hexToBytes(n.toString(16).padStart(len * 2, '0'));\n}\nfunction numberToBytesLE(n, len) {\n return numberToBytesBE(n, len).reverse();\n}\n// Unpadded, rarely used\nfunction numberToVarBytesBE(n) {\n return hexToBytes(numberToHexUnpadded(n));\n}\n/**\n * Takes hex string or Uint8Array, converts to Uint8Array.\n * Validates output length.\n * Will throw error for other types.\n * @param title descriptive title for an error e.g. 'private key'\n * @param hex hex string or Uint8Array\n * @param expectedLength optional, will compare to result array's length\n * @returns\n */\nfunction ensureBytes(title, hex, expectedLength) {\n let res;\n if (typeof hex === 'string') {\n try {\n res = hexToBytes(hex);\n }\n catch (e) {\n throw new Error(title + ' must be hex string or Uint8Array, cause: ' + e);\n }\n }\n else if (isBytes(hex)) {\n // Uint8Array.from() instead of hash.slice() because node.js Buffer\n // is instance of Uint8Array, and its slice() creates **mutable** copy\n res = Uint8Array.from(hex);\n }\n else {\n throw new Error(title + ' must be hex string or Uint8Array');\n }\n const len = res.length;\n if (typeof expectedLength === 'number' && len !== expectedLength)\n throw new Error(title + ' of length ' + expectedLength + ' expected, got ' + len);\n return res;\n}\n/**\n * Copies several Uint8Arrays into one.\n */\nfunction concatBytes(...arrays) {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n// Compares 2 u8a-s in kinda constant time\nfunction equalBytes(a, b) {\n if (a.length !== b.length)\n return false;\n let diff = 0;\n for (let i = 0; i < a.length; i++)\n diff |= a[i] ^ b[i];\n return diff === 0;\n}\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nfunction utf8ToBytes(str) {\n if (typeof str !== 'string')\n throw new Error('string expected');\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n// Is positive bigint\nconst isPosBig = (n) => typeof n === 'bigint' && _0n <= n;\nfunction inRange(n, min, max) {\n return isPosBig(n) && isPosBig(min) && isPosBig(max) && min <= n && n < max;\n}\n/**\n * Asserts min <= n < max. NOTE: It's < max and not <= max.\n * @example\n * aInRange('x', x, 1n, 256n); // would assume x is in (1n..255n)\n */\nfunction aInRange(title, n, min, max) {\n // Why min <= n < max and not a (min < n < max) OR b (min <= n <= max)?\n // consider P=256n, min=0n, max=P\n // - a for min=0 would require -1: `inRange('x', x, -1n, P)`\n // - b would commonly require subtraction: `inRange('x', x, 0n, P - 1n)`\n // - our way is the cleanest: `inRange('x', x, 0n, P)\n if (!inRange(n, min, max))\n throw new Error('expected valid ' + title + ': ' + min + ' <= n < ' + max + ', got ' + n);\n}\n// Bit operations\n/**\n * Calculates amount of bits in a bigint.\n * Same as `n.toString(2).length`\n */\nfunction bitLen(n) {\n let len;\n for (len = 0; n > _0n; n >>= _1n, len += 1)\n ;\n return len;\n}\n/**\n * Gets single bit at position.\n * NOTE: first bit position is 0 (same as arrays)\n * Same as `!!+Array.from(n.toString(2)).reverse()[pos]`\n */\nfunction bitGet(n, pos) {\n return (n >> BigInt(pos)) & _1n;\n}\n/**\n * Sets single bit at position.\n */\nfunction bitSet(n, pos, value) {\n return n | ((value ? _1n : _0n) << BigInt(pos));\n}\n/**\n * Calculate mask for N bits. Not using ** operator with bigints because of old engines.\n * Same as BigInt(`0b${Array(i).fill('1').join('')}`)\n */\nconst bitMask = (n) => (_2n << BigInt(n - 1)) - _1n;\nexports.bitMask = bitMask;\n// DRBG\nconst u8n = (data) => new Uint8Array(data); // creates Uint8Array\nconst u8fr = (arr) => Uint8Array.from(arr); // another shortcut\n/**\n * Minimal HMAC-DRBG from NIST 800-90 for RFC6979 sigs.\n * @returns function that will call DRBG until 2nd arg returns something meaningful\n * @example\n * const drbg = createHmacDRBG(32, 32, hmac);\n * drbg(seed, bytesToKey); // bytesToKey must return Key or undefined\n */\nfunction createHmacDrbg(hashLen, qByteLen, hmacFn) {\n if (typeof hashLen !== 'number' || hashLen < 2)\n throw new Error('hashLen must be a number');\n if (typeof qByteLen !== 'number' || qByteLen < 2)\n throw new Error('qByteLen must be a number');\n if (typeof hmacFn !== 'function')\n throw new Error('hmacFn must be a function');\n // Step B, Step C: set hashLen to 8*ceil(hlen/8)\n let v = u8n(hashLen); // Minimal non-full-spec HMAC-DRBG from NIST 800-90 for RFC6979 sigs.\n let k = u8n(hashLen); // Steps B and C of RFC6979 3.2: set hashLen, in our case always same\n let i = 0; // Iterations counter, will throw when over 1000\n const reset = () => {\n v.fill(1);\n k.fill(0);\n i = 0;\n };\n const h = (...b) => hmacFn(k, v, ...b); // hmac(k)(v, ...values)\n const reseed = (seed = u8n()) => {\n // HMAC-DRBG reseed() function. Steps D-G\n k = h(u8fr([0x00]), seed); // k = hmac(k || v || 0x00 || seed)\n v = h(); // v = hmac(k || v)\n if (seed.length === 0)\n return;\n k = h(u8fr([0x01]), seed); // k = hmac(k || v || 0x01 || seed)\n v = h(); // v = hmac(k || v)\n };\n const gen = () => {\n // HMAC-DRBG generate() function\n if (i++ >= 1000)\n throw new Error('drbg: tried 1000 values');\n let len = 0;\n const out = [];\n while (len < qByteLen) {\n v = h();\n const sl = v.slice();\n out.push(sl);\n len += v.length;\n }\n return concatBytes(...out);\n };\n const genUntil = (seed, pred) => {\n reset();\n reseed(seed); // Steps D-G\n let res = undefined; // Step H: grind until k is in [1..n-1]\n while (!(res = pred(gen())))\n reseed();\n reset();\n return res;\n };\n return genUntil;\n}\n// Validating curves and fields\nconst validatorFns = {\n bigint: (val) => typeof val === 'bigint',\n function: (val) => typeof val === 'function',\n boolean: (val) => typeof val === 'boolean',\n string: (val) => typeof val === 'string',\n stringOrUint8Array: (val) => typeof val === 'string' || isBytes(val),\n isSafeInteger: (val) => Number.isSafeInteger(val),\n array: (val) => Array.isArray(val),\n field: (val, object) => object.Fp.isValid(val),\n hash: (val) => typeof val === 'function' && Number.isSafeInteger(val.outputLen),\n};\n// type Record = { [P in K]: T; }\nfunction validateObject(object, validators, optValidators = {}) {\n const checkField = (fieldName, type, isOptional) => {\n const checkVal = validatorFns[type];\n if (typeof checkVal !== 'function')\n throw new Error('invalid validator function');\n const val = object[fieldName];\n if (isOptional && val === undefined)\n return;\n if (!checkVal(val, object)) {\n throw new Error('param ' + String(fieldName) + ' is invalid. Expected ' + type + ', got ' + val);\n }\n };\n for (const [fieldName, type] of Object.entries(validators))\n checkField(fieldName, type, false);\n for (const [fieldName, type] of Object.entries(optValidators))\n checkField(fieldName, type, true);\n return object;\n}\n// validate type tests\n// const o: { a: number; b: number; c: number } = { a: 1, b: 5, c: 6 };\n// const z0 = validateObject(o, { a: 'isSafeInteger' }, { c: 'bigint' }); // Ok!\n// // Should fail type-check\n// const z1 = validateObject(o, { a: 'tmp' }, { c: 'zz' });\n// const z2 = validateObject(o, { a: 'isSafeInteger' }, { c: 'zz' });\n// const z3 = validateObject(o, { test: 'boolean', z: 'bug' });\n// const z4 = validateObject(o, { a: 'boolean', z: 'bug' });\n/**\n * throws not implemented error\n */\nconst notImplemented = () => {\n throw new Error('not implemented');\n};\nexports.notImplemented = notImplemented;\n/**\n * Memoizes (caches) computation result.\n * Uses WeakMap: the value is going auto-cleaned by GC after last reference is removed.\n */\nfunction memoized(fn) {\n const map = new WeakMap();\n return (arg, ...args) => {\n const val = map.get(arg);\n if (val !== undefined)\n return val;\n const computed = fn(arg, ...args);\n map.set(arg, computed);\n return computed;\n };\n}\n//# sourceMappingURL=utils.js.map","/**\n * Hex, bytes and number utilities.\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n\n// 100 lines of code in the file are duplicated from noble-hashes (utils).\n// This is OK: `abstract` directory does not use noble-hashes.\n// User may opt-in into using different hashing library. This way, noble-hashes\n// won't be included into their bundle.\nconst _0n = /* @__PURE__ */ BigInt(0);\nconst _1n = /* @__PURE__ */ BigInt(1);\nconst _2n = /* @__PURE__ */ BigInt(2);\nexport type Hex = Uint8Array | string; // hex strings are accepted for simplicity\nexport type PrivKey = Hex | bigint; // bigints are accepted to ease learning curve\nexport type CHash = {\n (message: Uint8Array | string): Uint8Array;\n blockLen: number;\n outputLen: number;\n create(opts?: { dkLen?: number }): any; // For shake\n};\nexport type FHash = (message: Uint8Array | string) => Uint8Array;\n\nexport function isBytes(a: unknown): a is Uint8Array {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n\nexport function abytes(item: unknown): void {\n if (!isBytes(item)) throw new Error('Uint8Array expected');\n}\n\nexport function abool(title: string, value: boolean): void {\n if (typeof value !== 'boolean') throw new Error(title + ' boolean expected, got ' + value);\n}\n\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) =>\n i.toString(16).padStart(2, '0')\n);\n/**\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n abytes(bytes);\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n\nexport function numberToHexUnpadded(num: number | bigint): string {\n const hex = num.toString(16);\n return hex.length & 1 ? '0' + hex : hex;\n}\n\nexport function hexToNumber(hex: string): bigint {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n return hex === '' ? _0n : BigInt('0x' + hex); // Big Endian\n}\n\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 } as const;\nfunction asciiToBase16(ch: number): number | undefined {\n if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n\n/**\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex: string): Uint8Array {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2) throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n\n// BE: Big Endian, LE: Little Endian\nexport function bytesToNumberBE(bytes: Uint8Array): bigint {\n return hexToNumber(bytesToHex(bytes));\n}\nexport function bytesToNumberLE(bytes: Uint8Array): bigint {\n abytes(bytes);\n return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse()));\n}\n\nexport function numberToBytesBE(n: number | bigint, len: number): Uint8Array {\n return hexToBytes(n.toString(16).padStart(len * 2, '0'));\n}\nexport function numberToBytesLE(n: number | bigint, len: number): Uint8Array {\n return numberToBytesBE(n, len).reverse();\n}\n// Unpadded, rarely used\nexport function numberToVarBytesBE(n: number | bigint): Uint8Array {\n return hexToBytes(numberToHexUnpadded(n));\n}\n\n/**\n * Takes hex string or Uint8Array, converts to Uint8Array.\n * Validates output length.\n * Will throw error for other types.\n * @param title descriptive title for an error e.g. 'private key'\n * @param hex hex string or Uint8Array\n * @param expectedLength optional, will compare to result array's length\n * @returns\n */\nexport function ensureBytes(title: string, hex: Hex, expectedLength?: number): Uint8Array {\n let res: Uint8Array;\n if (typeof hex === 'string') {\n try {\n res = hexToBytes(hex);\n } catch (e) {\n throw new Error(title + ' must be hex string or Uint8Array, cause: ' + e);\n }\n } else if (isBytes(hex)) {\n // Uint8Array.from() instead of hash.slice() because node.js Buffer\n // is instance of Uint8Array, and its slice() creates **mutable** copy\n res = Uint8Array.from(hex);\n } else {\n throw new Error(title + ' must be hex string or Uint8Array');\n }\n const len = res.length;\n if (typeof expectedLength === 'number' && len !== expectedLength)\n throw new Error(title + ' of length ' + expectedLength + ' expected, got ' + len);\n return res;\n}\n\n/**\n * Copies several Uint8Arrays into one.\n */\nexport function concatBytes(...arrays: Uint8Array[]): Uint8Array {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n\n// Compares 2 u8a-s in kinda constant time\nexport function equalBytes(a: Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false;\n let diff = 0;\n for (let i = 0; i < a.length; i++) diff |= a[i] ^ b[i];\n return diff === 0;\n}\n\n// Global symbols in both browsers and Node.js since v11\n// See https://github.com/microsoft/TypeScript/issues/31535\ndeclare const TextEncoder: any;\n\n/**\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nexport function utf8ToBytes(str: string): Uint8Array {\n if (typeof str !== 'string') throw new Error('string expected');\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n\n// Is positive bigint\nconst isPosBig = (n: bigint) => typeof n === 'bigint' && _0n <= n;\n\nexport function inRange(n: bigint, min: bigint, max: bigint): boolean {\n return isPosBig(n) && isPosBig(min) && isPosBig(max) && min <= n && n < max;\n}\n\n/**\n * Asserts min <= n < max. NOTE: It's < max and not <= max.\n * @example\n * aInRange('x', x, 1n, 256n); // would assume x is in (1n..255n)\n */\nexport function aInRange(title: string, n: bigint, min: bigint, max: bigint): void {\n // Why min <= n < max and not a (min < n < max) OR b (min <= n <= max)?\n // consider P=256n, min=0n, max=P\n // - a for min=0 would require -1: `inRange('x', x, -1n, P)`\n // - b would commonly require subtraction: `inRange('x', x, 0n, P - 1n)`\n // - our way is the cleanest: `inRange('x', x, 0n, P)\n if (!inRange(n, min, max))\n throw new Error('expected valid ' + title + ': ' + min + ' <= n < ' + max + ', got ' + n);\n}\n\n// Bit operations\n\n/**\n * Calculates amount of bits in a bigint.\n * Same as `n.toString(2).length`\n */\nexport function bitLen(n: bigint): number {\n let len;\n for (len = 0; n > _0n; n >>= _1n, len += 1);\n return len;\n}\n\n/**\n * Gets single bit at position.\n * NOTE: first bit position is 0 (same as arrays)\n * Same as `!!+Array.from(n.toString(2)).reverse()[pos]`\n */\nexport function bitGet(n: bigint, pos: number): bigint {\n return (n >> BigInt(pos)) & _1n;\n}\n\n/**\n * Sets single bit at position.\n */\nexport function bitSet(n: bigint, pos: number, value: boolean): bigint {\n return n | ((value ? _1n : _0n) << BigInt(pos));\n}\n\n/**\n * Calculate mask for N bits. Not using ** operator with bigints because of old engines.\n * Same as BigInt(`0b${Array(i).fill('1').join('')}`)\n */\nexport const bitMask = (n: number): bigint => (_2n << BigInt(n - 1)) - _1n;\n\n// DRBG\n\nconst u8n = (data?: any) => new Uint8Array(data); // creates Uint8Array\nconst u8fr = (arr: any) => Uint8Array.from(arr); // another shortcut\ntype Pred = (v: Uint8Array) => T | undefined;\n/**\n * Minimal HMAC-DRBG from NIST 800-90 for RFC6979 sigs.\n * @returns function that will call DRBG until 2nd arg returns something meaningful\n * @example\n * const drbg = createHmacDRBG(32, 32, hmac);\n * drbg(seed, bytesToKey); // bytesToKey must return Key or undefined\n */\nexport function createHmacDrbg(\n hashLen: number,\n qByteLen: number,\n hmacFn: (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array\n): (seed: Uint8Array, predicate: Pred) => T {\n if (typeof hashLen !== 'number' || hashLen < 2) throw new Error('hashLen must be a number');\n if (typeof qByteLen !== 'number' || qByteLen < 2) throw new Error('qByteLen must be a number');\n if (typeof hmacFn !== 'function') throw new Error('hmacFn must be a function');\n // Step B, Step C: set hashLen to 8*ceil(hlen/8)\n let v = u8n(hashLen); // Minimal non-full-spec HMAC-DRBG from NIST 800-90 for RFC6979 sigs.\n let k = u8n(hashLen); // Steps B and C of RFC6979 3.2: set hashLen, in our case always same\n let i = 0; // Iterations counter, will throw when over 1000\n const reset = () => {\n v.fill(1);\n k.fill(0);\n i = 0;\n };\n const h = (...b: Uint8Array[]) => hmacFn(k, v, ...b); // hmac(k)(v, ...values)\n const reseed = (seed = u8n()) => {\n // HMAC-DRBG reseed() function. Steps D-G\n k = h(u8fr([0x00]), seed); // k = hmac(k || v || 0x00 || seed)\n v = h(); // v = hmac(k || v)\n if (seed.length === 0) return;\n k = h(u8fr([0x01]), seed); // k = hmac(k || v || 0x01 || seed)\n v = h(); // v = hmac(k || v)\n };\n const gen = () => {\n // HMAC-DRBG generate() function\n if (i++ >= 1000) throw new Error('drbg: tried 1000 values');\n let len = 0;\n const out: Uint8Array[] = [];\n while (len < qByteLen) {\n v = h();\n const sl = v.slice();\n out.push(sl);\n len += v.length;\n }\n return concatBytes(...out);\n };\n const genUntil = (seed: Uint8Array, pred: Pred): T => {\n reset();\n reseed(seed); // Steps D-G\n let res: T | undefined = undefined; // Step H: grind until k is in [1..n-1]\n while (!(res = pred(gen()))) reseed();\n reset();\n return res;\n };\n return genUntil;\n}\n\n// Validating curves and fields\n\nconst validatorFns = {\n bigint: (val: any): boolean => typeof val === 'bigint',\n function: (val: any): boolean => typeof val === 'function',\n boolean: (val: any): boolean => typeof val === 'boolean',\n string: (val: any): boolean => typeof val === 'string',\n stringOrUint8Array: (val: any): boolean => typeof val === 'string' || isBytes(val),\n isSafeInteger: (val: any): boolean => Number.isSafeInteger(val),\n array: (val: any): boolean => Array.isArray(val),\n field: (val: any, object: any): any => (object as any).Fp.isValid(val),\n hash: (val: any): boolean => typeof val === 'function' && Number.isSafeInteger(val.outputLen),\n} as const;\ntype Validator = keyof typeof validatorFns;\ntype ValMap> = { [K in keyof T]?: Validator };\n// type Record = { [P in K]: T; }\n\nexport function validateObject>(\n object: T,\n validators: ValMap,\n optValidators: ValMap = {}\n): T {\n const checkField = (fieldName: keyof T, type: Validator, isOptional: boolean) => {\n const checkVal = validatorFns[type];\n if (typeof checkVal !== 'function') throw new Error('invalid validator function');\n\n const val = object[fieldName as keyof typeof object];\n if (isOptional && val === undefined) return;\n if (!checkVal(val, object)) {\n throw new Error(\n 'param ' + String(fieldName) + ' is invalid. Expected ' + type + ', got ' + val\n );\n }\n };\n for (const [fieldName, type] of Object.entries(validators)) checkField(fieldName, type!, false);\n for (const [fieldName, type] of Object.entries(optValidators)) checkField(fieldName, type!, true);\n return object;\n}\n// validate type tests\n// const o: { a: number; b: number; c: number } = { a: 1, b: 5, c: 6 };\n// const z0 = validateObject(o, { a: 'isSafeInteger' }, { c: 'bigint' }); // Ok!\n// // Should fail type-check\n// const z1 = validateObject(o, { a: 'tmp' }, { c: 'zz' });\n// const z2 = validateObject(o, { a: 'isSafeInteger' }, { c: 'zz' });\n// const z3 = validateObject(o, { test: 'boolean', z: 'bug' });\n// const z4 = validateObject(o, { a: 'boolean', z: 'bug' });\n\n/**\n * throws not implemented error\n */\nexport const notImplemented = (): never => {\n throw new Error('not implemented');\n};\n\n/**\n * Memoizes (caches) computation result.\n * Uses WeakMap: the value is going auto-cleaned by GC after last reference is removed.\n */\nexport function memoized(\n fn: (arg: T, ...args: O) => R\n): (arg: T, ...args: O) => R {\n const map = new WeakMap();\n return (arg: T, ...args: O): R => {\n const val = map.get(arg);\n if (val !== undefined) return val;\n const computed = fn(arg, ...args);\n map.set(arg, computed);\n return computed;\n };\n}\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.twistedEdwards = twistedEdwards;\n/**\n * Twisted Edwards curve. The formula is: ax² + y² = 1 + dx²y².\n * For design rationale of types / exports, see weierstrass module documentation.\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nconst curve_js_1 = require(\"./curve.js\");\nconst modular_js_1 = require(\"./modular.js\");\nconst ut = require(\"./utils.js\");\nconst utils_js_1 = require(\"./utils.js\");\n// Be friendly to bad ECMAScript parsers by not using bigint literals\n// prettier-ignore\nconst _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _8n = BigInt(8);\n// verification rule is either zip215 or rfc8032 / nist186-5. Consult fromHex:\nconst VERIFY_DEFAULT = { zip215: true };\nfunction validateOpts(curve) {\n const opts = (0, curve_js_1.validateBasic)(curve);\n ut.validateObject(curve, {\n hash: 'function',\n a: 'bigint',\n d: 'bigint',\n randomBytes: 'function',\n }, {\n adjustScalarBytes: 'function',\n domain: 'function',\n uvRatio: 'function',\n mapToCurve: 'function',\n });\n // Set defaults\n return Object.freeze({ ...opts });\n}\n/**\n * Creates Twisted Edwards curve with EdDSA signatures.\n * @example\n * import { Field } from '@noble/curves/abstract/modular';\n * // Before that, define BigInt-s: a, d, p, n, Gx, Gy, h\n * const curve = twistedEdwards({ a, d, Fp: Field(p), n, Gx, Gy, h })\n */\nfunction twistedEdwards(curveDef) {\n const CURVE = validateOpts(curveDef);\n const { Fp, n: CURVE_ORDER, prehash: prehash, hash: cHash, randomBytes, nByteLength, h: cofactor, } = CURVE;\n // Important:\n // There are some places where Fp.BYTES is used instead of nByteLength.\n // So far, everything has been tested with curves of Fp.BYTES == nByteLength.\n // TODO: test and find curves which behave otherwise.\n const MASK = _2n << (BigInt(nByteLength * 8) - _1n);\n const modP = Fp.create; // Function overrides\n const Fn = (0, modular_js_1.Field)(CURVE.n, CURVE.nBitLength);\n // sqrt(u/v)\n const uvRatio = CURVE.uvRatio ||\n ((u, v) => {\n try {\n return { isValid: true, value: Fp.sqrt(u * Fp.inv(v)) };\n }\n catch (e) {\n return { isValid: false, value: _0n };\n }\n });\n const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes) => bytes); // NOOP\n const domain = CURVE.domain ||\n ((data, ctx, phflag) => {\n (0, utils_js_1.abool)('phflag', phflag);\n if (ctx.length || phflag)\n throw new Error('Contexts/pre-hash are not supported');\n return data;\n }); // NOOP\n // 0 <= n < MASK\n // Coordinates larger than Fp.ORDER are allowed for zip215\n function aCoordinate(title, n) {\n ut.aInRange('coordinate ' + title, n, _0n, MASK);\n }\n function assertPoint(other) {\n if (!(other instanceof Point))\n throw new Error('ExtendedPoint expected');\n }\n // Converts Extended point to default (x, y) coordinates.\n // Can accept precomputed Z^-1 - for example, from invertBatch.\n const toAffineMemo = (0, utils_js_1.memoized)((p, iz) => {\n const { ex: x, ey: y, ez: z } = p;\n const is0 = p.is0();\n if (iz == null)\n iz = is0 ? _8n : Fp.inv(z); // 8 was chosen arbitrarily\n const ax = modP(x * iz);\n const ay = modP(y * iz);\n const zz = modP(z * iz);\n if (is0)\n return { x: _0n, y: _1n };\n if (zz !== _1n)\n throw new Error('invZ was invalid');\n return { x: ax, y: ay };\n });\n const assertValidMemo = (0, utils_js_1.memoized)((p) => {\n const { a, d } = CURVE;\n if (p.is0())\n throw new Error('bad point: ZERO'); // TODO: optimize, with vars below?\n // Equation in affine coordinates: ax² + y² = 1 + dx²y²\n // Equation in projective coordinates (X/Z, Y/Z, Z): (aX² + Y²)Z² = Z⁴ + dX²Y²\n const { ex: X, ey: Y, ez: Z, et: T } = p;\n const X2 = modP(X * X); // X²\n const Y2 = modP(Y * Y); // Y²\n const Z2 = modP(Z * Z); // Z²\n const Z4 = modP(Z2 * Z2); // Z⁴\n const aX2 = modP(X2 * a); // aX²\n const left = modP(Z2 * modP(aX2 + Y2)); // (aX² + Y²)Z²\n const right = modP(Z4 + modP(d * modP(X2 * Y2))); // Z⁴ + dX²Y²\n if (left !== right)\n throw new Error('bad point: equation left != right (1)');\n // In Extended coordinates we also have T, which is x*y=T/Z: check X*Y == Z*T\n const XY = modP(X * Y);\n const ZT = modP(Z * T);\n if (XY !== ZT)\n throw new Error('bad point: equation left != right (2)');\n return true;\n });\n // Extended Point works in extended coordinates: (x, y, z, t) ∋ (x=x/z, y=y/z, t=xy).\n // https://en.wikipedia.org/wiki/Twisted_Edwards_curve#Extended_coordinates\n class Point {\n constructor(ex, ey, ez, et) {\n this.ex = ex;\n this.ey = ey;\n this.ez = ez;\n this.et = et;\n aCoordinate('x', ex);\n aCoordinate('y', ey);\n aCoordinate('z', ez);\n aCoordinate('t', et);\n Object.freeze(this);\n }\n get x() {\n return this.toAffine().x;\n }\n get y() {\n return this.toAffine().y;\n }\n static fromAffine(p) {\n if (p instanceof Point)\n throw new Error('extended point not allowed');\n const { x, y } = p || {};\n aCoordinate('x', x);\n aCoordinate('y', y);\n return new Point(x, y, _1n, modP(x * y));\n }\n static normalizeZ(points) {\n const toInv = Fp.invertBatch(points.map((p) => p.ez));\n return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine);\n }\n // Multiscalar Multiplication\n static msm(points, scalars) {\n return (0, curve_js_1.pippenger)(Point, Fn, points, scalars);\n }\n // \"Private method\", don't use it directly\n _setWindowSize(windowSize) {\n wnaf.setWindowSize(this, windowSize);\n }\n // Not required for fromHex(), which always creates valid points.\n // Could be useful for fromAffine().\n assertValidity() {\n assertValidMemo(this);\n }\n // Compare one point to another.\n equals(other) {\n assertPoint(other);\n const { ex: X1, ey: Y1, ez: Z1 } = this;\n const { ex: X2, ey: Y2, ez: Z2 } = other;\n const X1Z2 = modP(X1 * Z2);\n const X2Z1 = modP(X2 * Z1);\n const Y1Z2 = modP(Y1 * Z2);\n const Y2Z1 = modP(Y2 * Z1);\n return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;\n }\n is0() {\n return this.equals(Point.ZERO);\n }\n negate() {\n // Flips point sign to a negative one (-x, y in affine coords)\n return new Point(modP(-this.ex), this.ey, this.ez, modP(-this.et));\n }\n // Fast algo for doubling Extended Point.\n // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#doubling-dbl-2008-hwcd\n // Cost: 4M + 4S + 1*a + 6add + 1*2.\n double() {\n const { a } = CURVE;\n const { ex: X1, ey: Y1, ez: Z1 } = this;\n const A = modP(X1 * X1); // A = X12\n const B = modP(Y1 * Y1); // B = Y12\n const C = modP(_2n * modP(Z1 * Z1)); // C = 2*Z12\n const D = modP(a * A); // D = a*A\n const x1y1 = X1 + Y1;\n const E = modP(modP(x1y1 * x1y1) - A - B); // E = (X1+Y1)2-A-B\n const G = D + B; // G = D+B\n const F = G - C; // F = G-C\n const H = D - B; // H = D-B\n const X3 = modP(E * F); // X3 = E*F\n const Y3 = modP(G * H); // Y3 = G*H\n const T3 = modP(E * H); // T3 = E*H\n const Z3 = modP(F * G); // Z3 = F*G\n return new Point(X3, Y3, Z3, T3);\n }\n // Fast algo for adding 2 Extended Points.\n // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd\n // Cost: 9M + 1*a + 1*d + 7add.\n add(other) {\n assertPoint(other);\n const { a, d } = CURVE;\n const { ex: X1, ey: Y1, ez: Z1, et: T1 } = this;\n const { ex: X2, ey: Y2, ez: Z2, et: T2 } = other;\n // Faster algo for adding 2 Extended Points when curve's a=-1.\n // http://hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html#addition-add-2008-hwcd-4\n // Cost: 8M + 8add + 2*2.\n // Note: It does not check whether the `other` point is valid.\n if (a === BigInt(-1)) {\n const A = modP((Y1 - X1) * (Y2 + X2));\n const B = modP((Y1 + X1) * (Y2 - X2));\n const F = modP(B - A);\n if (F === _0n)\n return this.double(); // Same point. Tests say it doesn't affect timing\n const C = modP(Z1 * _2n * T2);\n const D = modP(T1 * _2n * Z2);\n const E = D + C;\n const G = B + A;\n const H = D - C;\n const X3 = modP(E * F);\n const Y3 = modP(G * H);\n const T3 = modP(E * H);\n const Z3 = modP(F * G);\n return new Point(X3, Y3, Z3, T3);\n }\n const A = modP(X1 * X2); // A = X1*X2\n const B = modP(Y1 * Y2); // B = Y1*Y2\n const C = modP(T1 * d * T2); // C = T1*d*T2\n const D = modP(Z1 * Z2); // D = Z1*Z2\n const E = modP((X1 + Y1) * (X2 + Y2) - A - B); // E = (X1+Y1)*(X2+Y2)-A-B\n const F = D - C; // F = D-C\n const G = D + C; // G = D+C\n const H = modP(B - a * A); // H = B-a*A\n const X3 = modP(E * F); // X3 = E*F\n const Y3 = modP(G * H); // Y3 = G*H\n const T3 = modP(E * H); // T3 = E*H\n const Z3 = modP(F * G); // Z3 = F*G\n return new Point(X3, Y3, Z3, T3);\n }\n subtract(other) {\n return this.add(other.negate());\n }\n wNAF(n) {\n return wnaf.wNAFCached(this, n, Point.normalizeZ);\n }\n // Constant-time multiplication.\n multiply(scalar) {\n const n = scalar;\n ut.aInRange('scalar', n, _1n, CURVE_ORDER); // 1 <= scalar < L\n const { p, f } = this.wNAF(n);\n return Point.normalizeZ([p, f])[0];\n }\n // Non-constant-time multiplication. Uses double-and-add algorithm.\n // It's faster, but should only be used when you don't care about\n // an exposed private key e.g. sig verification.\n // Does NOT allow scalars higher than CURVE.n.\n // Accepts optional accumulator to merge with multiply (important for sparse scalars)\n multiplyUnsafe(scalar, acc = Point.ZERO) {\n const n = scalar;\n ut.aInRange('scalar', n, _0n, CURVE_ORDER); // 0 <= scalar < L\n if (n === _0n)\n return I;\n if (this.is0() || n === _1n)\n return this;\n return wnaf.wNAFCachedUnsafe(this, n, Point.normalizeZ, acc);\n }\n // Checks if point is of small order.\n // If you add something to small order point, you will have \"dirty\"\n // point with torsion component.\n // Multiplies point by cofactor and checks if the result is 0.\n isSmallOrder() {\n return this.multiplyUnsafe(cofactor).is0();\n }\n // Multiplies point by curve order and checks if the result is 0.\n // Returns `false` is the point is dirty.\n isTorsionFree() {\n return wnaf.unsafeLadder(this, CURVE_ORDER).is0();\n }\n // Converts Extended point to default (x, y) coordinates.\n // Can accept precomputed Z^-1 - for example, from invertBatch.\n toAffine(iz) {\n return toAffineMemo(this, iz);\n }\n clearCofactor() {\n const { h: cofactor } = CURVE;\n if (cofactor === _1n)\n return this;\n return this.multiplyUnsafe(cofactor);\n }\n // Converts hash string or Uint8Array to Point.\n // Uses algo from RFC8032 5.1.3.\n static fromHex(hex, zip215 = false) {\n const { d, a } = CURVE;\n const len = Fp.BYTES;\n hex = (0, utils_js_1.ensureBytes)('pointHex', hex, len); // copy hex to a new array\n (0, utils_js_1.abool)('zip215', zip215);\n const normed = hex.slice(); // copy again, we'll manipulate it\n const lastByte = hex[len - 1]; // select last byte\n normed[len - 1] = lastByte & ~0x80; // clear last bit\n const y = ut.bytesToNumberLE(normed);\n // zip215=true is good for consensus-critical apps. =false follows RFC8032 / NIST186-5.\n // RFC8032 prohibits >= p, but ZIP215 doesn't\n // zip215=true: 0 <= y < MASK (2^256 for ed25519)\n // zip215=false: 0 <= y < P (2^255-19 for ed25519)\n const max = zip215 ? MASK : Fp.ORDER;\n ut.aInRange('pointHex.y', y, _0n, max);\n // Ed25519: x² = (y²-1)/(dy²+1) mod p. Ed448: x² = (y²-1)/(dy²-1) mod p. Generic case:\n // ax²+y²=1+dx²y² => y²-1=dx²y²-ax² => y²-1=x²(dy²-a) => x²=(y²-1)/(dy²-a)\n const y2 = modP(y * y); // denominator is always non-0 mod p.\n const u = modP(y2 - _1n); // u = y² - 1\n const v = modP(d * y2 - a); // v = d y² + 1.\n let { isValid, value: x } = uvRatio(u, v); // √(u/v)\n if (!isValid)\n throw new Error('Point.fromHex: invalid y coordinate');\n const isXOdd = (x & _1n) === _1n; // There are 2 square roots. Use x_0 bit to select proper\n const isLastByteOdd = (lastByte & 0x80) !== 0; // x_0, last bit\n if (!zip215 && x === _0n && isLastByteOdd)\n // if x=0 and x_0 = 1, fail\n throw new Error('Point.fromHex: x=0 and x_0=1');\n if (isLastByteOdd !== isXOdd)\n x = modP(-x); // if x_0 != x mod 2, set x = p-x\n return Point.fromAffine({ x, y });\n }\n static fromPrivateKey(privKey) {\n return getExtendedPublicKey(privKey).point;\n }\n toRawBytes() {\n const { x, y } = this.toAffine();\n const bytes = ut.numberToBytesLE(y, Fp.BYTES); // each y has 2 x values (x, -y)\n bytes[bytes.length - 1] |= x & _1n ? 0x80 : 0; // when compressing, it's enough to store y\n return bytes; // and use the last byte to encode sign of x\n }\n toHex() {\n return ut.bytesToHex(this.toRawBytes()); // Same as toRawBytes, but returns string.\n }\n }\n Point.BASE = new Point(CURVE.Gx, CURVE.Gy, _1n, modP(CURVE.Gx * CURVE.Gy));\n Point.ZERO = new Point(_0n, _1n, _1n, _0n); // 0, 1, 1, 0\n const { BASE: G, ZERO: I } = Point;\n const wnaf = (0, curve_js_1.wNAF)(Point, nByteLength * 8);\n function modN(a) {\n return (0, modular_js_1.mod)(a, CURVE_ORDER);\n }\n // Little-endian SHA512 with modulo n\n function modN_LE(hash) {\n return modN(ut.bytesToNumberLE(hash));\n }\n /** Convenience method that creates public key and other stuff. RFC8032 5.1.5 */\n function getExtendedPublicKey(key) {\n const len = Fp.BYTES;\n key = (0, utils_js_1.ensureBytes)('private key', key, len);\n // Hash private key with curve's hash function to produce uniformingly random input\n // Check byte lengths: ensure(64, h(ensure(32, key)))\n const hashed = (0, utils_js_1.ensureBytes)('hashed private key', cHash(key), 2 * len);\n const head = adjustScalarBytes(hashed.slice(0, len)); // clear first half bits, produce FE\n const prefix = hashed.slice(len, 2 * len); // second half is called key prefix (5.1.6)\n const scalar = modN_LE(head); // The actual private scalar\n const point = G.multiply(scalar); // Point on Edwards curve aka public key\n const pointBytes = point.toRawBytes(); // Uint8Array representation\n return { head, prefix, scalar, point, pointBytes };\n }\n // Calculates EdDSA pub key. RFC8032 5.1.5. Privkey is hashed. Use first half with 3 bits cleared\n function getPublicKey(privKey) {\n return getExtendedPublicKey(privKey).pointBytes;\n }\n // int('LE', SHA512(dom2(F, C) || msgs)) mod N\n function hashDomainToScalar(context = new Uint8Array(), ...msgs) {\n const msg = ut.concatBytes(...msgs);\n return modN_LE(cHash(domain(msg, (0, utils_js_1.ensureBytes)('context', context), !!prehash)));\n }\n /** Signs message with privateKey. RFC8032 5.1.6 */\n function sign(msg, privKey, options = {}) {\n msg = (0, utils_js_1.ensureBytes)('message', msg);\n if (prehash)\n msg = prehash(msg); // for ed25519ph etc.\n const { prefix, scalar, pointBytes } = getExtendedPublicKey(privKey);\n const r = hashDomainToScalar(options.context, prefix, msg); // r = dom2(F, C) || prefix || PH(M)\n const R = G.multiply(r).toRawBytes(); // R = rG\n const k = hashDomainToScalar(options.context, R, pointBytes, msg); // R || A || PH(M)\n const s = modN(r + k * scalar); // S = (r + k * s) mod L\n ut.aInRange('signature.s', s, _0n, CURVE_ORDER); // 0 <= s < l\n const res = ut.concatBytes(R, ut.numberToBytesLE(s, Fp.BYTES));\n return (0, utils_js_1.ensureBytes)('result', res, Fp.BYTES * 2); // 64-byte signature\n }\n const verifyOpts = VERIFY_DEFAULT;\n /**\n * Verifies EdDSA signature against message and public key. RFC8032 5.1.7.\n * An extended group equation is checked.\n */\n function verify(sig, msg, publicKey, options = verifyOpts) {\n const { context, zip215 } = options;\n const len = Fp.BYTES; // Verifies EdDSA signature against message and public key. RFC8032 5.1.7.\n sig = (0, utils_js_1.ensureBytes)('signature', sig, 2 * len); // An extended group equation is checked.\n msg = (0, utils_js_1.ensureBytes)('message', msg);\n publicKey = (0, utils_js_1.ensureBytes)('publicKey', publicKey, len);\n if (zip215 !== undefined)\n (0, utils_js_1.abool)('zip215', zip215);\n if (prehash)\n msg = prehash(msg); // for ed25519ph, etc\n const s = ut.bytesToNumberLE(sig.slice(len, 2 * len));\n let A, R, SB;\n try {\n // zip215=true is good for consensus-critical apps. =false follows RFC8032 / NIST186-5.\n // zip215=true: 0 <= y < MASK (2^256 for ed25519)\n // zip215=false: 0 <= y < P (2^255-19 for ed25519)\n A = Point.fromHex(publicKey, zip215);\n R = Point.fromHex(sig.slice(0, len), zip215);\n SB = G.multiplyUnsafe(s); // 0 <= s < l is done inside\n }\n catch (error) {\n return false;\n }\n if (!zip215 && A.isSmallOrder())\n return false;\n const k = hashDomainToScalar(context, R.toRawBytes(), A.toRawBytes(), msg);\n const RkA = R.add(A.multiplyUnsafe(k));\n // Extended group equation\n // [8][S]B = [8]R + [8][k]A'\n return RkA.subtract(SB).clearCofactor().equals(Point.ZERO);\n }\n G._setWindowSize(8); // Enable precomputes. Slows down first publicKey computation by 20ms.\n const utils = {\n getExtendedPublicKey,\n // ed25519 private keys are uniform 32b. No need to check for modulo bias, like in secp256k1.\n randomPrivateKey: () => randomBytes(Fp.BYTES),\n /**\n * We're doing scalar multiplication (used in getPublicKey etc) with precomputed BASE_POINT\n * values. This slows down first getPublicKey() by milliseconds (see Speed section),\n * but allows to speed-up subsequent getPublicKey() calls up to 20x.\n * @param windowSize 2, 4, 8, 16\n */\n precompute(windowSize = 8, point = Point.BASE) {\n point._setWindowSize(windowSize);\n point.multiply(BigInt(3));\n return point;\n },\n };\n return {\n CURVE,\n getPublicKey,\n sign,\n verify,\n ExtendedPoint: Point,\n utils,\n };\n}\n//# sourceMappingURL=edwards.js.map","/**\n * Twisted Edwards curve. The formula is: ax² + y² = 1 + dx²y².\n * For design rationale of types / exports, see weierstrass module documentation.\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nimport {\n type AffinePoint,\n type BasicCurve,\n type Group,\n type GroupConstructor,\n pippenger,\n validateBasic,\n wNAF,\n} from './curve.js';\nimport { Field, mod } from './modular.js';\nimport * as ut from './utils.js';\nimport { abool, ensureBytes, type FHash, type Hex, memoized } from './utils.js';\n\n// Be friendly to bad ECMAScript parsers by not using bigint literals\n// prettier-ignore\nconst _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _8n = BigInt(8);\n\n/** Edwards curves must declare params a & d. */\nexport type CurveType = BasicCurve & {\n a: bigint; // curve param a\n d: bigint; // curve param d\n hash: FHash; // Hashing\n randomBytes: (bytesLength?: number) => Uint8Array; // CSPRNG\n adjustScalarBytes?: (bytes: Uint8Array) => Uint8Array; // clears bits to get valid field elemtn\n domain?: (data: Uint8Array, ctx: Uint8Array, phflag: boolean) => Uint8Array; // Used for hashing\n uvRatio?: (u: bigint, v: bigint) => { isValid: boolean; value: bigint }; // Ratio √(u/v)\n prehash?: FHash; // RFC 8032 pre-hashing of messages to sign() / verify()\n mapToCurve?: (scalar: bigint[]) => AffinePoint; // for hash-to-curve standard\n};\n\nexport type CurveTypeWithLength = Readonly;\n\n// verification rule is either zip215 or rfc8032 / nist186-5. Consult fromHex:\nconst VERIFY_DEFAULT = { zip215: true };\n\nfunction validateOpts(curve: CurveType): CurveTypeWithLength {\n const opts = validateBasic(curve);\n ut.validateObject(\n curve,\n {\n hash: 'function',\n a: 'bigint',\n d: 'bigint',\n randomBytes: 'function',\n },\n {\n adjustScalarBytes: 'function',\n domain: 'function',\n uvRatio: 'function',\n mapToCurve: 'function',\n }\n );\n // Set defaults\n return Object.freeze({ ...opts } as const);\n}\n\n/** Instance of Extended Point with coordinates in X, Y, Z, T. */\nexport interface ExtPointType extends Group {\n readonly ex: bigint;\n readonly ey: bigint;\n readonly ez: bigint;\n readonly et: bigint;\n get x(): bigint;\n get y(): bigint;\n assertValidity(): void;\n multiply(scalar: bigint): ExtPointType;\n multiplyUnsafe(scalar: bigint): ExtPointType;\n isSmallOrder(): boolean;\n isTorsionFree(): boolean;\n clearCofactor(): ExtPointType;\n toAffine(iz?: bigint): AffinePoint;\n toRawBytes(isCompressed?: boolean): Uint8Array;\n toHex(isCompressed?: boolean): string;\n _setWindowSize(windowSize: number): void;\n}\n/** Static methods of Extended Point with coordinates in X, Y, Z, T. */\nexport interface ExtPointConstructor extends GroupConstructor {\n new (x: bigint, y: bigint, z: bigint, t: bigint): ExtPointType;\n fromAffine(p: AffinePoint): ExtPointType;\n fromHex(hex: Hex): ExtPointType;\n fromPrivateKey(privateKey: Hex): ExtPointType;\n msm(points: ExtPointType[], scalars: bigint[]): ExtPointType;\n}\n\n/**\n * Edwards Curve interface.\n * Main methods: `getPublicKey(priv)`, `sign(msg, priv)`, `verify(sig, msg, pub)`.\n */\nexport type CurveFn = {\n CURVE: ReturnType;\n getPublicKey: (privateKey: Hex) => Uint8Array;\n sign: (message: Hex, privateKey: Hex, options?: { context?: Hex }) => Uint8Array;\n verify: (\n sig: Hex,\n message: Hex,\n publicKey: Hex,\n options?: { context?: Hex; zip215: boolean }\n ) => boolean;\n ExtendedPoint: ExtPointConstructor;\n utils: {\n randomPrivateKey: () => Uint8Array;\n getExtendedPublicKey: (key: Hex) => {\n head: Uint8Array;\n prefix: Uint8Array;\n scalar: bigint;\n point: ExtPointType;\n pointBytes: Uint8Array;\n };\n precompute: (windowSize?: number, point?: ExtPointType) => ExtPointType;\n };\n};\n\n/**\n * Creates Twisted Edwards curve with EdDSA signatures.\n * @example\n * import { Field } from '@noble/curves/abstract/modular';\n * // Before that, define BigInt-s: a, d, p, n, Gx, Gy, h\n * const curve = twistedEdwards({ a, d, Fp: Field(p), n, Gx, Gy, h })\n */\nexport function twistedEdwards(curveDef: CurveType): CurveFn {\n const CURVE = validateOpts(curveDef) as ReturnType;\n const {\n Fp,\n n: CURVE_ORDER,\n prehash: prehash,\n hash: cHash,\n randomBytes,\n nByteLength,\n h: cofactor,\n } = CURVE;\n // Important:\n // There are some places where Fp.BYTES is used instead of nByteLength.\n // So far, everything has been tested with curves of Fp.BYTES == nByteLength.\n // TODO: test and find curves which behave otherwise.\n const MASK = _2n << (BigInt(nByteLength * 8) - _1n);\n const modP = Fp.create; // Function overrides\n const Fn = Field(CURVE.n, CURVE.nBitLength);\n\n // sqrt(u/v)\n const uvRatio =\n CURVE.uvRatio ||\n ((u: bigint, v: bigint) => {\n try {\n return { isValid: true, value: Fp.sqrt(u * Fp.inv(v)) };\n } catch (e) {\n return { isValid: false, value: _0n };\n }\n });\n const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes: Uint8Array) => bytes); // NOOP\n const domain =\n CURVE.domain ||\n ((data: Uint8Array, ctx: Uint8Array, phflag: boolean) => {\n abool('phflag', phflag);\n if (ctx.length || phflag) throw new Error('Contexts/pre-hash are not supported');\n return data;\n }); // NOOP\n // 0 <= n < MASK\n // Coordinates larger than Fp.ORDER are allowed for zip215\n function aCoordinate(title: string, n: bigint) {\n ut.aInRange('coordinate ' + title, n, _0n, MASK);\n }\n\n function assertPoint(other: unknown) {\n if (!(other instanceof Point)) throw new Error('ExtendedPoint expected');\n }\n // Converts Extended point to default (x, y) coordinates.\n // Can accept precomputed Z^-1 - for example, from invertBatch.\n const toAffineMemo = memoized((p: Point, iz?: bigint): AffinePoint => {\n const { ex: x, ey: y, ez: z } = p;\n const is0 = p.is0();\n if (iz == null) iz = is0 ? _8n : (Fp.inv(z) as bigint); // 8 was chosen arbitrarily\n const ax = modP(x * iz);\n const ay = modP(y * iz);\n const zz = modP(z * iz);\n if (is0) return { x: _0n, y: _1n };\n if (zz !== _1n) throw new Error('invZ was invalid');\n return { x: ax, y: ay };\n });\n const assertValidMemo = memoized((p: Point) => {\n const { a, d } = CURVE;\n if (p.is0()) throw new Error('bad point: ZERO'); // TODO: optimize, with vars below?\n // Equation in affine coordinates: ax² + y² = 1 + dx²y²\n // Equation in projective coordinates (X/Z, Y/Z, Z): (aX² + Y²)Z² = Z⁴ + dX²Y²\n const { ex: X, ey: Y, ez: Z, et: T } = p;\n const X2 = modP(X * X); // X²\n const Y2 = modP(Y * Y); // Y²\n const Z2 = modP(Z * Z); // Z²\n const Z4 = modP(Z2 * Z2); // Z⁴\n const aX2 = modP(X2 * a); // aX²\n const left = modP(Z2 * modP(aX2 + Y2)); // (aX² + Y²)Z²\n const right = modP(Z4 + modP(d * modP(X2 * Y2))); // Z⁴ + dX²Y²\n if (left !== right) throw new Error('bad point: equation left != right (1)');\n // In Extended coordinates we also have T, which is x*y=T/Z: check X*Y == Z*T\n const XY = modP(X * Y);\n const ZT = modP(Z * T);\n if (XY !== ZT) throw new Error('bad point: equation left != right (2)');\n return true;\n });\n\n // Extended Point works in extended coordinates: (x, y, z, t) ∋ (x=x/z, y=y/z, t=xy).\n // https://en.wikipedia.org/wiki/Twisted_Edwards_curve#Extended_coordinates\n class Point implements ExtPointType {\n static readonly BASE = new Point(CURVE.Gx, CURVE.Gy, _1n, modP(CURVE.Gx * CURVE.Gy));\n static readonly ZERO = new Point(_0n, _1n, _1n, _0n); // 0, 1, 1, 0\n\n constructor(\n readonly ex: bigint,\n readonly ey: bigint,\n readonly ez: bigint,\n readonly et: bigint\n ) {\n aCoordinate('x', ex);\n aCoordinate('y', ey);\n aCoordinate('z', ez);\n aCoordinate('t', et);\n Object.freeze(this);\n }\n\n get x(): bigint {\n return this.toAffine().x;\n }\n get y(): bigint {\n return this.toAffine().y;\n }\n\n static fromAffine(p: AffinePoint): Point {\n if (p instanceof Point) throw new Error('extended point not allowed');\n const { x, y } = p || {};\n aCoordinate('x', x);\n aCoordinate('y', y);\n return new Point(x, y, _1n, modP(x * y));\n }\n static normalizeZ(points: Point[]): Point[] {\n const toInv = Fp.invertBatch(points.map((p) => p.ez));\n return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine);\n }\n // Multiscalar Multiplication\n static msm(points: Point[], scalars: bigint[]): Point {\n return pippenger(Point, Fn, points, scalars);\n }\n\n // \"Private method\", don't use it directly\n _setWindowSize(windowSize: number) {\n wnaf.setWindowSize(this, windowSize);\n }\n // Not required for fromHex(), which always creates valid points.\n // Could be useful for fromAffine().\n assertValidity(): void {\n assertValidMemo(this);\n }\n\n // Compare one point to another.\n equals(other: Point): boolean {\n assertPoint(other);\n const { ex: X1, ey: Y1, ez: Z1 } = this;\n const { ex: X2, ey: Y2, ez: Z2 } = other;\n const X1Z2 = modP(X1 * Z2);\n const X2Z1 = modP(X2 * Z1);\n const Y1Z2 = modP(Y1 * Z2);\n const Y2Z1 = modP(Y2 * Z1);\n return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;\n }\n\n is0(): boolean {\n return this.equals(Point.ZERO);\n }\n\n negate(): Point {\n // Flips point sign to a negative one (-x, y in affine coords)\n return new Point(modP(-this.ex), this.ey, this.ez, modP(-this.et));\n }\n\n // Fast algo for doubling Extended Point.\n // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#doubling-dbl-2008-hwcd\n // Cost: 4M + 4S + 1*a + 6add + 1*2.\n double(): Point {\n const { a } = CURVE;\n const { ex: X1, ey: Y1, ez: Z1 } = this;\n const A = modP(X1 * X1); // A = X12\n const B = modP(Y1 * Y1); // B = Y12\n const C = modP(_2n * modP(Z1 * Z1)); // C = 2*Z12\n const D = modP(a * A); // D = a*A\n const x1y1 = X1 + Y1;\n const E = modP(modP(x1y1 * x1y1) - A - B); // E = (X1+Y1)2-A-B\n const G = D + B; // G = D+B\n const F = G - C; // F = G-C\n const H = D - B; // H = D-B\n const X3 = modP(E * F); // X3 = E*F\n const Y3 = modP(G * H); // Y3 = G*H\n const T3 = modP(E * H); // T3 = E*H\n const Z3 = modP(F * G); // Z3 = F*G\n return new Point(X3, Y3, Z3, T3);\n }\n\n // Fast algo for adding 2 Extended Points.\n // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd\n // Cost: 9M + 1*a + 1*d + 7add.\n add(other: Point) {\n assertPoint(other);\n const { a, d } = CURVE;\n const { ex: X1, ey: Y1, ez: Z1, et: T1 } = this;\n const { ex: X2, ey: Y2, ez: Z2, et: T2 } = other;\n // Faster algo for adding 2 Extended Points when curve's a=-1.\n // http://hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html#addition-add-2008-hwcd-4\n // Cost: 8M + 8add + 2*2.\n // Note: It does not check whether the `other` point is valid.\n if (a === BigInt(-1)) {\n const A = modP((Y1 - X1) * (Y2 + X2));\n const B = modP((Y1 + X1) * (Y2 - X2));\n const F = modP(B - A);\n if (F === _0n) return this.double(); // Same point. Tests say it doesn't affect timing\n const C = modP(Z1 * _2n * T2);\n const D = modP(T1 * _2n * Z2);\n const E = D + C;\n const G = B + A;\n const H = D - C;\n const X3 = modP(E * F);\n const Y3 = modP(G * H);\n const T3 = modP(E * H);\n const Z3 = modP(F * G);\n return new Point(X3, Y3, Z3, T3);\n }\n const A = modP(X1 * X2); // A = X1*X2\n const B = modP(Y1 * Y2); // B = Y1*Y2\n const C = modP(T1 * d * T2); // C = T1*d*T2\n const D = modP(Z1 * Z2); // D = Z1*Z2\n const E = modP((X1 + Y1) * (X2 + Y2) - A - B); // E = (X1+Y1)*(X2+Y2)-A-B\n const F = D - C; // F = D-C\n const G = D + C; // G = D+C\n const H = modP(B - a * A); // H = B-a*A\n const X3 = modP(E * F); // X3 = E*F\n const Y3 = modP(G * H); // Y3 = G*H\n const T3 = modP(E * H); // T3 = E*H\n const Z3 = modP(F * G); // Z3 = F*G\n\n return new Point(X3, Y3, Z3, T3);\n }\n\n subtract(other: Point): Point {\n return this.add(other.negate());\n }\n\n private wNAF(n: bigint): { p: Point; f: Point } {\n return wnaf.wNAFCached(this, n, Point.normalizeZ);\n }\n\n // Constant-time multiplication.\n multiply(scalar: bigint): Point {\n const n = scalar;\n ut.aInRange('scalar', n, _1n, CURVE_ORDER); // 1 <= scalar < L\n const { p, f } = this.wNAF(n);\n return Point.normalizeZ([p, f])[0];\n }\n\n // Non-constant-time multiplication. Uses double-and-add algorithm.\n // It's faster, but should only be used when you don't care about\n // an exposed private key e.g. sig verification.\n // Does NOT allow scalars higher than CURVE.n.\n // Accepts optional accumulator to merge with multiply (important for sparse scalars)\n multiplyUnsafe(scalar: bigint, acc = Point.ZERO): Point {\n const n = scalar;\n ut.aInRange('scalar', n, _0n, CURVE_ORDER); // 0 <= scalar < L\n if (n === _0n) return I;\n if (this.is0() || n === _1n) return this;\n return wnaf.wNAFCachedUnsafe(this, n, Point.normalizeZ, acc);\n }\n\n // Checks if point is of small order.\n // If you add something to small order point, you will have \"dirty\"\n // point with torsion component.\n // Multiplies point by cofactor and checks if the result is 0.\n isSmallOrder(): boolean {\n return this.multiplyUnsafe(cofactor).is0();\n }\n\n // Multiplies point by curve order and checks if the result is 0.\n // Returns `false` is the point is dirty.\n isTorsionFree(): boolean {\n return wnaf.unsafeLadder(this, CURVE_ORDER).is0();\n }\n\n // Converts Extended point to default (x, y) coordinates.\n // Can accept precomputed Z^-1 - for example, from invertBatch.\n toAffine(iz?: bigint): AffinePoint {\n return toAffineMemo(this, iz);\n }\n\n clearCofactor(): Point {\n const { h: cofactor } = CURVE;\n if (cofactor === _1n) return this;\n return this.multiplyUnsafe(cofactor);\n }\n\n // Converts hash string or Uint8Array to Point.\n // Uses algo from RFC8032 5.1.3.\n static fromHex(hex: Hex, zip215 = false): Point {\n const { d, a } = CURVE;\n const len = Fp.BYTES;\n hex = ensureBytes('pointHex', hex, len); // copy hex to a new array\n abool('zip215', zip215);\n const normed = hex.slice(); // copy again, we'll manipulate it\n const lastByte = hex[len - 1]; // select last byte\n normed[len - 1] = lastByte & ~0x80; // clear last bit\n const y = ut.bytesToNumberLE(normed);\n\n // zip215=true is good for consensus-critical apps. =false follows RFC8032 / NIST186-5.\n // RFC8032 prohibits >= p, but ZIP215 doesn't\n // zip215=true: 0 <= y < MASK (2^256 for ed25519)\n // zip215=false: 0 <= y < P (2^255-19 for ed25519)\n const max = zip215 ? MASK : Fp.ORDER;\n ut.aInRange('pointHex.y', y, _0n, max);\n\n // Ed25519: x² = (y²-1)/(dy²+1) mod p. Ed448: x² = (y²-1)/(dy²-1) mod p. Generic case:\n // ax²+y²=1+dx²y² => y²-1=dx²y²-ax² => y²-1=x²(dy²-a) => x²=(y²-1)/(dy²-a)\n const y2 = modP(y * y); // denominator is always non-0 mod p.\n const u = modP(y2 - _1n); // u = y² - 1\n const v = modP(d * y2 - a); // v = d y² + 1.\n let { isValid, value: x } = uvRatio(u, v); // √(u/v)\n if (!isValid) throw new Error('Point.fromHex: invalid y coordinate');\n const isXOdd = (x & _1n) === _1n; // There are 2 square roots. Use x_0 bit to select proper\n const isLastByteOdd = (lastByte & 0x80) !== 0; // x_0, last bit\n if (!zip215 && x === _0n && isLastByteOdd)\n // if x=0 and x_0 = 1, fail\n throw new Error('Point.fromHex: x=0 and x_0=1');\n if (isLastByteOdd !== isXOdd) x = modP(-x); // if x_0 != x mod 2, set x = p-x\n return Point.fromAffine({ x, y });\n }\n static fromPrivateKey(privKey: Hex) {\n return getExtendedPublicKey(privKey).point;\n }\n toRawBytes(): Uint8Array {\n const { x, y } = this.toAffine();\n const bytes = ut.numberToBytesLE(y, Fp.BYTES); // each y has 2 x values (x, -y)\n bytes[bytes.length - 1] |= x & _1n ? 0x80 : 0; // when compressing, it's enough to store y\n return bytes; // and use the last byte to encode sign of x\n }\n toHex(): string {\n return ut.bytesToHex(this.toRawBytes()); // Same as toRawBytes, but returns string.\n }\n }\n const { BASE: G, ZERO: I } = Point;\n const wnaf = wNAF(Point, nByteLength * 8);\n\n function modN(a: bigint) {\n return mod(a, CURVE_ORDER);\n }\n // Little-endian SHA512 with modulo n\n function modN_LE(hash: Uint8Array): bigint {\n return modN(ut.bytesToNumberLE(hash));\n }\n\n /** Convenience method that creates public key and other stuff. RFC8032 5.1.5 */\n function getExtendedPublicKey(key: Hex) {\n const len = Fp.BYTES;\n key = ensureBytes('private key', key, len);\n // Hash private key with curve's hash function to produce uniformingly random input\n // Check byte lengths: ensure(64, h(ensure(32, key)))\n const hashed = ensureBytes('hashed private key', cHash(key), 2 * len);\n const head = adjustScalarBytes(hashed.slice(0, len)); // clear first half bits, produce FE\n const prefix = hashed.slice(len, 2 * len); // second half is called key prefix (5.1.6)\n const scalar = modN_LE(head); // The actual private scalar\n const point = G.multiply(scalar); // Point on Edwards curve aka public key\n const pointBytes = point.toRawBytes(); // Uint8Array representation\n return { head, prefix, scalar, point, pointBytes };\n }\n\n // Calculates EdDSA pub key. RFC8032 5.1.5. Privkey is hashed. Use first half with 3 bits cleared\n function getPublicKey(privKey: Hex): Uint8Array {\n return getExtendedPublicKey(privKey).pointBytes;\n }\n\n // int('LE', SHA512(dom2(F, C) || msgs)) mod N\n function hashDomainToScalar(context: Hex = new Uint8Array(), ...msgs: Uint8Array[]) {\n const msg = ut.concatBytes(...msgs);\n return modN_LE(cHash(domain(msg, ensureBytes('context', context), !!prehash)));\n }\n\n /** Signs message with privateKey. RFC8032 5.1.6 */\n function sign(msg: Hex, privKey: Hex, options: { context?: Hex } = {}): Uint8Array {\n msg = ensureBytes('message', msg);\n if (prehash) msg = prehash(msg); // for ed25519ph etc.\n const { prefix, scalar, pointBytes } = getExtendedPublicKey(privKey);\n const r = hashDomainToScalar(options.context, prefix, msg); // r = dom2(F, C) || prefix || PH(M)\n const R = G.multiply(r).toRawBytes(); // R = rG\n const k = hashDomainToScalar(options.context, R, pointBytes, msg); // R || A || PH(M)\n const s = modN(r + k * scalar); // S = (r + k * s) mod L\n ut.aInRange('signature.s', s, _0n, CURVE_ORDER); // 0 <= s < l\n const res = ut.concatBytes(R, ut.numberToBytesLE(s, Fp.BYTES));\n return ensureBytes('result', res, Fp.BYTES * 2); // 64-byte signature\n }\n\n const verifyOpts: { context?: Hex; zip215?: boolean } = VERIFY_DEFAULT;\n\n /**\n * Verifies EdDSA signature against message and public key. RFC8032 5.1.7.\n * An extended group equation is checked.\n */\n function verify(sig: Hex, msg: Hex, publicKey: Hex, options = verifyOpts): boolean {\n const { context, zip215 } = options;\n const len = Fp.BYTES; // Verifies EdDSA signature against message and public key. RFC8032 5.1.7.\n sig = ensureBytes('signature', sig, 2 * len); // An extended group equation is checked.\n msg = ensureBytes('message', msg);\n publicKey = ensureBytes('publicKey', publicKey, len);\n if (zip215 !== undefined) abool('zip215', zip215);\n if (prehash) msg = prehash(msg); // for ed25519ph, etc\n\n const s = ut.bytesToNumberLE(sig.slice(len, 2 * len));\n let A, R, SB;\n try {\n // zip215=true is good for consensus-critical apps. =false follows RFC8032 / NIST186-5.\n // zip215=true: 0 <= y < MASK (2^256 for ed25519)\n // zip215=false: 0 <= y < P (2^255-19 for ed25519)\n A = Point.fromHex(publicKey, zip215);\n R = Point.fromHex(sig.slice(0, len), zip215);\n SB = G.multiplyUnsafe(s); // 0 <= s < l is done inside\n } catch (error) {\n return false;\n }\n if (!zip215 && A.isSmallOrder()) return false;\n\n const k = hashDomainToScalar(context, R.toRawBytes(), A.toRawBytes(), msg);\n const RkA = R.add(A.multiplyUnsafe(k));\n // Extended group equation\n // [8][S]B = [8]R + [8][k]A'\n return RkA.subtract(SB).clearCofactor().equals(Point.ZERO);\n }\n\n G._setWindowSize(8); // Enable precomputes. Slows down first publicKey computation by 20ms.\n\n const utils = {\n getExtendedPublicKey,\n // ed25519 private keys are uniform 32b. No need to check for modulo bias, like in secp256k1.\n randomPrivateKey: (): Uint8Array => randomBytes(Fp.BYTES),\n\n /**\n * We're doing scalar multiplication (used in getPublicKey etc) with precomputed BASE_POINT\n * values. This slows down first getPublicKey() by milliseconds (see Speed section),\n * but allows to speed-up subsequent getPublicKey() calls up to 20x.\n * @param windowSize 2, 4, 8, 16\n */\n precompute(windowSize = 8, point: ExtPointType = Point.BASE): ExtPointType {\n point._setWindowSize(windowSize);\n point.multiply(BigInt(3));\n return point;\n },\n };\n\n return {\n CURVE,\n getPublicKey,\n sign,\n verify,\n ExtendedPoint: Point,\n utils,\n };\n}\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.expand_message_xmd = expand_message_xmd;\nexports.expand_message_xof = expand_message_xof;\nexports.hash_to_field = hash_to_field;\nexports.isogenyMap = isogenyMap;\nexports.createHasher = createHasher;\nconst modular_js_1 = require(\"./modular.js\");\nconst utils_js_1 = require(\"./utils.js\");\n// Octet Stream to Integer. \"spec\" implementation of os2ip is 2.5x slower vs bytesToNumberBE.\nconst os2ip = utils_js_1.bytesToNumberBE;\n// Integer to Octet Stream (numberToBytesBE)\nfunction i2osp(value, length) {\n anum(value);\n anum(length);\n if (value < 0 || value >= 1 << (8 * length))\n throw new Error('invalid I2OSP input: ' + value);\n const res = Array.from({ length }).fill(0);\n for (let i = length - 1; i >= 0; i--) {\n res[i] = value & 0xff;\n value >>>= 8;\n }\n return new Uint8Array(res);\n}\nfunction strxor(a, b) {\n const arr = new Uint8Array(a.length);\n for (let i = 0; i < a.length; i++) {\n arr[i] = a[i] ^ b[i];\n }\n return arr;\n}\nfunction anum(item) {\n if (!Number.isSafeInteger(item))\n throw new Error('number expected');\n}\n/**\n * Produces a uniformly random byte string using a cryptographic hash function H that outputs b bits.\n * [RFC 9380 5.3.1](https://www.rfc-editor.org/rfc/rfc9380#section-5.3.1).\n */\nfunction expand_message_xmd(msg, DST, lenInBytes, H) {\n (0, utils_js_1.abytes)(msg);\n (0, utils_js_1.abytes)(DST);\n anum(lenInBytes);\n // https://www.rfc-editor.org/rfc/rfc9380#section-5.3.3\n if (DST.length > 255)\n DST = H((0, utils_js_1.concatBytes)((0, utils_js_1.utf8ToBytes)('H2C-OVERSIZE-DST-'), DST));\n const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H;\n const ell = Math.ceil(lenInBytes / b_in_bytes);\n if (lenInBytes > 65535 || ell > 255)\n throw new Error('expand_message_xmd: invalid lenInBytes');\n const DST_prime = (0, utils_js_1.concatBytes)(DST, i2osp(DST.length, 1));\n const Z_pad = i2osp(0, r_in_bytes);\n const l_i_b_str = i2osp(lenInBytes, 2); // len_in_bytes_str\n const b = new Array(ell);\n const b_0 = H((0, utils_js_1.concatBytes)(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));\n b[0] = H((0, utils_js_1.concatBytes)(b_0, i2osp(1, 1), DST_prime));\n for (let i = 1; i <= ell; i++) {\n const args = [strxor(b_0, b[i - 1]), i2osp(i + 1, 1), DST_prime];\n b[i] = H((0, utils_js_1.concatBytes)(...args));\n }\n const pseudo_random_bytes = (0, utils_js_1.concatBytes)(...b);\n return pseudo_random_bytes.slice(0, lenInBytes);\n}\n/**\n * Produces a uniformly random byte string using an extendable-output function (XOF) H.\n * 1. The collision resistance of H MUST be at least k bits.\n * 2. H MUST be an XOF that has been proved indifferentiable from\n * a random oracle under a reasonable cryptographic assumption.\n * [RFC 9380 5.3.2](https://www.rfc-editor.org/rfc/rfc9380#section-5.3.2).\n */\nfunction expand_message_xof(msg, DST, lenInBytes, k, H) {\n (0, utils_js_1.abytes)(msg);\n (0, utils_js_1.abytes)(DST);\n anum(lenInBytes);\n // https://www.rfc-editor.org/rfc/rfc9380#section-5.3.3\n // DST = H('H2C-OVERSIZE-DST-' || a_very_long_DST, Math.ceil((lenInBytes * k) / 8));\n if (DST.length > 255) {\n const dkLen = Math.ceil((2 * k) / 8);\n DST = H.create({ dkLen }).update((0, utils_js_1.utf8ToBytes)('H2C-OVERSIZE-DST-')).update(DST).digest();\n }\n if (lenInBytes > 65535 || DST.length > 255)\n throw new Error('expand_message_xof: invalid lenInBytes');\n return (H.create({ dkLen: lenInBytes })\n .update(msg)\n .update(i2osp(lenInBytes, 2))\n // 2. DST_prime = DST || I2OSP(len(DST), 1)\n .update(DST)\n .update(i2osp(DST.length, 1))\n .digest());\n}\n/**\n * Hashes arbitrary-length byte strings to a list of one or more elements of a finite field F.\n * [RFC 9380 5.2](https://www.rfc-editor.org/rfc/rfc9380#section-5.2).\n * @param msg a byte string containing the message to hash\n * @param count the number of elements of F to output\n * @param options `{DST: string, p: bigint, m: number, k: number, expand: 'xmd' | 'xof', hash: H}`, see above\n * @returns [u_0, ..., u_(count - 1)], a list of field elements.\n */\nfunction hash_to_field(msg, count, options) {\n (0, utils_js_1.validateObject)(options, {\n DST: 'stringOrUint8Array',\n p: 'bigint',\n m: 'isSafeInteger',\n k: 'isSafeInteger',\n hash: 'hash',\n });\n const { p, k, m, hash, expand, DST: _DST } = options;\n (0, utils_js_1.abytes)(msg);\n anum(count);\n const DST = typeof _DST === 'string' ? (0, utils_js_1.utf8ToBytes)(_DST) : _DST;\n const log2p = p.toString(2).length;\n const L = Math.ceil((log2p + k) / 8); // section 5.1 of ietf draft link above\n const len_in_bytes = count * m * L;\n let prb; // pseudo_random_bytes\n if (expand === 'xmd') {\n prb = expand_message_xmd(msg, DST, len_in_bytes, hash);\n }\n else if (expand === 'xof') {\n prb = expand_message_xof(msg, DST, len_in_bytes, k, hash);\n }\n else if (expand === '_internal_pass') {\n // for internal tests only\n prb = msg;\n }\n else {\n throw new Error('expand must be \"xmd\" or \"xof\"');\n }\n const u = new Array(count);\n for (let i = 0; i < count; i++) {\n const e = new Array(m);\n for (let j = 0; j < m; j++) {\n const elm_offset = L * (j + i * m);\n const tv = prb.subarray(elm_offset, elm_offset + L);\n e[j] = (0, modular_js_1.mod)(os2ip(tv), p);\n }\n u[i] = e;\n }\n return u;\n}\nfunction isogenyMap(field, map) {\n // Make same order as in spec\n const COEFF = map.map((i) => Array.from(i).reverse());\n return (x, y) => {\n const [xNum, xDen, yNum, yDen] = COEFF.map((val) => val.reduce((acc, i) => field.add(field.mul(acc, x), i)));\n x = field.div(xNum, xDen); // xNum / xDen\n y = field.mul(y, field.div(yNum, yDen)); // y * (yNum / yDev)\n return { x: x, y: y };\n };\n}\n/** Creates hash-to-curve methods from EC Point and mapToCurve function. */\nfunction createHasher(Point, mapToCurve, def) {\n if (typeof mapToCurve !== 'function')\n throw new Error('mapToCurve() must be defined');\n return {\n // Encodes byte string to elliptic curve.\n // hash_to_curve from https://www.rfc-editor.org/rfc/rfc9380#section-3\n hashToCurve(msg, options) {\n const u = hash_to_field(msg, 2, { ...def, DST: def.DST, ...options });\n const u0 = Point.fromAffine(mapToCurve(u[0]));\n const u1 = Point.fromAffine(mapToCurve(u[1]));\n const P = u0.add(u1).clearCofactor();\n P.assertValidity();\n return P;\n },\n // Encodes byte string to elliptic curve.\n // encode_to_curve from https://www.rfc-editor.org/rfc/rfc9380#section-3\n encodeToCurve(msg, options) {\n const u = hash_to_field(msg, 1, { ...def, DST: def.encodeDST, ...options });\n const P = Point.fromAffine(mapToCurve(u[0])).clearCofactor();\n P.assertValidity();\n return P;\n },\n // Same as encodeToCurve, but without hash\n mapToCurve(scalars) {\n if (!Array.isArray(scalars))\n throw new Error('mapToCurve: expected array of bigints');\n for (const i of scalars)\n if (typeof i !== 'bigint')\n throw new Error('mapToCurve: expected array of bigints');\n const P = Point.fromAffine(mapToCurve(scalars)).clearCofactor();\n P.assertValidity();\n return P;\n },\n };\n}\n//# sourceMappingURL=hash-to-curve.js.map","/**\n * hash-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380).\n * Hashes arbitrary-length byte strings to a list of one or more elements of a finite field F.\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nimport type { AffinePoint, Group, GroupConstructor } from './curve.js';\nimport { type IField, mod } from './modular.js';\nimport type { CHash } from './utils.js';\nimport { abytes, bytesToNumberBE, concatBytes, utf8ToBytes, validateObject } from './utils.js';\n\nexport type UnicodeOrBytes = string | Uint8Array;\n\n/**\n * * `DST` is a domain separation tag, defined in section 2.2.5\n * * `p` characteristic of F, where F is a finite field of characteristic p and order q = p^m\n * * `m` is extension degree (1 for prime fields)\n * * `k` is the target security target in bits (e.g. 128), from section 5.1\n * * `expand` is `xmd` (SHA2, SHA3, BLAKE) or `xof` (SHAKE, BLAKE-XOF)\n * * `hash` conforming to `utils.CHash` interface, with `outputLen` / `blockLen` props\n */\nexport type Opts = {\n DST: UnicodeOrBytes;\n p: bigint;\n m: number;\n k: number;\n expand: 'xmd' | 'xof';\n hash: CHash;\n};\n\n// Octet Stream to Integer. \"spec\" implementation of os2ip is 2.5x slower vs bytesToNumberBE.\nconst os2ip = bytesToNumberBE;\n\n// Integer to Octet Stream (numberToBytesBE)\nfunction i2osp(value: number, length: number): Uint8Array {\n anum(value);\n anum(length);\n if (value < 0 || value >= 1 << (8 * length)) throw new Error('invalid I2OSP input: ' + value);\n const res = Array.from({ length }).fill(0) as number[];\n for (let i = length - 1; i >= 0; i--) {\n res[i] = value & 0xff;\n value >>>= 8;\n }\n return new Uint8Array(res);\n}\n\nfunction strxor(a: Uint8Array, b: Uint8Array): Uint8Array {\n const arr = new Uint8Array(a.length);\n for (let i = 0; i < a.length; i++) {\n arr[i] = a[i] ^ b[i];\n }\n return arr;\n}\n\nfunction anum(item: unknown): void {\n if (!Number.isSafeInteger(item)) throw new Error('number expected');\n}\n\n/**\n * Produces a uniformly random byte string using a cryptographic hash function H that outputs b bits.\n * [RFC 9380 5.3.1](https://www.rfc-editor.org/rfc/rfc9380#section-5.3.1).\n */\nexport function expand_message_xmd(\n msg: Uint8Array,\n DST: Uint8Array,\n lenInBytes: number,\n H: CHash\n): Uint8Array {\n abytes(msg);\n abytes(DST);\n anum(lenInBytes);\n // https://www.rfc-editor.org/rfc/rfc9380#section-5.3.3\n if (DST.length > 255) DST = H(concatBytes(utf8ToBytes('H2C-OVERSIZE-DST-'), DST));\n const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H;\n const ell = Math.ceil(lenInBytes / b_in_bytes);\n if (lenInBytes > 65535 || ell > 255) throw new Error('expand_message_xmd: invalid lenInBytes');\n const DST_prime = concatBytes(DST, i2osp(DST.length, 1));\n const Z_pad = i2osp(0, r_in_bytes);\n const l_i_b_str = i2osp(lenInBytes, 2); // len_in_bytes_str\n const b = new Array(ell);\n const b_0 = H(concatBytes(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));\n b[0] = H(concatBytes(b_0, i2osp(1, 1), DST_prime));\n for (let i = 1; i <= ell; i++) {\n const args = [strxor(b_0, b[i - 1]), i2osp(i + 1, 1), DST_prime];\n b[i] = H(concatBytes(...args));\n }\n const pseudo_random_bytes = concatBytes(...b);\n return pseudo_random_bytes.slice(0, lenInBytes);\n}\n\n/**\n * Produces a uniformly random byte string using an extendable-output function (XOF) H.\n * 1. The collision resistance of H MUST be at least k bits.\n * 2. H MUST be an XOF that has been proved indifferentiable from\n * a random oracle under a reasonable cryptographic assumption.\n * [RFC 9380 5.3.2](https://www.rfc-editor.org/rfc/rfc9380#section-5.3.2).\n */\nexport function expand_message_xof(\n msg: Uint8Array,\n DST: Uint8Array,\n lenInBytes: number,\n k: number,\n H: CHash\n): Uint8Array {\n abytes(msg);\n abytes(DST);\n anum(lenInBytes);\n // https://www.rfc-editor.org/rfc/rfc9380#section-5.3.3\n // DST = H('H2C-OVERSIZE-DST-' || a_very_long_DST, Math.ceil((lenInBytes * k) / 8));\n if (DST.length > 255) {\n const dkLen = Math.ceil((2 * k) / 8);\n DST = H.create({ dkLen }).update(utf8ToBytes('H2C-OVERSIZE-DST-')).update(DST).digest();\n }\n if (lenInBytes > 65535 || DST.length > 255)\n throw new Error('expand_message_xof: invalid lenInBytes');\n return (\n H.create({ dkLen: lenInBytes })\n .update(msg)\n .update(i2osp(lenInBytes, 2))\n // 2. DST_prime = DST || I2OSP(len(DST), 1)\n .update(DST)\n .update(i2osp(DST.length, 1))\n .digest()\n );\n}\n\n/**\n * Hashes arbitrary-length byte strings to a list of one or more elements of a finite field F.\n * [RFC 9380 5.2](https://www.rfc-editor.org/rfc/rfc9380#section-5.2).\n * @param msg a byte string containing the message to hash\n * @param count the number of elements of F to output\n * @param options `{DST: string, p: bigint, m: number, k: number, expand: 'xmd' | 'xof', hash: H}`, see above\n * @returns [u_0, ..., u_(count - 1)], a list of field elements.\n */\nexport function hash_to_field(msg: Uint8Array, count: number, options: Opts): bigint[][] {\n validateObject(options, {\n DST: 'stringOrUint8Array',\n p: 'bigint',\n m: 'isSafeInteger',\n k: 'isSafeInteger',\n hash: 'hash',\n });\n const { p, k, m, hash, expand, DST: _DST } = options;\n abytes(msg);\n anum(count);\n const DST = typeof _DST === 'string' ? utf8ToBytes(_DST) : _DST;\n const log2p = p.toString(2).length;\n const L = Math.ceil((log2p + k) / 8); // section 5.1 of ietf draft link above\n const len_in_bytes = count * m * L;\n let prb; // pseudo_random_bytes\n if (expand === 'xmd') {\n prb = expand_message_xmd(msg, DST, len_in_bytes, hash);\n } else if (expand === 'xof') {\n prb = expand_message_xof(msg, DST, len_in_bytes, k, hash);\n } else if (expand === '_internal_pass') {\n // for internal tests only\n prb = msg;\n } else {\n throw new Error('expand must be \"xmd\" or \"xof\"');\n }\n const u = new Array(count);\n for (let i = 0; i < count; i++) {\n const e = new Array(m);\n for (let j = 0; j < m; j++) {\n const elm_offset = L * (j + i * m);\n const tv = prb.subarray(elm_offset, elm_offset + L);\n e[j] = mod(os2ip(tv), p);\n }\n u[i] = e;\n }\n return u;\n}\n\nexport type XY = (\n x: T,\n y: T\n) => {\n x: T;\n y: T;\n};\nexport function isogenyMap>(field: F, map: [T[], T[], T[], T[]]): XY {\n // Make same order as in spec\n const COEFF = map.map((i) => Array.from(i).reverse());\n return (x: T, y: T) => {\n const [xNum, xDen, yNum, yDen] = COEFF.map((val) =>\n val.reduce((acc, i) => field.add(field.mul(acc, x), i))\n );\n x = field.div(xNum, xDen); // xNum / xDen\n y = field.mul(y, field.div(yNum, yDen)); // y * (yNum / yDev)\n return { x: x, y: y };\n };\n}\n\n/** Point interface, which curves must implement to work correctly with the module. */\nexport interface H2CPoint extends Group> {\n add(rhs: H2CPoint): H2CPoint;\n toAffine(iz?: bigint): AffinePoint;\n clearCofactor(): H2CPoint;\n assertValidity(): void;\n}\n\nexport interface H2CPointConstructor extends GroupConstructor> {\n fromAffine(ap: AffinePoint): H2CPoint;\n}\n\nexport type MapToCurve = (scalar: bigint[]) => AffinePoint;\n\n// Separated from initialization opts, so users won't accidentally change per-curve parameters\n// (changing DST is ok!)\nexport type htfBasicOpts = { DST: UnicodeOrBytes };\nexport type HTFMethod = (msg: Uint8Array, options?: htfBasicOpts) => H2CPoint;\nexport type MapMethod = (scalars: bigint[]) => H2CPoint;\n\n/** Creates hash-to-curve methods from EC Point and mapToCurve function. */\nexport function createHasher(\n Point: H2CPointConstructor,\n mapToCurve: MapToCurve,\n def: Opts & { encodeDST?: UnicodeOrBytes }\n): {\n hashToCurve: HTFMethod;\n encodeToCurve: HTFMethod;\n mapToCurve: MapMethod;\n} {\n if (typeof mapToCurve !== 'function') throw new Error('mapToCurve() must be defined');\n return {\n // Encodes byte string to elliptic curve.\n // hash_to_curve from https://www.rfc-editor.org/rfc/rfc9380#section-3\n hashToCurve(msg: Uint8Array, options?: htfBasicOpts): H2CPoint {\n const u = hash_to_field(msg, 2, { ...def, DST: def.DST, ...options } as Opts);\n const u0 = Point.fromAffine(mapToCurve(u[0]));\n const u1 = Point.fromAffine(mapToCurve(u[1]));\n const P = u0.add(u1).clearCofactor();\n P.assertValidity();\n return P;\n },\n\n // Encodes byte string to elliptic curve.\n // encode_to_curve from https://www.rfc-editor.org/rfc/rfc9380#section-3\n encodeToCurve(msg: Uint8Array, options?: htfBasicOpts): H2CPoint {\n const u = hash_to_field(msg, 1, { ...def, DST: def.encodeDST, ...options } as Opts);\n const P = Point.fromAffine(mapToCurve(u[0])).clearCofactor();\n P.assertValidity();\n return P;\n },\n // Same as encodeToCurve, but without hash\n mapToCurve(scalars: bigint[]): H2CPoint {\n if (!Array.isArray(scalars)) throw new Error('mapToCurve: expected array of bigints');\n for (const i of scalars)\n if (typeof i !== 'bigint') throw new Error('mapToCurve: expected array of bigints');\n const P = Point.fromAffine(mapToCurve(scalars)).clearCofactor();\n P.assertValidity();\n return P;\n },\n };\n}\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.montgomery = montgomery;\n/**\n * Montgomery curve methods. It's not really whole montgomery curve,\n * just bunch of very specific methods for X25519 / X448 from\n * [RFC 7748](https://www.rfc-editor.org/rfc/rfc7748)\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nconst modular_js_1 = require(\"./modular.js\");\nconst utils_js_1 = require(\"./utils.js\");\nconst _0n = BigInt(0);\nconst _1n = BigInt(1);\nfunction validateOpts(curve) {\n (0, utils_js_1.validateObject)(curve, {\n a: 'bigint',\n }, {\n montgomeryBits: 'isSafeInteger',\n nByteLength: 'isSafeInteger',\n adjustScalarBytes: 'function',\n domain: 'function',\n powPminus2: 'function',\n Gu: 'bigint',\n });\n // Set defaults\n return Object.freeze({ ...curve });\n}\n// Uses only one coordinate instead of two\nfunction montgomery(curveDef) {\n const CURVE = validateOpts(curveDef);\n const { P } = CURVE;\n const modP = (n) => (0, modular_js_1.mod)(n, P);\n const montgomeryBits = CURVE.montgomeryBits;\n const montgomeryBytes = Math.ceil(montgomeryBits / 8);\n const fieldLen = CURVE.nByteLength;\n const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes) => bytes);\n const powPminus2 = CURVE.powPminus2 || ((x) => (0, modular_js_1.pow)(x, P - BigInt(2), P));\n // cswap from RFC7748. But it is not from RFC7748!\n /*\n cswap(swap, x_2, x_3):\n dummy = mask(swap) AND (x_2 XOR x_3)\n x_2 = x_2 XOR dummy\n x_3 = x_3 XOR dummy\n Return (x_2, x_3)\n Where mask(swap) is the all-1 or all-0 word of the same length as x_2\n and x_3, computed, e.g., as mask(swap) = 0 - swap.\n */\n function cswap(swap, x_2, x_3) {\n const dummy = modP(swap * (x_2 - x_3));\n x_2 = modP(x_2 - dummy);\n x_3 = modP(x_3 + dummy);\n return [x_2, x_3];\n }\n // x25519 from 4\n // The constant a24 is (486662 - 2) / 4 = 121665 for curve25519/X25519\n const a24 = (CURVE.a - BigInt(2)) / BigInt(4);\n /**\n *\n * @param pointU u coordinate (x) on Montgomery Curve 25519\n * @param scalar by which the point would be multiplied\n * @returns new Point on Montgomery curve\n */\n function montgomeryLadder(u, scalar) {\n (0, utils_js_1.aInRange)('u', u, _0n, P);\n (0, utils_js_1.aInRange)('scalar', scalar, _0n, P);\n // Section 5: Implementations MUST accept non-canonical values and process them as\n // if they had been reduced modulo the field prime.\n const k = scalar;\n const x_1 = u;\n let x_2 = _1n;\n let z_2 = _0n;\n let x_3 = u;\n let z_3 = _1n;\n let swap = _0n;\n let sw;\n for (let t = BigInt(montgomeryBits - 1); t >= _0n; t--) {\n const k_t = (k >> t) & _1n;\n swap ^= k_t;\n sw = cswap(swap, x_2, x_3);\n x_2 = sw[0];\n x_3 = sw[1];\n sw = cswap(swap, z_2, z_3);\n z_2 = sw[0];\n z_3 = sw[1];\n swap = k_t;\n const A = x_2 + z_2;\n const AA = modP(A * A);\n const B = x_2 - z_2;\n const BB = modP(B * B);\n const E = AA - BB;\n const C = x_3 + z_3;\n const D = x_3 - z_3;\n const DA = modP(D * A);\n const CB = modP(C * B);\n const dacb = DA + CB;\n const da_cb = DA - CB;\n x_3 = modP(dacb * dacb);\n z_3 = modP(x_1 * modP(da_cb * da_cb));\n x_2 = modP(AA * BB);\n z_2 = modP(E * (AA + modP(a24 * E)));\n }\n // (x_2, x_3) = cswap(swap, x_2, x_3)\n sw = cswap(swap, x_2, x_3);\n x_2 = sw[0];\n x_3 = sw[1];\n // (z_2, z_3) = cswap(swap, z_2, z_3)\n sw = cswap(swap, z_2, z_3);\n z_2 = sw[0];\n z_3 = sw[1];\n // z_2^(p - 2)\n const z2 = powPminus2(z_2);\n // Return x_2 * (z_2^(p - 2))\n return modP(x_2 * z2);\n }\n function encodeUCoordinate(u) {\n return (0, utils_js_1.numberToBytesLE)(modP(u), montgomeryBytes);\n }\n function decodeUCoordinate(uEnc) {\n // Section 5: When receiving such an array, implementations of X25519\n // MUST mask the most significant bit in the final byte.\n const u = (0, utils_js_1.ensureBytes)('u coordinate', uEnc, montgomeryBytes);\n if (fieldLen === 32)\n u[31] &= 127; // 0b0111_1111\n return (0, utils_js_1.bytesToNumberLE)(u);\n }\n function decodeScalar(n) {\n const bytes = (0, utils_js_1.ensureBytes)('scalar', n);\n const len = bytes.length;\n if (len !== montgomeryBytes && len !== fieldLen) {\n let valid = '' + montgomeryBytes + ' or ' + fieldLen;\n throw new Error('invalid scalar, expected ' + valid + ' bytes, got ' + len);\n }\n return (0, utils_js_1.bytesToNumberLE)(adjustScalarBytes(bytes));\n }\n function scalarMult(scalar, u) {\n const pointU = decodeUCoordinate(u);\n const _scalar = decodeScalar(scalar);\n const pu = montgomeryLadder(pointU, _scalar);\n // The result was not contributory\n // https://cr.yp.to/ecdh.html#validate\n if (pu === _0n)\n throw new Error('invalid private or public key received');\n return encodeUCoordinate(pu);\n }\n // Computes public key from private. By doing scalar multiplication of base point.\n const GuBytes = encodeUCoordinate(CURVE.Gu);\n function scalarMultBase(scalar) {\n return scalarMult(scalar, GuBytes);\n }\n return {\n scalarMult,\n scalarMultBase,\n getSharedSecret: (privateKey, publicKey) => scalarMult(privateKey, publicKey),\n getPublicKey: (privateKey) => scalarMultBase(privateKey),\n utils: { randomPrivateKey: () => CURVE.randomBytes(CURVE.nByteLength) },\n GuBytes: GuBytes,\n };\n}\n//# sourceMappingURL=montgomery.js.map","/**\n * Montgomery curve methods. It's not really whole montgomery curve,\n * just bunch of very specific methods for X25519 / X448 from\n * [RFC 7748](https://www.rfc-editor.org/rfc/rfc7748)\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nimport { mod, pow } from './modular.js';\nimport {\n aInRange,\n bytesToNumberLE,\n ensureBytes,\n numberToBytesLE,\n validateObject,\n} from './utils.js';\n\nconst _0n = BigInt(0);\nconst _1n = BigInt(1);\ntype Hex = string | Uint8Array;\n\nexport type CurveType = {\n P: bigint; // finite field prime\n nByteLength: number;\n adjustScalarBytes?: (bytes: Uint8Array) => Uint8Array;\n domain?: (data: Uint8Array, ctx: Uint8Array, phflag: boolean) => Uint8Array;\n a: bigint;\n montgomeryBits: number;\n powPminus2?: (x: bigint) => bigint;\n xyToU?: (x: bigint, y: bigint) => bigint;\n Gu: bigint;\n randomBytes?: (bytesLength?: number) => Uint8Array;\n};\n\nexport type CurveFn = {\n scalarMult: (scalar: Hex, u: Hex) => Uint8Array;\n scalarMultBase: (scalar: Hex) => Uint8Array;\n getSharedSecret: (privateKeyA: Hex, publicKeyB: Hex) => Uint8Array;\n getPublicKey: (privateKey: Hex) => Uint8Array;\n utils: { randomPrivateKey: () => Uint8Array };\n GuBytes: Uint8Array;\n};\n\nfunction validateOpts(curve: CurveType) {\n validateObject(\n curve,\n {\n a: 'bigint',\n },\n {\n montgomeryBits: 'isSafeInteger',\n nByteLength: 'isSafeInteger',\n adjustScalarBytes: 'function',\n domain: 'function',\n powPminus2: 'function',\n Gu: 'bigint',\n }\n );\n // Set defaults\n return Object.freeze({ ...curve } as const);\n}\n\n// Uses only one coordinate instead of two\nexport function montgomery(curveDef: CurveType): CurveFn {\n const CURVE = validateOpts(curveDef);\n const { P } = CURVE;\n const modP = (n: bigint) => mod(n, P);\n const montgomeryBits = CURVE.montgomeryBits;\n const montgomeryBytes = Math.ceil(montgomeryBits / 8);\n const fieldLen = CURVE.nByteLength;\n const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes: Uint8Array) => bytes);\n const powPminus2 = CURVE.powPminus2 || ((x: bigint) => pow(x, P - BigInt(2), P));\n\n // cswap from RFC7748. But it is not from RFC7748!\n /*\n cswap(swap, x_2, x_3):\n dummy = mask(swap) AND (x_2 XOR x_3)\n x_2 = x_2 XOR dummy\n x_3 = x_3 XOR dummy\n Return (x_2, x_3)\n Where mask(swap) is the all-1 or all-0 word of the same length as x_2\n and x_3, computed, e.g., as mask(swap) = 0 - swap.\n */\n function cswap(swap: bigint, x_2: bigint, x_3: bigint): [bigint, bigint] {\n const dummy = modP(swap * (x_2 - x_3));\n x_2 = modP(x_2 - dummy);\n x_3 = modP(x_3 + dummy);\n return [x_2, x_3];\n }\n\n // x25519 from 4\n // The constant a24 is (486662 - 2) / 4 = 121665 for curve25519/X25519\n const a24 = (CURVE.a - BigInt(2)) / BigInt(4);\n /**\n *\n * @param pointU u coordinate (x) on Montgomery Curve 25519\n * @param scalar by which the point would be multiplied\n * @returns new Point on Montgomery curve\n */\n function montgomeryLadder(u: bigint, scalar: bigint): bigint {\n aInRange('u', u, _0n, P);\n aInRange('scalar', scalar, _0n, P);\n // Section 5: Implementations MUST accept non-canonical values and process them as\n // if they had been reduced modulo the field prime.\n const k = scalar;\n const x_1 = u;\n let x_2 = _1n;\n let z_2 = _0n;\n let x_3 = u;\n let z_3 = _1n;\n let swap = _0n;\n let sw: [bigint, bigint];\n for (let t = BigInt(montgomeryBits - 1); t >= _0n; t--) {\n const k_t = (k >> t) & _1n;\n swap ^= k_t;\n sw = cswap(swap, x_2, x_3);\n x_2 = sw[0];\n x_3 = sw[1];\n sw = cswap(swap, z_2, z_3);\n z_2 = sw[0];\n z_3 = sw[1];\n swap = k_t;\n\n const A = x_2 + z_2;\n const AA = modP(A * A);\n const B = x_2 - z_2;\n const BB = modP(B * B);\n const E = AA - BB;\n const C = x_3 + z_3;\n const D = x_3 - z_3;\n const DA = modP(D * A);\n const CB = modP(C * B);\n const dacb = DA + CB;\n const da_cb = DA - CB;\n x_3 = modP(dacb * dacb);\n z_3 = modP(x_1 * modP(da_cb * da_cb));\n x_2 = modP(AA * BB);\n z_2 = modP(E * (AA + modP(a24 * E)));\n }\n // (x_2, x_3) = cswap(swap, x_2, x_3)\n sw = cswap(swap, x_2, x_3);\n x_2 = sw[0];\n x_3 = sw[1];\n // (z_2, z_3) = cswap(swap, z_2, z_3)\n sw = cswap(swap, z_2, z_3);\n z_2 = sw[0];\n z_3 = sw[1];\n // z_2^(p - 2)\n const z2 = powPminus2(z_2);\n // Return x_2 * (z_2^(p - 2))\n return modP(x_2 * z2);\n }\n\n function encodeUCoordinate(u: bigint): Uint8Array {\n return numberToBytesLE(modP(u), montgomeryBytes);\n }\n\n function decodeUCoordinate(uEnc: Hex): bigint {\n // Section 5: When receiving such an array, implementations of X25519\n // MUST mask the most significant bit in the final byte.\n const u = ensureBytes('u coordinate', uEnc, montgomeryBytes);\n if (fieldLen === 32) u[31] &= 127; // 0b0111_1111\n return bytesToNumberLE(u);\n }\n function decodeScalar(n: Hex): bigint {\n const bytes = ensureBytes('scalar', n);\n const len = bytes.length;\n if (len !== montgomeryBytes && len !== fieldLen) {\n let valid = '' + montgomeryBytes + ' or ' + fieldLen;\n throw new Error('invalid scalar, expected ' + valid + ' bytes, got ' + len);\n }\n return bytesToNumberLE(adjustScalarBytes(bytes));\n }\n function scalarMult(scalar: Hex, u: Hex): Uint8Array {\n const pointU = decodeUCoordinate(u);\n const _scalar = decodeScalar(scalar);\n const pu = montgomeryLadder(pointU, _scalar);\n // The result was not contributory\n // https://cr.yp.to/ecdh.html#validate\n if (pu === _0n) throw new Error('invalid private or public key received');\n return encodeUCoordinate(pu);\n }\n // Computes public key from private. By doing scalar multiplication of base point.\n const GuBytes = encodeUCoordinate(CURVE.Gu);\n function scalarMultBase(scalar: Hex): Uint8Array {\n return scalarMult(scalar, GuBytes);\n }\n\n return {\n scalarMult,\n scalarMultBase,\n getSharedSecret: (privateKey: Hex, publicKey: Hex) => scalarMult(privateKey, publicKey),\n getPublicKey: (privateKey: Hex): Uint8Array => scalarMultBase(privateKey),\n utils: { randomPrivateKey: () => CURVE.randomBytes!(CURVE.nByteLength) },\n GuBytes: GuBytes,\n };\n}\n","(function (module, exports) {\n 'use strict';\n\n // Utils\n function assert (val, msg) {\n if (!val) throw new Error(msg || 'Assertion failed');\n }\n\n // Could use `inherits` module, but don't want to move from single file\n // architecture yet.\n function inherits (ctor, superCtor) {\n ctor.super_ = superCtor;\n var TempCtor = function () {};\n TempCtor.prototype = superCtor.prototype;\n ctor.prototype = new TempCtor();\n ctor.prototype.constructor = ctor;\n }\n\n // BN\n\n function BN (number, base, endian) {\n if (BN.isBN(number)) {\n return number;\n }\n\n this.negative = 0;\n this.words = null;\n this.length = 0;\n\n // Reduction context\n this.red = null;\n\n if (number !== null) {\n if (base === 'le' || base === 'be') {\n endian = base;\n base = 10;\n }\n\n this._init(number || 0, base || 10, endian || 'be');\n }\n }\n if (typeof module === 'object') {\n module.exports = BN;\n } else {\n exports.BN = BN;\n }\n\n BN.BN = BN;\n BN.wordSize = 26;\n\n var Buffer;\n try {\n if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {\n Buffer = window.Buffer;\n } else {\n Buffer = require('buffer').Buffer;\n }\n } catch (e) {\n }\n\n BN.isBN = function isBN (num) {\n if (num instanceof BN) {\n return true;\n }\n\n return num !== null && typeof num === 'object' &&\n num.constructor.wordSize === BN.wordSize && Array.isArray(num.words);\n };\n\n BN.max = function max (left, right) {\n if (left.cmp(right) > 0) return left;\n return right;\n };\n\n BN.min = function min (left, right) {\n if (left.cmp(right) < 0) return left;\n return right;\n };\n\n BN.prototype._init = function init (number, base, endian) {\n if (typeof number === 'number') {\n return this._initNumber(number, base, endian);\n }\n\n if (typeof number === 'object') {\n return this._initArray(number, base, endian);\n }\n\n if (base === 'hex') {\n base = 16;\n }\n assert(base === (base | 0) && base >= 2 && base <= 36);\n\n number = number.toString().replace(/\\s+/g, '');\n var start = 0;\n if (number[0] === '-') {\n start++;\n this.negative = 1;\n }\n\n if (start < number.length) {\n if (base === 16) {\n this._parseHex(number, start, endian);\n } else {\n this._parseBase(number, base, start);\n if (endian === 'le') {\n this._initArray(this.toArray(), base, endian);\n }\n }\n }\n };\n\n BN.prototype._initNumber = function _initNumber (number, base, endian) {\n if (number < 0) {\n this.negative = 1;\n number = -number;\n }\n if (number < 0x4000000) {\n this.words = [number & 0x3ffffff];\n this.length = 1;\n } else if (number < 0x10000000000000) {\n this.words = [\n number & 0x3ffffff,\n (number / 0x4000000) & 0x3ffffff\n ];\n this.length = 2;\n } else {\n assert(number < 0x20000000000000); // 2 ^ 53 (unsafe)\n this.words = [\n number & 0x3ffffff,\n (number / 0x4000000) & 0x3ffffff,\n 1\n ];\n this.length = 3;\n }\n\n if (endian !== 'le') return;\n\n // Reverse the bytes\n this._initArray(this.toArray(), base, endian);\n };\n\n BN.prototype._initArray = function _initArray (number, base, endian) {\n // Perhaps a Uint8Array\n assert(typeof number.length === 'number');\n if (number.length <= 0) {\n this.words = [0];\n this.length = 1;\n return this;\n }\n\n this.length = Math.ceil(number.length / 3);\n this.words = new Array(this.length);\n for (var i = 0; i < this.length; i++) {\n this.words[i] = 0;\n }\n\n var j, w;\n var off = 0;\n if (endian === 'be') {\n for (i = number.length - 1, j = 0; i >= 0; i -= 3) {\n w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16);\n this.words[j] |= (w << off) & 0x3ffffff;\n this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;\n off += 24;\n if (off >= 26) {\n off -= 26;\n j++;\n }\n }\n } else if (endian === 'le') {\n for (i = 0, j = 0; i < number.length; i += 3) {\n w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16);\n this.words[j] |= (w << off) & 0x3ffffff;\n this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff;\n off += 24;\n if (off >= 26) {\n off -= 26;\n j++;\n }\n }\n }\n return this._strip();\n };\n\n function parseHex4Bits (string, index) {\n var c = string.charCodeAt(index);\n // '0' - '9'\n if (c >= 48 && c <= 57) {\n return c - 48;\n // 'A' - 'F'\n } else if (c >= 65 && c <= 70) {\n return c - 55;\n // 'a' - 'f'\n } else if (c >= 97 && c <= 102) {\n return c - 87;\n } else {\n assert(false, 'Invalid character in ' + string);\n }\n }\n\n function parseHexByte (string, lowerBound, index) {\n var r = parseHex4Bits(string, index);\n if (index - 1 >= lowerBound) {\n r |= parseHex4Bits(string, index - 1) << 4;\n }\n return r;\n }\n\n BN.prototype._parseHex = function _parseHex (number, start, endian) {\n // Create possibly bigger array to ensure that it fits the number\n this.length = Math.ceil((number.length - start) / 6);\n this.words = new Array(this.length);\n for (var i = 0; i < this.length; i++) {\n this.words[i] = 0;\n }\n\n // 24-bits chunks\n var off = 0;\n var j = 0;\n\n var w;\n if (endian === 'be') {\n for (i = number.length - 1; i >= start; i -= 2) {\n w = parseHexByte(number, start, i) << off;\n this.words[j] |= w & 0x3ffffff;\n if (off >= 18) {\n off -= 18;\n j += 1;\n this.words[j] |= w >>> 26;\n } else {\n off += 8;\n }\n }\n } else {\n var parseLength = number.length - start;\n for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {\n w = parseHexByte(number, start, i) << off;\n this.words[j] |= w & 0x3ffffff;\n if (off >= 18) {\n off -= 18;\n j += 1;\n this.words[j] |= w >>> 26;\n } else {\n off += 8;\n }\n }\n }\n\n this._strip();\n };\n\n function parseBase (str, start, end, mul) {\n var r = 0;\n var b = 0;\n var len = Math.min(str.length, end);\n for (var i = start; i < len; i++) {\n var c = str.charCodeAt(i) - 48;\n\n r *= mul;\n\n // 'a'\n if (c >= 49) {\n b = c - 49 + 0xa;\n\n // 'A'\n } else if (c >= 17) {\n b = c - 17 + 0xa;\n\n // '0' - '9'\n } else {\n b = c;\n }\n assert(c >= 0 && b < mul, 'Invalid character');\n r += b;\n }\n return r;\n }\n\n BN.prototype._parseBase = function _parseBase (number, base, start) {\n // Initialize as zero\n this.words = [0];\n this.length = 1;\n\n // Find length of limb in base\n for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) {\n limbLen++;\n }\n limbLen--;\n limbPow = (limbPow / base) | 0;\n\n var total = number.length - start;\n var mod = total % limbLen;\n var end = Math.min(total, total - mod) + start;\n\n var word = 0;\n for (var i = start; i < end; i += limbLen) {\n word = parseBase(number, i, i + limbLen, base);\n\n this.imuln(limbPow);\n if (this.words[0] + word < 0x4000000) {\n this.words[0] += word;\n } else {\n this._iaddn(word);\n }\n }\n\n if (mod !== 0) {\n var pow = 1;\n word = parseBase(number, i, number.length, base);\n\n for (i = 0; i < mod; i++) {\n pow *= base;\n }\n\n this.imuln(pow);\n if (this.words[0] + word < 0x4000000) {\n this.words[0] += word;\n } else {\n this._iaddn(word);\n }\n }\n\n this._strip();\n };\n\n BN.prototype.copy = function copy (dest) {\n dest.words = new Array(this.length);\n for (var i = 0; i < this.length; i++) {\n dest.words[i] = this.words[i];\n }\n dest.length = this.length;\n dest.negative = this.negative;\n dest.red = this.red;\n };\n\n function move (dest, src) {\n dest.words = src.words;\n dest.length = src.length;\n dest.negative = src.negative;\n dest.red = src.red;\n }\n\n BN.prototype._move = function _move (dest) {\n move(dest, this);\n };\n\n BN.prototype.clone = function clone () {\n var r = new BN(null);\n this.copy(r);\n return r;\n };\n\n BN.prototype._expand = function _expand (size) {\n while (this.length < size) {\n this.words[this.length++] = 0;\n }\n return this;\n };\n\n // Remove leading `0` from `this`\n BN.prototype._strip = function strip () {\n while (this.length > 1 && this.words[this.length - 1] === 0) {\n this.length--;\n }\n return this._normSign();\n };\n\n BN.prototype._normSign = function _normSign () {\n // -0 = 0\n if (this.length === 1 && this.words[0] === 0) {\n this.negative = 0;\n }\n return this;\n };\n\n // Check Symbol.for because not everywhere where Symbol defined\n // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility\n if (typeof Symbol !== 'undefined' && typeof Symbol.for === 'function') {\n try {\n BN.prototype[Symbol.for('nodejs.util.inspect.custom')] = inspect;\n } catch (e) {\n BN.prototype.inspect = inspect;\n }\n } else {\n BN.prototype.inspect = inspect;\n }\n\n function inspect () {\n return (this.red ? '';\n }\n\n /*\n\n var zeros = [];\n var groupSizes = [];\n var groupBases = [];\n\n var s = '';\n var i = -1;\n while (++i < BN.wordSize) {\n zeros[i] = s;\n s += '0';\n }\n groupSizes[0] = 0;\n groupSizes[1] = 0;\n groupBases[0] = 0;\n groupBases[1] = 0;\n var base = 2 - 1;\n while (++base < 36 + 1) {\n var groupSize = 0;\n var groupBase = 1;\n while (groupBase < (1 << BN.wordSize) / base) {\n groupBase *= base;\n groupSize += 1;\n }\n groupSizes[base] = groupSize;\n groupBases[base] = groupBase;\n }\n\n */\n\n var zeros = [\n '',\n '0',\n '00',\n '000',\n '0000',\n '00000',\n '000000',\n '0000000',\n '00000000',\n '000000000',\n '0000000000',\n '00000000000',\n '000000000000',\n '0000000000000',\n '00000000000000',\n '000000000000000',\n '0000000000000000',\n '00000000000000000',\n '000000000000000000',\n '0000000000000000000',\n '00000000000000000000',\n '000000000000000000000',\n '0000000000000000000000',\n '00000000000000000000000',\n '000000000000000000000000',\n '0000000000000000000000000'\n ];\n\n var groupSizes = [\n 0, 0,\n 25, 16, 12, 11, 10, 9, 8,\n 8, 7, 7, 7, 7, 6, 6,\n 6, 6, 6, 6, 6, 5, 5,\n 5, 5, 5, 5, 5, 5, 5,\n 5, 5, 5, 5, 5, 5, 5\n ];\n\n var groupBases = [\n 0, 0,\n 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216,\n 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625,\n 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632,\n 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149,\n 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176\n ];\n\n BN.prototype.toString = function toString (base, padding) {\n base = base || 10;\n padding = padding | 0 || 1;\n\n var out;\n if (base === 16 || base === 'hex') {\n out = '';\n var off = 0;\n var carry = 0;\n for (var i = 0; i < this.length; i++) {\n var w = this.words[i];\n var word = (((w << off) | carry) & 0xffffff).toString(16);\n carry = (w >>> (24 - off)) & 0xffffff;\n off += 2;\n if (off >= 26) {\n off -= 26;\n i--;\n }\n if (carry !== 0 || i !== this.length - 1) {\n out = zeros[6 - word.length] + word + out;\n } else {\n out = word + out;\n }\n }\n if (carry !== 0) {\n out = carry.toString(16) + out;\n }\n while (out.length % padding !== 0) {\n out = '0' + out;\n }\n if (this.negative !== 0) {\n out = '-' + out;\n }\n return out;\n }\n\n if (base === (base | 0) && base >= 2 && base <= 36) {\n // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));\n var groupSize = groupSizes[base];\n // var groupBase = Math.pow(base, groupSize);\n var groupBase = groupBases[base];\n out = '';\n var c = this.clone();\n c.negative = 0;\n while (!c.isZero()) {\n var r = c.modrn(groupBase).toString(base);\n c = c.idivn(groupBase);\n\n if (!c.isZero()) {\n out = zeros[groupSize - r.length] + r + out;\n } else {\n out = r + out;\n }\n }\n if (this.isZero()) {\n out = '0' + out;\n }\n while (out.length % padding !== 0) {\n out = '0' + out;\n }\n if (this.negative !== 0) {\n out = '-' + out;\n }\n return out;\n }\n\n assert(false, 'Base should be between 2 and 36');\n };\n\n BN.prototype.toNumber = function toNumber () {\n var ret = this.words[0];\n if (this.length === 2) {\n ret += this.words[1] * 0x4000000;\n } else if (this.length === 3 && this.words[2] === 0x01) {\n // NOTE: at this stage it is known that the top bit is set\n ret += 0x10000000000000 + (this.words[1] * 0x4000000);\n } else if (this.length > 2) {\n assert(false, 'Number can only safely store up to 53 bits');\n }\n return (this.negative !== 0) ? -ret : ret;\n };\n\n BN.prototype.toJSON = function toJSON () {\n return this.toString(16, 2);\n };\n\n if (Buffer) {\n BN.prototype.toBuffer = function toBuffer (endian, length) {\n return this.toArrayLike(Buffer, endian, length);\n };\n }\n\n BN.prototype.toArray = function toArray (endian, length) {\n return this.toArrayLike(Array, endian, length);\n };\n\n var allocate = function allocate (ArrayType, size) {\n if (ArrayType.allocUnsafe) {\n return ArrayType.allocUnsafe(size);\n }\n return new ArrayType(size);\n };\n\n BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) {\n this._strip();\n\n var byteLength = this.byteLength();\n var reqLength = length || Math.max(1, byteLength);\n assert(byteLength <= reqLength, 'byte array longer than desired length');\n assert(reqLength > 0, 'Requested array length <= 0');\n\n var res = allocate(ArrayType, reqLength);\n var postfix = endian === 'le' ? 'LE' : 'BE';\n this['_toArrayLike' + postfix](res, byteLength);\n return res;\n };\n\n BN.prototype._toArrayLikeLE = function _toArrayLikeLE (res, byteLength) {\n var position = 0;\n var carry = 0;\n\n for (var i = 0, shift = 0; i < this.length; i++) {\n var word = (this.words[i] << shift) | carry;\n\n res[position++] = word & 0xff;\n if (position < res.length) {\n res[position++] = (word >> 8) & 0xff;\n }\n if (position < res.length) {\n res[position++] = (word >> 16) & 0xff;\n }\n\n if (shift === 6) {\n if (position < res.length) {\n res[position++] = (word >> 24) & 0xff;\n }\n carry = 0;\n shift = 0;\n } else {\n carry = word >>> 24;\n shift += 2;\n }\n }\n\n if (position < res.length) {\n res[position++] = carry;\n\n while (position < res.length) {\n res[position++] = 0;\n }\n }\n };\n\n BN.prototype._toArrayLikeBE = function _toArrayLikeBE (res, byteLength) {\n var position = res.length - 1;\n var carry = 0;\n\n for (var i = 0, shift = 0; i < this.length; i++) {\n var word = (this.words[i] << shift) | carry;\n\n res[position--] = word & 0xff;\n if (position >= 0) {\n res[position--] = (word >> 8) & 0xff;\n }\n if (position >= 0) {\n res[position--] = (word >> 16) & 0xff;\n }\n\n if (shift === 6) {\n if (position >= 0) {\n res[position--] = (word >> 24) & 0xff;\n }\n carry = 0;\n shift = 0;\n } else {\n carry = word >>> 24;\n shift += 2;\n }\n }\n\n if (position >= 0) {\n res[position--] = carry;\n\n while (position >= 0) {\n res[position--] = 0;\n }\n }\n };\n\n if (Math.clz32) {\n BN.prototype._countBits = function _countBits (w) {\n return 32 - Math.clz32(w);\n };\n } else {\n BN.prototype._countBits = function _countBits (w) {\n var t = w;\n var r = 0;\n if (t >= 0x1000) {\n r += 13;\n t >>>= 13;\n }\n if (t >= 0x40) {\n r += 7;\n t >>>= 7;\n }\n if (t >= 0x8) {\n r += 4;\n t >>>= 4;\n }\n if (t >= 0x02) {\n r += 2;\n t >>>= 2;\n }\n return r + t;\n };\n }\n\n BN.prototype._zeroBits = function _zeroBits (w) {\n // Short-cut\n if (w === 0) return 26;\n\n var t = w;\n var r = 0;\n if ((t & 0x1fff) === 0) {\n r += 13;\n t >>>= 13;\n }\n if ((t & 0x7f) === 0) {\n r += 7;\n t >>>= 7;\n }\n if ((t & 0xf) === 0) {\n r += 4;\n t >>>= 4;\n }\n if ((t & 0x3) === 0) {\n r += 2;\n t >>>= 2;\n }\n if ((t & 0x1) === 0) {\n r++;\n }\n return r;\n };\n\n // Return number of used bits in a BN\n BN.prototype.bitLength = function bitLength () {\n var w = this.words[this.length - 1];\n var hi = this._countBits(w);\n return (this.length - 1) * 26 + hi;\n };\n\n function toBitArray (num) {\n var w = new Array(num.bitLength());\n\n for (var bit = 0; bit < w.length; bit++) {\n var off = (bit / 26) | 0;\n var wbit = bit % 26;\n\n w[bit] = (num.words[off] >>> wbit) & 0x01;\n }\n\n return w;\n }\n\n // Number of trailing zero bits\n BN.prototype.zeroBits = function zeroBits () {\n if (this.isZero()) return 0;\n\n var r = 0;\n for (var i = 0; i < this.length; i++) {\n var b = this._zeroBits(this.words[i]);\n r += b;\n if (b !== 26) break;\n }\n return r;\n };\n\n BN.prototype.byteLength = function byteLength () {\n return Math.ceil(this.bitLength() / 8);\n };\n\n BN.prototype.toTwos = function toTwos (width) {\n if (this.negative !== 0) {\n return this.abs().inotn(width).iaddn(1);\n }\n return this.clone();\n };\n\n BN.prototype.fromTwos = function fromTwos (width) {\n if (this.testn(width - 1)) {\n return this.notn(width).iaddn(1).ineg();\n }\n return this.clone();\n };\n\n BN.prototype.isNeg = function isNeg () {\n return this.negative !== 0;\n };\n\n // Return negative clone of `this`\n BN.prototype.neg = function neg () {\n return this.clone().ineg();\n };\n\n BN.prototype.ineg = function ineg () {\n if (!this.isZero()) {\n this.negative ^= 1;\n }\n\n return this;\n };\n\n // Or `num` with `this` in-place\n BN.prototype.iuor = function iuor (num) {\n while (this.length < num.length) {\n this.words[this.length++] = 0;\n }\n\n for (var i = 0; i < num.length; i++) {\n this.words[i] = this.words[i] | num.words[i];\n }\n\n return this._strip();\n };\n\n BN.prototype.ior = function ior (num) {\n assert((this.negative | num.negative) === 0);\n return this.iuor(num);\n };\n\n // Or `num` with `this`\n BN.prototype.or = function or (num) {\n if (this.length > num.length) return this.clone().ior(num);\n return num.clone().ior(this);\n };\n\n BN.prototype.uor = function uor (num) {\n if (this.length > num.length) return this.clone().iuor(num);\n return num.clone().iuor(this);\n };\n\n // And `num` with `this` in-place\n BN.prototype.iuand = function iuand (num) {\n // b = min-length(num, this)\n var b;\n if (this.length > num.length) {\n b = num;\n } else {\n b = this;\n }\n\n for (var i = 0; i < b.length; i++) {\n this.words[i] = this.words[i] & num.words[i];\n }\n\n this.length = b.length;\n\n return this._strip();\n };\n\n BN.prototype.iand = function iand (num) {\n assert((this.negative | num.negative) === 0);\n return this.iuand(num);\n };\n\n // And `num` with `this`\n BN.prototype.and = function and (num) {\n if (this.length > num.length) return this.clone().iand(num);\n return num.clone().iand(this);\n };\n\n BN.prototype.uand = function uand (num) {\n if (this.length > num.length) return this.clone().iuand(num);\n return num.clone().iuand(this);\n };\n\n // Xor `num` with `this` in-place\n BN.prototype.iuxor = function iuxor (num) {\n // a.length > b.length\n var a;\n var b;\n if (this.length > num.length) {\n a = this;\n b = num;\n } else {\n a = num;\n b = this;\n }\n\n for (var i = 0; i < b.length; i++) {\n this.words[i] = a.words[i] ^ b.words[i];\n }\n\n if (this !== a) {\n for (; i < a.length; i++) {\n this.words[i] = a.words[i];\n }\n }\n\n this.length = a.length;\n\n return this._strip();\n };\n\n BN.prototype.ixor = function ixor (num) {\n assert((this.negative | num.negative) === 0);\n return this.iuxor(num);\n };\n\n // Xor `num` with `this`\n BN.prototype.xor = function xor (num) {\n if (this.length > num.length) return this.clone().ixor(num);\n return num.clone().ixor(this);\n };\n\n BN.prototype.uxor = function uxor (num) {\n if (this.length > num.length) return this.clone().iuxor(num);\n return num.clone().iuxor(this);\n };\n\n // Not ``this`` with ``width`` bitwidth\n BN.prototype.inotn = function inotn (width) {\n assert(typeof width === 'number' && width >= 0);\n\n var bytesNeeded = Math.ceil(width / 26) | 0;\n var bitsLeft = width % 26;\n\n // Extend the buffer with leading zeroes\n this._expand(bytesNeeded);\n\n if (bitsLeft > 0) {\n bytesNeeded--;\n }\n\n // Handle complete words\n for (var i = 0; i < bytesNeeded; i++) {\n this.words[i] = ~this.words[i] & 0x3ffffff;\n }\n\n // Handle the residue\n if (bitsLeft > 0) {\n this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));\n }\n\n // And remove leading zeroes\n return this._strip();\n };\n\n BN.prototype.notn = function notn (width) {\n return this.clone().inotn(width);\n };\n\n // Set `bit` of `this`\n BN.prototype.setn = function setn (bit, val) {\n assert(typeof bit === 'number' && bit >= 0);\n\n var off = (bit / 26) | 0;\n var wbit = bit % 26;\n\n this._expand(off + 1);\n\n if (val) {\n this.words[off] = this.words[off] | (1 << wbit);\n } else {\n this.words[off] = this.words[off] & ~(1 << wbit);\n }\n\n return this._strip();\n };\n\n // Add `num` to `this` in-place\n BN.prototype.iadd = function iadd (num) {\n var r;\n\n // negative + positive\n if (this.negative !== 0 && num.negative === 0) {\n this.negative = 0;\n r = this.isub(num);\n this.negative ^= 1;\n return this._normSign();\n\n // positive + negative\n } else if (this.negative === 0 && num.negative !== 0) {\n num.negative = 0;\n r = this.isub(num);\n num.negative = 1;\n return r._normSign();\n }\n\n // a.length > b.length\n var a, b;\n if (this.length > num.length) {\n a = this;\n b = num;\n } else {\n a = num;\n b = this;\n }\n\n var carry = 0;\n for (var i = 0; i < b.length; i++) {\n r = (a.words[i] | 0) + (b.words[i] | 0) + carry;\n this.words[i] = r & 0x3ffffff;\n carry = r >>> 26;\n }\n for (; carry !== 0 && i < a.length; i++) {\n r = (a.words[i] | 0) + carry;\n this.words[i] = r & 0x3ffffff;\n carry = r >>> 26;\n }\n\n this.length = a.length;\n if (carry !== 0) {\n this.words[this.length] = carry;\n this.length++;\n // Copy the rest of the words\n } else if (a !== this) {\n for (; i < a.length; i++) {\n this.words[i] = a.words[i];\n }\n }\n\n return this;\n };\n\n // Add `num` to `this`\n BN.prototype.add = function add (num) {\n var res;\n if (num.negative !== 0 && this.negative === 0) {\n num.negative = 0;\n res = this.sub(num);\n num.negative ^= 1;\n return res;\n } else if (num.negative === 0 && this.negative !== 0) {\n this.negative = 0;\n res = num.sub(this);\n this.negative = 1;\n return res;\n }\n\n if (this.length > num.length) return this.clone().iadd(num);\n\n return num.clone().iadd(this);\n };\n\n // Subtract `num` from `this` in-place\n BN.prototype.isub = function isub (num) {\n // this - (-num) = this + num\n if (num.negative !== 0) {\n num.negative = 0;\n var r = this.iadd(num);\n num.negative = 1;\n return r._normSign();\n\n // -this - num = -(this + num)\n } else if (this.negative !== 0) {\n this.negative = 0;\n this.iadd(num);\n this.negative = 1;\n return this._normSign();\n }\n\n // At this point both numbers are positive\n var cmp = this.cmp(num);\n\n // Optimization - zeroify\n if (cmp === 0) {\n this.negative = 0;\n this.length = 1;\n this.words[0] = 0;\n return this;\n }\n\n // a > b\n var a, b;\n if (cmp > 0) {\n a = this;\n b = num;\n } else {\n a = num;\n b = this;\n }\n\n var carry = 0;\n for (var i = 0; i < b.length; i++) {\n r = (a.words[i] | 0) - (b.words[i] | 0) + carry;\n carry = r >> 26;\n this.words[i] = r & 0x3ffffff;\n }\n for (; carry !== 0 && i < a.length; i++) {\n r = (a.words[i] | 0) + carry;\n carry = r >> 26;\n this.words[i] = r & 0x3ffffff;\n }\n\n // Copy rest of the words\n if (carry === 0 && i < a.length && a !== this) {\n for (; i < a.length; i++) {\n this.words[i] = a.words[i];\n }\n }\n\n this.length = Math.max(this.length, i);\n\n if (a !== this) {\n this.negative = 1;\n }\n\n return this._strip();\n };\n\n // Subtract `num` from `this`\n BN.prototype.sub = function sub (num) {\n return this.clone().isub(num);\n };\n\n function smallMulTo (self, num, out) {\n out.negative = num.negative ^ self.negative;\n var len = (self.length + num.length) | 0;\n out.length = len;\n len = (len - 1) | 0;\n\n // Peel one iteration (compiler can't do it, because of code complexity)\n var a = self.words[0] | 0;\n var b = num.words[0] | 0;\n var r = a * b;\n\n var lo = r & 0x3ffffff;\n var carry = (r / 0x4000000) | 0;\n out.words[0] = lo;\n\n for (var k = 1; k < len; k++) {\n // Sum all words with the same `i + j = k` and accumulate `ncarry`,\n // note that ncarry could be >= 0x3ffffff\n var ncarry = carry >>> 26;\n var rword = carry & 0x3ffffff;\n var maxJ = Math.min(k, num.length - 1);\n for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {\n var i = (k - j) | 0;\n a = self.words[i] | 0;\n b = num.words[j] | 0;\n r = a * b + rword;\n ncarry += (r / 0x4000000) | 0;\n rword = r & 0x3ffffff;\n }\n out.words[k] = rword | 0;\n carry = ncarry | 0;\n }\n if (carry !== 0) {\n out.words[k] = carry | 0;\n } else {\n out.length--;\n }\n\n return out._strip();\n }\n\n // TODO(indutny): it may be reasonable to omit it for users who don't need\n // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit\n // multiplication (like elliptic secp256k1).\n var comb10MulTo = function comb10MulTo (self, num, out) {\n var a = self.words;\n var b = num.words;\n var o = out.words;\n var c = 0;\n var lo;\n var mid;\n var hi;\n var a0 = a[0] | 0;\n var al0 = a0 & 0x1fff;\n var ah0 = a0 >>> 13;\n var a1 = a[1] | 0;\n var al1 = a1 & 0x1fff;\n var ah1 = a1 >>> 13;\n var a2 = a[2] | 0;\n var al2 = a2 & 0x1fff;\n var ah2 = a2 >>> 13;\n var a3 = a[3] | 0;\n var al3 = a3 & 0x1fff;\n var ah3 = a3 >>> 13;\n var a4 = a[4] | 0;\n var al4 = a4 & 0x1fff;\n var ah4 = a4 >>> 13;\n var a5 = a[5] | 0;\n var al5 = a5 & 0x1fff;\n var ah5 = a5 >>> 13;\n var a6 = a[6] | 0;\n var al6 = a6 & 0x1fff;\n var ah6 = a6 >>> 13;\n var a7 = a[7] | 0;\n var al7 = a7 & 0x1fff;\n var ah7 = a7 >>> 13;\n var a8 = a[8] | 0;\n var al8 = a8 & 0x1fff;\n var ah8 = a8 >>> 13;\n var a9 = a[9] | 0;\n var al9 = a9 & 0x1fff;\n var ah9 = a9 >>> 13;\n var b0 = b[0] | 0;\n var bl0 = b0 & 0x1fff;\n var bh0 = b0 >>> 13;\n var b1 = b[1] | 0;\n var bl1 = b1 & 0x1fff;\n var bh1 = b1 >>> 13;\n var b2 = b[2] | 0;\n var bl2 = b2 & 0x1fff;\n var bh2 = b2 >>> 13;\n var b3 = b[3] | 0;\n var bl3 = b3 & 0x1fff;\n var bh3 = b3 >>> 13;\n var b4 = b[4] | 0;\n var bl4 = b4 & 0x1fff;\n var bh4 = b4 >>> 13;\n var b5 = b[5] | 0;\n var bl5 = b5 & 0x1fff;\n var bh5 = b5 >>> 13;\n var b6 = b[6] | 0;\n var bl6 = b6 & 0x1fff;\n var bh6 = b6 >>> 13;\n var b7 = b[7] | 0;\n var bl7 = b7 & 0x1fff;\n var bh7 = b7 >>> 13;\n var b8 = b[8] | 0;\n var bl8 = b8 & 0x1fff;\n var bh8 = b8 >>> 13;\n var b9 = b[9] | 0;\n var bl9 = b9 & 0x1fff;\n var bh9 = b9 >>> 13;\n\n out.negative = self.negative ^ num.negative;\n out.length = 19;\n /* k = 0 */\n lo = Math.imul(al0, bl0);\n mid = Math.imul(al0, bh0);\n mid = (mid + Math.imul(ah0, bl0)) | 0;\n hi = Math.imul(ah0, bh0);\n var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0;\n w0 &= 0x3ffffff;\n /* k = 1 */\n lo = Math.imul(al1, bl0);\n mid = Math.imul(al1, bh0);\n mid = (mid + Math.imul(ah1, bl0)) | 0;\n hi = Math.imul(ah1, bh0);\n lo = (lo + Math.imul(al0, bl1)) | 0;\n mid = (mid + Math.imul(al0, bh1)) | 0;\n mid = (mid + Math.imul(ah0, bl1)) | 0;\n hi = (hi + Math.imul(ah0, bh1)) | 0;\n var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0;\n w1 &= 0x3ffffff;\n /* k = 2 */\n lo = Math.imul(al2, bl0);\n mid = Math.imul(al2, bh0);\n mid = (mid + Math.imul(ah2, bl0)) | 0;\n hi = Math.imul(ah2, bh0);\n lo = (lo + Math.imul(al1, bl1)) | 0;\n mid = (mid + Math.imul(al1, bh1)) | 0;\n mid = (mid + Math.imul(ah1, bl1)) | 0;\n hi = (hi + Math.imul(ah1, bh1)) | 0;\n lo = (lo + Math.imul(al0, bl2)) | 0;\n mid = (mid + Math.imul(al0, bh2)) | 0;\n mid = (mid + Math.imul(ah0, bl2)) | 0;\n hi = (hi + Math.imul(ah0, bh2)) | 0;\n var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0;\n w2 &= 0x3ffffff;\n /* k = 3 */\n lo = Math.imul(al3, bl0);\n mid = Math.imul(al3, bh0);\n mid = (mid + Math.imul(ah3, bl0)) | 0;\n hi = Math.imul(ah3, bh0);\n lo = (lo + Math.imul(al2, bl1)) | 0;\n mid = (mid + Math.imul(al2, bh1)) | 0;\n mid = (mid + Math.imul(ah2, bl1)) | 0;\n hi = (hi + Math.imul(ah2, bh1)) | 0;\n lo = (lo + Math.imul(al1, bl2)) | 0;\n mid = (mid + Math.imul(al1, bh2)) | 0;\n mid = (mid + Math.imul(ah1, bl2)) | 0;\n hi = (hi + Math.imul(ah1, bh2)) | 0;\n lo = (lo + Math.imul(al0, bl3)) | 0;\n mid = (mid + Math.imul(al0, bh3)) | 0;\n mid = (mid + Math.imul(ah0, bl3)) | 0;\n hi = (hi + Math.imul(ah0, bh3)) | 0;\n var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0;\n w3 &= 0x3ffffff;\n /* k = 4 */\n lo = Math.imul(al4, bl0);\n mid = Math.imul(al4, bh0);\n mid = (mid + Math.imul(ah4, bl0)) | 0;\n hi = Math.imul(ah4, bh0);\n lo = (lo + Math.imul(al3, bl1)) | 0;\n mid = (mid + Math.imul(al3, bh1)) | 0;\n mid = (mid + Math.imul(ah3, bl1)) | 0;\n hi = (hi + Math.imul(ah3, bh1)) | 0;\n lo = (lo + Math.imul(al2, bl2)) | 0;\n mid = (mid + Math.imul(al2, bh2)) | 0;\n mid = (mid + Math.imul(ah2, bl2)) | 0;\n hi = (hi + Math.imul(ah2, bh2)) | 0;\n lo = (lo + Math.imul(al1, bl3)) | 0;\n mid = (mid + Math.imul(al1, bh3)) | 0;\n mid = (mid + Math.imul(ah1, bl3)) | 0;\n hi = (hi + Math.imul(ah1, bh3)) | 0;\n lo = (lo + Math.imul(al0, bl4)) | 0;\n mid = (mid + Math.imul(al0, bh4)) | 0;\n mid = (mid + Math.imul(ah0, bl4)) | 0;\n hi = (hi + Math.imul(ah0, bh4)) | 0;\n var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0;\n w4 &= 0x3ffffff;\n /* k = 5 */\n lo = Math.imul(al5, bl0);\n mid = Math.imul(al5, bh0);\n mid = (mid + Math.imul(ah5, bl0)) | 0;\n hi = Math.imul(ah5, bh0);\n lo = (lo + Math.imul(al4, bl1)) | 0;\n mid = (mid + Math.imul(al4, bh1)) | 0;\n mid = (mid + Math.imul(ah4, bl1)) | 0;\n hi = (hi + Math.imul(ah4, bh1)) | 0;\n lo = (lo + Math.imul(al3, bl2)) | 0;\n mid = (mid + Math.imul(al3, bh2)) | 0;\n mid = (mid + Math.imul(ah3, bl2)) | 0;\n hi = (hi + Math.imul(ah3, bh2)) | 0;\n lo = (lo + Math.imul(al2, bl3)) | 0;\n mid = (mid + Math.imul(al2, bh3)) | 0;\n mid = (mid + Math.imul(ah2, bl3)) | 0;\n hi = (hi + Math.imul(ah2, bh3)) | 0;\n lo = (lo + Math.imul(al1, bl4)) | 0;\n mid = (mid + Math.imul(al1, bh4)) | 0;\n mid = (mid + Math.imul(ah1, bl4)) | 0;\n hi = (hi + Math.imul(ah1, bh4)) | 0;\n lo = (lo + Math.imul(al0, bl5)) | 0;\n mid = (mid + Math.imul(al0, bh5)) | 0;\n mid = (mid + Math.imul(ah0, bl5)) | 0;\n hi = (hi + Math.imul(ah0, bh5)) | 0;\n var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0;\n w5 &= 0x3ffffff;\n /* k = 6 */\n lo = Math.imul(al6, bl0);\n mid = Math.imul(al6, bh0);\n mid = (mid + Math.imul(ah6, bl0)) | 0;\n hi = Math.imul(ah6, bh0);\n lo = (lo + Math.imul(al5, bl1)) | 0;\n mid = (mid + Math.imul(al5, bh1)) | 0;\n mid = (mid + Math.imul(ah5, bl1)) | 0;\n hi = (hi + Math.imul(ah5, bh1)) | 0;\n lo = (lo + Math.imul(al4, bl2)) | 0;\n mid = (mid + Math.imul(al4, bh2)) | 0;\n mid = (mid + Math.imul(ah4, bl2)) | 0;\n hi = (hi + Math.imul(ah4, bh2)) | 0;\n lo = (lo + Math.imul(al3, bl3)) | 0;\n mid = (mid + Math.imul(al3, bh3)) | 0;\n mid = (mid + Math.imul(ah3, bl3)) | 0;\n hi = (hi + Math.imul(ah3, bh3)) | 0;\n lo = (lo + Math.imul(al2, bl4)) | 0;\n mid = (mid + Math.imul(al2, bh4)) | 0;\n mid = (mid + Math.imul(ah2, bl4)) | 0;\n hi = (hi + Math.imul(ah2, bh4)) | 0;\n lo = (lo + Math.imul(al1, bl5)) | 0;\n mid = (mid + Math.imul(al1, bh5)) | 0;\n mid = (mid + Math.imul(ah1, bl5)) | 0;\n hi = (hi + Math.imul(ah1, bh5)) | 0;\n lo = (lo + Math.imul(al0, bl6)) | 0;\n mid = (mid + Math.imul(al0, bh6)) | 0;\n mid = (mid + Math.imul(ah0, bl6)) | 0;\n hi = (hi + Math.imul(ah0, bh6)) | 0;\n var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0;\n w6 &= 0x3ffffff;\n /* k = 7 */\n lo = Math.imul(al7, bl0);\n mid = Math.imul(al7, bh0);\n mid = (mid + Math.imul(ah7, bl0)) | 0;\n hi = Math.imul(ah7, bh0);\n lo = (lo + Math.imul(al6, bl1)) | 0;\n mid = (mid + Math.imul(al6, bh1)) | 0;\n mid = (mid + Math.imul(ah6, bl1)) | 0;\n hi = (hi + Math.imul(ah6, bh1)) | 0;\n lo = (lo + Math.imul(al5, bl2)) | 0;\n mid = (mid + Math.imul(al5, bh2)) | 0;\n mid = (mid + Math.imul(ah5, bl2)) | 0;\n hi = (hi + Math.imul(ah5, bh2)) | 0;\n lo = (lo + Math.imul(al4, bl3)) | 0;\n mid = (mid + Math.imul(al4, bh3)) | 0;\n mid = (mid + Math.imul(ah4, bl3)) | 0;\n hi = (hi + Math.imul(ah4, bh3)) | 0;\n lo = (lo + Math.imul(al3, bl4)) | 0;\n mid = (mid + Math.imul(al3, bh4)) | 0;\n mid = (mid + Math.imul(ah3, bl4)) | 0;\n hi = (hi + Math.imul(ah3, bh4)) | 0;\n lo = (lo + Math.imul(al2, bl5)) | 0;\n mid = (mid + Math.imul(al2, bh5)) | 0;\n mid = (mid + Math.imul(ah2, bl5)) | 0;\n hi = (hi + Math.imul(ah2, bh5)) | 0;\n lo = (lo + Math.imul(al1, bl6)) | 0;\n mid = (mid + Math.imul(al1, bh6)) | 0;\n mid = (mid + Math.imul(ah1, bl6)) | 0;\n hi = (hi + Math.imul(ah1, bh6)) | 0;\n lo = (lo + Math.imul(al0, bl7)) | 0;\n mid = (mid + Math.imul(al0, bh7)) | 0;\n mid = (mid + Math.imul(ah0, bl7)) | 0;\n hi = (hi + Math.imul(ah0, bh7)) | 0;\n var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0;\n w7 &= 0x3ffffff;\n /* k = 8 */\n lo = Math.imul(al8, bl0);\n mid = Math.imul(al8, bh0);\n mid = (mid + Math.imul(ah8, bl0)) | 0;\n hi = Math.imul(ah8, bh0);\n lo = (lo + Math.imul(al7, bl1)) | 0;\n mid = (mid + Math.imul(al7, bh1)) | 0;\n mid = (mid + Math.imul(ah7, bl1)) | 0;\n hi = (hi + Math.imul(ah7, bh1)) | 0;\n lo = (lo + Math.imul(al6, bl2)) | 0;\n mid = (mid + Math.imul(al6, bh2)) | 0;\n mid = (mid + Math.imul(ah6, bl2)) | 0;\n hi = (hi + Math.imul(ah6, bh2)) | 0;\n lo = (lo + Math.imul(al5, bl3)) | 0;\n mid = (mid + Math.imul(al5, bh3)) | 0;\n mid = (mid + Math.imul(ah5, bl3)) | 0;\n hi = (hi + Math.imul(ah5, bh3)) | 0;\n lo = (lo + Math.imul(al4, bl4)) | 0;\n mid = (mid + Math.imul(al4, bh4)) | 0;\n mid = (mid + Math.imul(ah4, bl4)) | 0;\n hi = (hi + Math.imul(ah4, bh4)) | 0;\n lo = (lo + Math.imul(al3, bl5)) | 0;\n mid = (mid + Math.imul(al3, bh5)) | 0;\n mid = (mid + Math.imul(ah3, bl5)) | 0;\n hi = (hi + Math.imul(ah3, bh5)) | 0;\n lo = (lo + Math.imul(al2, bl6)) | 0;\n mid = (mid + Math.imul(al2, bh6)) | 0;\n mid = (mid + Math.imul(ah2, bl6)) | 0;\n hi = (hi + Math.imul(ah2, bh6)) | 0;\n lo = (lo + Math.imul(al1, bl7)) | 0;\n mid = (mid + Math.imul(al1, bh7)) | 0;\n mid = (mid + Math.imul(ah1, bl7)) | 0;\n hi = (hi + Math.imul(ah1, bh7)) | 0;\n lo = (lo + Math.imul(al0, bl8)) | 0;\n mid = (mid + Math.imul(al0, bh8)) | 0;\n mid = (mid + Math.imul(ah0, bl8)) | 0;\n hi = (hi + Math.imul(ah0, bh8)) | 0;\n var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0;\n w8 &= 0x3ffffff;\n /* k = 9 */\n lo = Math.imul(al9, bl0);\n mid = Math.imul(al9, bh0);\n mid = (mid + Math.imul(ah9, bl0)) | 0;\n hi = Math.imul(ah9, bh0);\n lo = (lo + Math.imul(al8, bl1)) | 0;\n mid = (mid + Math.imul(al8, bh1)) | 0;\n mid = (mid + Math.imul(ah8, bl1)) | 0;\n hi = (hi + Math.imul(ah8, bh1)) | 0;\n lo = (lo + Math.imul(al7, bl2)) | 0;\n mid = (mid + Math.imul(al7, bh2)) | 0;\n mid = (mid + Math.imul(ah7, bl2)) | 0;\n hi = (hi + Math.imul(ah7, bh2)) | 0;\n lo = (lo + Math.imul(al6, bl3)) | 0;\n mid = (mid + Math.imul(al6, bh3)) | 0;\n mid = (mid + Math.imul(ah6, bl3)) | 0;\n hi = (hi + Math.imul(ah6, bh3)) | 0;\n lo = (lo + Math.imul(al5, bl4)) | 0;\n mid = (mid + Math.imul(al5, bh4)) | 0;\n mid = (mid + Math.imul(ah5, bl4)) | 0;\n hi = (hi + Math.imul(ah5, bh4)) | 0;\n lo = (lo + Math.imul(al4, bl5)) | 0;\n mid = (mid + Math.imul(al4, bh5)) | 0;\n mid = (mid + Math.imul(ah4, bl5)) | 0;\n hi = (hi + Math.imul(ah4, bh5)) | 0;\n lo = (lo + Math.imul(al3, bl6)) | 0;\n mid = (mid + Math.imul(al3, bh6)) | 0;\n mid = (mid + Math.imul(ah3, bl6)) | 0;\n hi = (hi + Math.imul(ah3, bh6)) | 0;\n lo = (lo + Math.imul(al2, bl7)) | 0;\n mid = (mid + Math.imul(al2, bh7)) | 0;\n mid = (mid + Math.imul(ah2, bl7)) | 0;\n hi = (hi + Math.imul(ah2, bh7)) | 0;\n lo = (lo + Math.imul(al1, bl8)) | 0;\n mid = (mid + Math.imul(al1, bh8)) | 0;\n mid = (mid + Math.imul(ah1, bl8)) | 0;\n hi = (hi + Math.imul(ah1, bh8)) | 0;\n lo = (lo + Math.imul(al0, bl9)) | 0;\n mid = (mid + Math.imul(al0, bh9)) | 0;\n mid = (mid + Math.imul(ah0, bl9)) | 0;\n hi = (hi + Math.imul(ah0, bh9)) | 0;\n var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0;\n w9 &= 0x3ffffff;\n /* k = 10 */\n lo = Math.imul(al9, bl1);\n mid = Math.imul(al9, bh1);\n mid = (mid + Math.imul(ah9, bl1)) | 0;\n hi = Math.imul(ah9, bh1);\n lo = (lo + Math.imul(al8, bl2)) | 0;\n mid = (mid + Math.imul(al8, bh2)) | 0;\n mid = (mid + Math.imul(ah8, bl2)) | 0;\n hi = (hi + Math.imul(ah8, bh2)) | 0;\n lo = (lo + Math.imul(al7, bl3)) | 0;\n mid = (mid + Math.imul(al7, bh3)) | 0;\n mid = (mid + Math.imul(ah7, bl3)) | 0;\n hi = (hi + Math.imul(ah7, bh3)) | 0;\n lo = (lo + Math.imul(al6, bl4)) | 0;\n mid = (mid + Math.imul(al6, bh4)) | 0;\n mid = (mid + Math.imul(ah6, bl4)) | 0;\n hi = (hi + Math.imul(ah6, bh4)) | 0;\n lo = (lo + Math.imul(al5, bl5)) | 0;\n mid = (mid + Math.imul(al5, bh5)) | 0;\n mid = (mid + Math.imul(ah5, bl5)) | 0;\n hi = (hi + Math.imul(ah5, bh5)) | 0;\n lo = (lo + Math.imul(al4, bl6)) | 0;\n mid = (mid + Math.imul(al4, bh6)) | 0;\n mid = (mid + Math.imul(ah4, bl6)) | 0;\n hi = (hi + Math.imul(ah4, bh6)) | 0;\n lo = (lo + Math.imul(al3, bl7)) | 0;\n mid = (mid + Math.imul(al3, bh7)) | 0;\n mid = (mid + Math.imul(ah3, bl7)) | 0;\n hi = (hi + Math.imul(ah3, bh7)) | 0;\n lo = (lo + Math.imul(al2, bl8)) | 0;\n mid = (mid + Math.imul(al2, bh8)) | 0;\n mid = (mid + Math.imul(ah2, bl8)) | 0;\n hi = (hi + Math.imul(ah2, bh8)) | 0;\n lo = (lo + Math.imul(al1, bl9)) | 0;\n mid = (mid + Math.imul(al1, bh9)) | 0;\n mid = (mid + Math.imul(ah1, bl9)) | 0;\n hi = (hi + Math.imul(ah1, bh9)) | 0;\n var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0;\n w10 &= 0x3ffffff;\n /* k = 11 */\n lo = Math.imul(al9, bl2);\n mid = Math.imul(al9, bh2);\n mid = (mid + Math.imul(ah9, bl2)) | 0;\n hi = Math.imul(ah9, bh2);\n lo = (lo + Math.imul(al8, bl3)) | 0;\n mid = (mid + Math.imul(al8, bh3)) | 0;\n mid = (mid + Math.imul(ah8, bl3)) | 0;\n hi = (hi + Math.imul(ah8, bh3)) | 0;\n lo = (lo + Math.imul(al7, bl4)) | 0;\n mid = (mid + Math.imul(al7, bh4)) | 0;\n mid = (mid + Math.imul(ah7, bl4)) | 0;\n hi = (hi + Math.imul(ah7, bh4)) | 0;\n lo = (lo + Math.imul(al6, bl5)) | 0;\n mid = (mid + Math.imul(al6, bh5)) | 0;\n mid = (mid + Math.imul(ah6, bl5)) | 0;\n hi = (hi + Math.imul(ah6, bh5)) | 0;\n lo = (lo + Math.imul(al5, bl6)) | 0;\n mid = (mid + Math.imul(al5, bh6)) | 0;\n mid = (mid + Math.imul(ah5, bl6)) | 0;\n hi = (hi + Math.imul(ah5, bh6)) | 0;\n lo = (lo + Math.imul(al4, bl7)) | 0;\n mid = (mid + Math.imul(al4, bh7)) | 0;\n mid = (mid + Math.imul(ah4, bl7)) | 0;\n hi = (hi + Math.imul(ah4, bh7)) | 0;\n lo = (lo + Math.imul(al3, bl8)) | 0;\n mid = (mid + Math.imul(al3, bh8)) | 0;\n mid = (mid + Math.imul(ah3, bl8)) | 0;\n hi = (hi + Math.imul(ah3, bh8)) | 0;\n lo = (lo + Math.imul(al2, bl9)) | 0;\n mid = (mid + Math.imul(al2, bh9)) | 0;\n mid = (mid + Math.imul(ah2, bl9)) | 0;\n hi = (hi + Math.imul(ah2, bh9)) | 0;\n var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0;\n w11 &= 0x3ffffff;\n /* k = 12 */\n lo = Math.imul(al9, bl3);\n mid = Math.imul(al9, bh3);\n mid = (mid + Math.imul(ah9, bl3)) | 0;\n hi = Math.imul(ah9, bh3);\n lo = (lo + Math.imul(al8, bl4)) | 0;\n mid = (mid + Math.imul(al8, bh4)) | 0;\n mid = (mid + Math.imul(ah8, bl4)) | 0;\n hi = (hi + Math.imul(ah8, bh4)) | 0;\n lo = (lo + Math.imul(al7, bl5)) | 0;\n mid = (mid + Math.imul(al7, bh5)) | 0;\n mid = (mid + Math.imul(ah7, bl5)) | 0;\n hi = (hi + Math.imul(ah7, bh5)) | 0;\n lo = (lo + Math.imul(al6, bl6)) | 0;\n mid = (mid + Math.imul(al6, bh6)) | 0;\n mid = (mid + Math.imul(ah6, bl6)) | 0;\n hi = (hi + Math.imul(ah6, bh6)) | 0;\n lo = (lo + Math.imul(al5, bl7)) | 0;\n mid = (mid + Math.imul(al5, bh7)) | 0;\n mid = (mid + Math.imul(ah5, bl7)) | 0;\n hi = (hi + Math.imul(ah5, bh7)) | 0;\n lo = (lo + Math.imul(al4, bl8)) | 0;\n mid = (mid + Math.imul(al4, bh8)) | 0;\n mid = (mid + Math.imul(ah4, bl8)) | 0;\n hi = (hi + Math.imul(ah4, bh8)) | 0;\n lo = (lo + Math.imul(al3, bl9)) | 0;\n mid = (mid + Math.imul(al3, bh9)) | 0;\n mid = (mid + Math.imul(ah3, bl9)) | 0;\n hi = (hi + Math.imul(ah3, bh9)) | 0;\n var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0;\n w12 &= 0x3ffffff;\n /* k = 13 */\n lo = Math.imul(al9, bl4);\n mid = Math.imul(al9, bh4);\n mid = (mid + Math.imul(ah9, bl4)) | 0;\n hi = Math.imul(ah9, bh4);\n lo = (lo + Math.imul(al8, bl5)) | 0;\n mid = (mid + Math.imul(al8, bh5)) | 0;\n mid = (mid + Math.imul(ah8, bl5)) | 0;\n hi = (hi + Math.imul(ah8, bh5)) | 0;\n lo = (lo + Math.imul(al7, bl6)) | 0;\n mid = (mid + Math.imul(al7, bh6)) | 0;\n mid = (mid + Math.imul(ah7, bl6)) | 0;\n hi = (hi + Math.imul(ah7, bh6)) | 0;\n lo = (lo + Math.imul(al6, bl7)) | 0;\n mid = (mid + Math.imul(al6, bh7)) | 0;\n mid = (mid + Math.imul(ah6, bl7)) | 0;\n hi = (hi + Math.imul(ah6, bh7)) | 0;\n lo = (lo + Math.imul(al5, bl8)) | 0;\n mid = (mid + Math.imul(al5, bh8)) | 0;\n mid = (mid + Math.imul(ah5, bl8)) | 0;\n hi = (hi + Math.imul(ah5, bh8)) | 0;\n lo = (lo + Math.imul(al4, bl9)) | 0;\n mid = (mid + Math.imul(al4, bh9)) | 0;\n mid = (mid + Math.imul(ah4, bl9)) | 0;\n hi = (hi + Math.imul(ah4, bh9)) | 0;\n var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0;\n w13 &= 0x3ffffff;\n /* k = 14 */\n lo = Math.imul(al9, bl5);\n mid = Math.imul(al9, bh5);\n mid = (mid + Math.imul(ah9, bl5)) | 0;\n hi = Math.imul(ah9, bh5);\n lo = (lo + Math.imul(al8, bl6)) | 0;\n mid = (mid + Math.imul(al8, bh6)) | 0;\n mid = (mid + Math.imul(ah8, bl6)) | 0;\n hi = (hi + Math.imul(ah8, bh6)) | 0;\n lo = (lo + Math.imul(al7, bl7)) | 0;\n mid = (mid + Math.imul(al7, bh7)) | 0;\n mid = (mid + Math.imul(ah7, bl7)) | 0;\n hi = (hi + Math.imul(ah7, bh7)) | 0;\n lo = (lo + Math.imul(al6, bl8)) | 0;\n mid = (mid + Math.imul(al6, bh8)) | 0;\n mid = (mid + Math.imul(ah6, bl8)) | 0;\n hi = (hi + Math.imul(ah6, bh8)) | 0;\n lo = (lo + Math.imul(al5, bl9)) | 0;\n mid = (mid + Math.imul(al5, bh9)) | 0;\n mid = (mid + Math.imul(ah5, bl9)) | 0;\n hi = (hi + Math.imul(ah5, bh9)) | 0;\n var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0;\n w14 &= 0x3ffffff;\n /* k = 15 */\n lo = Math.imul(al9, bl6);\n mid = Math.imul(al9, bh6);\n mid = (mid + Math.imul(ah9, bl6)) | 0;\n hi = Math.imul(ah9, bh6);\n lo = (lo + Math.imul(al8, bl7)) | 0;\n mid = (mid + Math.imul(al8, bh7)) | 0;\n mid = (mid + Math.imul(ah8, bl7)) | 0;\n hi = (hi + Math.imul(ah8, bh7)) | 0;\n lo = (lo + Math.imul(al7, bl8)) | 0;\n mid = (mid + Math.imul(al7, bh8)) | 0;\n mid = (mid + Math.imul(ah7, bl8)) | 0;\n hi = (hi + Math.imul(ah7, bh8)) | 0;\n lo = (lo + Math.imul(al6, bl9)) | 0;\n mid = (mid + Math.imul(al6, bh9)) | 0;\n mid = (mid + Math.imul(ah6, bl9)) | 0;\n hi = (hi + Math.imul(ah6, bh9)) | 0;\n var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0;\n w15 &= 0x3ffffff;\n /* k = 16 */\n lo = Math.imul(al9, bl7);\n mid = Math.imul(al9, bh7);\n mid = (mid + Math.imul(ah9, bl7)) | 0;\n hi = Math.imul(ah9, bh7);\n lo = (lo + Math.imul(al8, bl8)) | 0;\n mid = (mid + Math.imul(al8, bh8)) | 0;\n mid = (mid + Math.imul(ah8, bl8)) | 0;\n hi = (hi + Math.imul(ah8, bh8)) | 0;\n lo = (lo + Math.imul(al7, bl9)) | 0;\n mid = (mid + Math.imul(al7, bh9)) | 0;\n mid = (mid + Math.imul(ah7, bl9)) | 0;\n hi = (hi + Math.imul(ah7, bh9)) | 0;\n var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0;\n w16 &= 0x3ffffff;\n /* k = 17 */\n lo = Math.imul(al9, bl8);\n mid = Math.imul(al9, bh8);\n mid = (mid + Math.imul(ah9, bl8)) | 0;\n hi = Math.imul(ah9, bh8);\n lo = (lo + Math.imul(al8, bl9)) | 0;\n mid = (mid + Math.imul(al8, bh9)) | 0;\n mid = (mid + Math.imul(ah8, bl9)) | 0;\n hi = (hi + Math.imul(ah8, bh9)) | 0;\n var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0;\n w17 &= 0x3ffffff;\n /* k = 18 */\n lo = Math.imul(al9, bl9);\n mid = Math.imul(al9, bh9);\n mid = (mid + Math.imul(ah9, bl9)) | 0;\n hi = Math.imul(ah9, bh9);\n var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0;\n c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0;\n w18 &= 0x3ffffff;\n o[0] = w0;\n o[1] = w1;\n o[2] = w2;\n o[3] = w3;\n o[4] = w4;\n o[5] = w5;\n o[6] = w6;\n o[7] = w7;\n o[8] = w8;\n o[9] = w9;\n o[10] = w10;\n o[11] = w11;\n o[12] = w12;\n o[13] = w13;\n o[14] = w14;\n o[15] = w15;\n o[16] = w16;\n o[17] = w17;\n o[18] = w18;\n if (c !== 0) {\n o[19] = c;\n out.length++;\n }\n return out;\n };\n\n // Polyfill comb\n if (!Math.imul) {\n comb10MulTo = smallMulTo;\n }\n\n function bigMulTo (self, num, out) {\n out.negative = num.negative ^ self.negative;\n out.length = self.length + num.length;\n\n var carry = 0;\n var hncarry = 0;\n for (var k = 0; k < out.length - 1; k++) {\n // Sum all words with the same `i + j = k` and accumulate `ncarry`,\n // note that ncarry could be >= 0x3ffffff\n var ncarry = hncarry;\n hncarry = 0;\n var rword = carry & 0x3ffffff;\n var maxJ = Math.min(k, num.length - 1);\n for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) {\n var i = k - j;\n var a = self.words[i] | 0;\n var b = num.words[j] | 0;\n var r = a * b;\n\n var lo = r & 0x3ffffff;\n ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0;\n lo = (lo + rword) | 0;\n rword = lo & 0x3ffffff;\n ncarry = (ncarry + (lo >>> 26)) | 0;\n\n hncarry += ncarry >>> 26;\n ncarry &= 0x3ffffff;\n }\n out.words[k] = rword;\n carry = ncarry;\n ncarry = hncarry;\n }\n if (carry !== 0) {\n out.words[k] = carry;\n } else {\n out.length--;\n }\n\n return out._strip();\n }\n\n function jumboMulTo (self, num, out) {\n // Temporary disable, see https://github.com/indutny/bn.js/issues/211\n // var fftm = new FFTM();\n // return fftm.mulp(self, num, out);\n return bigMulTo(self, num, out);\n }\n\n BN.prototype.mulTo = function mulTo (num, out) {\n var res;\n var len = this.length + num.length;\n if (this.length === 10 && num.length === 10) {\n res = comb10MulTo(this, num, out);\n } else if (len < 63) {\n res = smallMulTo(this, num, out);\n } else if (len < 1024) {\n res = bigMulTo(this, num, out);\n } else {\n res = jumboMulTo(this, num, out);\n }\n\n return res;\n };\n\n // Cooley-Tukey algorithm for FFT\n // slightly revisited to rely on looping instead of recursion\n\n function FFTM (x, y) {\n this.x = x;\n this.y = y;\n }\n\n FFTM.prototype.makeRBT = function makeRBT (N) {\n var t = new Array(N);\n var l = BN.prototype._countBits(N) - 1;\n for (var i = 0; i < N; i++) {\n t[i] = this.revBin(i, l, N);\n }\n\n return t;\n };\n\n // Returns binary-reversed representation of `x`\n FFTM.prototype.revBin = function revBin (x, l, N) {\n if (x === 0 || x === N - 1) return x;\n\n var rb = 0;\n for (var i = 0; i < l; i++) {\n rb |= (x & 1) << (l - i - 1);\n x >>= 1;\n }\n\n return rb;\n };\n\n // Performs \"tweedling\" phase, therefore 'emulating'\n // behaviour of the recursive algorithm\n FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) {\n for (var i = 0; i < N; i++) {\n rtws[i] = rws[rbt[i]];\n itws[i] = iws[rbt[i]];\n }\n };\n\n FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) {\n this.permute(rbt, rws, iws, rtws, itws, N);\n\n for (var s = 1; s < N; s <<= 1) {\n var l = s << 1;\n\n var rtwdf = Math.cos(2 * Math.PI / l);\n var itwdf = Math.sin(2 * Math.PI / l);\n\n for (var p = 0; p < N; p += l) {\n var rtwdf_ = rtwdf;\n var itwdf_ = itwdf;\n\n for (var j = 0; j < s; j++) {\n var re = rtws[p + j];\n var ie = itws[p + j];\n\n var ro = rtws[p + j + s];\n var io = itws[p + j + s];\n\n var rx = rtwdf_ * ro - itwdf_ * io;\n\n io = rtwdf_ * io + itwdf_ * ro;\n ro = rx;\n\n rtws[p + j] = re + ro;\n itws[p + j] = ie + io;\n\n rtws[p + j + s] = re - ro;\n itws[p + j + s] = ie - io;\n\n /* jshint maxdepth : false */\n if (j !== l) {\n rx = rtwdf * rtwdf_ - itwdf * itwdf_;\n\n itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_;\n rtwdf_ = rx;\n }\n }\n }\n }\n };\n\n FFTM.prototype.guessLen13b = function guessLen13b (n, m) {\n var N = Math.max(m, n) | 1;\n var odd = N & 1;\n var i = 0;\n for (N = N / 2 | 0; N; N = N >>> 1) {\n i++;\n }\n\n return 1 << i + 1 + odd;\n };\n\n FFTM.prototype.conjugate = function conjugate (rws, iws, N) {\n if (N <= 1) return;\n\n for (var i = 0; i < N / 2; i++) {\n var t = rws[i];\n\n rws[i] = rws[N - i - 1];\n rws[N - i - 1] = t;\n\n t = iws[i];\n\n iws[i] = -iws[N - i - 1];\n iws[N - i - 1] = -t;\n }\n };\n\n FFTM.prototype.normalize13b = function normalize13b (ws, N) {\n var carry = 0;\n for (var i = 0; i < N / 2; i++) {\n var w = Math.round(ws[2 * i + 1] / N) * 0x2000 +\n Math.round(ws[2 * i] / N) +\n carry;\n\n ws[i] = w & 0x3ffffff;\n\n if (w < 0x4000000) {\n carry = 0;\n } else {\n carry = w / 0x4000000 | 0;\n }\n }\n\n return ws;\n };\n\n FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) {\n var carry = 0;\n for (var i = 0; i < len; i++) {\n carry = carry + (ws[i] | 0);\n\n rws[2 * i] = carry & 0x1fff; carry = carry >>> 13;\n rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13;\n }\n\n // Pad with zeroes\n for (i = 2 * len; i < N; ++i) {\n rws[i] = 0;\n }\n\n assert(carry === 0);\n assert((carry & ~0x1fff) === 0);\n };\n\n FFTM.prototype.stub = function stub (N) {\n var ph = new Array(N);\n for (var i = 0; i < N; i++) {\n ph[i] = 0;\n }\n\n return ph;\n };\n\n FFTM.prototype.mulp = function mulp (x, y, out) {\n var N = 2 * this.guessLen13b(x.length, y.length);\n\n var rbt = this.makeRBT(N);\n\n var _ = this.stub(N);\n\n var rws = new Array(N);\n var rwst = new Array(N);\n var iwst = new Array(N);\n\n var nrws = new Array(N);\n var nrwst = new Array(N);\n var niwst = new Array(N);\n\n var rmws = out.words;\n rmws.length = N;\n\n this.convert13b(x.words, x.length, rws, N);\n this.convert13b(y.words, y.length, nrws, N);\n\n this.transform(rws, _, rwst, iwst, N, rbt);\n this.transform(nrws, _, nrwst, niwst, N, rbt);\n\n for (var i = 0; i < N; i++) {\n var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i];\n iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i];\n rwst[i] = rx;\n }\n\n this.conjugate(rwst, iwst, N);\n this.transform(rwst, iwst, rmws, _, N, rbt);\n this.conjugate(rmws, _, N);\n this.normalize13b(rmws, N);\n\n out.negative = x.negative ^ y.negative;\n out.length = x.length + y.length;\n return out._strip();\n };\n\n // Multiply `this` by `num`\n BN.prototype.mul = function mul (num) {\n var out = new BN(null);\n out.words = new Array(this.length + num.length);\n return this.mulTo(num, out);\n };\n\n // Multiply employing FFT\n BN.prototype.mulf = function mulf (num) {\n var out = new BN(null);\n out.words = new Array(this.length + num.length);\n return jumboMulTo(this, num, out);\n };\n\n // In-place Multiplication\n BN.prototype.imul = function imul (num) {\n return this.clone().mulTo(num, this);\n };\n\n BN.prototype.imuln = function imuln (num) {\n var isNegNum = num < 0;\n if (isNegNum) num = -num;\n\n assert(typeof num === 'number');\n assert(num < 0x4000000);\n\n // Carry\n var carry = 0;\n for (var i = 0; i < this.length; i++) {\n var w = (this.words[i] | 0) * num;\n var lo = (w & 0x3ffffff) + (carry & 0x3ffffff);\n carry >>= 26;\n carry += (w / 0x4000000) | 0;\n // NOTE: lo is 27bit maximum\n carry += lo >>> 26;\n this.words[i] = lo & 0x3ffffff;\n }\n\n if (carry !== 0) {\n this.words[i] = carry;\n this.length++;\n }\n\n return isNegNum ? this.ineg() : this;\n };\n\n BN.prototype.muln = function muln (num) {\n return this.clone().imuln(num);\n };\n\n // `this` * `this`\n BN.prototype.sqr = function sqr () {\n return this.mul(this);\n };\n\n // `this` * `this` in-place\n BN.prototype.isqr = function isqr () {\n return this.imul(this.clone());\n };\n\n // Math.pow(`this`, `num`)\n BN.prototype.pow = function pow (num) {\n var w = toBitArray(num);\n if (w.length === 0) return new BN(1);\n\n // Skip leading zeroes\n var res = this;\n for (var i = 0; i < w.length; i++, res = res.sqr()) {\n if (w[i] !== 0) break;\n }\n\n if (++i < w.length) {\n for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) {\n if (w[i] === 0) continue;\n\n res = res.mul(q);\n }\n }\n\n return res;\n };\n\n // Shift-left in-place\n BN.prototype.iushln = function iushln (bits) {\n assert(typeof bits === 'number' && bits >= 0);\n var r = bits % 26;\n var s = (bits - r) / 26;\n var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r);\n var i;\n\n if (r !== 0) {\n var carry = 0;\n\n for (i = 0; i < this.length; i++) {\n var newCarry = this.words[i] & carryMask;\n var c = ((this.words[i] | 0) - newCarry) << r;\n this.words[i] = c | carry;\n carry = newCarry >>> (26 - r);\n }\n\n if (carry) {\n this.words[i] = carry;\n this.length++;\n }\n }\n\n if (s !== 0) {\n for (i = this.length - 1; i >= 0; i--) {\n this.words[i + s] = this.words[i];\n }\n\n for (i = 0; i < s; i++) {\n this.words[i] = 0;\n }\n\n this.length += s;\n }\n\n return this._strip();\n };\n\n BN.prototype.ishln = function ishln (bits) {\n // TODO(indutny): implement me\n assert(this.negative === 0);\n return this.iushln(bits);\n };\n\n // Shift-right in-place\n // NOTE: `hint` is a lowest bit before trailing zeroes\n // NOTE: if `extended` is present - it will be filled with destroyed bits\n BN.prototype.iushrn = function iushrn (bits, hint, extended) {\n assert(typeof bits === 'number' && bits >= 0);\n var h;\n if (hint) {\n h = (hint - (hint % 26)) / 26;\n } else {\n h = 0;\n }\n\n var r = bits % 26;\n var s = Math.min((bits - r) / 26, this.length);\n var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);\n var maskedWords = extended;\n\n h -= s;\n h = Math.max(0, h);\n\n // Extended mode, copy masked part\n if (maskedWords) {\n for (var i = 0; i < s; i++) {\n maskedWords.words[i] = this.words[i];\n }\n maskedWords.length = s;\n }\n\n if (s === 0) {\n // No-op, we should not move anything at all\n } else if (this.length > s) {\n this.length -= s;\n for (i = 0; i < this.length; i++) {\n this.words[i] = this.words[i + s];\n }\n } else {\n this.words[0] = 0;\n this.length = 1;\n }\n\n var carry = 0;\n for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) {\n var word = this.words[i] | 0;\n this.words[i] = (carry << (26 - r)) | (word >>> r);\n carry = word & mask;\n }\n\n // Push carried bits as a mask\n if (maskedWords && carry !== 0) {\n maskedWords.words[maskedWords.length++] = carry;\n }\n\n if (this.length === 0) {\n this.words[0] = 0;\n this.length = 1;\n }\n\n return this._strip();\n };\n\n BN.prototype.ishrn = function ishrn (bits, hint, extended) {\n // TODO(indutny): implement me\n assert(this.negative === 0);\n return this.iushrn(bits, hint, extended);\n };\n\n // Shift-left\n BN.prototype.shln = function shln (bits) {\n return this.clone().ishln(bits);\n };\n\n BN.prototype.ushln = function ushln (bits) {\n return this.clone().iushln(bits);\n };\n\n // Shift-right\n BN.prototype.shrn = function shrn (bits) {\n return this.clone().ishrn(bits);\n };\n\n BN.prototype.ushrn = function ushrn (bits) {\n return this.clone().iushrn(bits);\n };\n\n // Test if n bit is set\n BN.prototype.testn = function testn (bit) {\n assert(typeof bit === 'number' && bit >= 0);\n var r = bit % 26;\n var s = (bit - r) / 26;\n var q = 1 << r;\n\n // Fast case: bit is much higher than all existing words\n if (this.length <= s) return false;\n\n // Check bit and return\n var w = this.words[s];\n\n return !!(w & q);\n };\n\n // Return only lowers bits of number (in-place)\n BN.prototype.imaskn = function imaskn (bits) {\n assert(typeof bits === 'number' && bits >= 0);\n var r = bits % 26;\n var s = (bits - r) / 26;\n\n assert(this.negative === 0, 'imaskn works only with positive numbers');\n\n if (this.length <= s) {\n return this;\n }\n\n if (r !== 0) {\n s++;\n }\n this.length = Math.min(s, this.length);\n\n if (r !== 0) {\n var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r);\n this.words[this.length - 1] &= mask;\n }\n\n return this._strip();\n };\n\n // Return only lowers bits of number\n BN.prototype.maskn = function maskn (bits) {\n return this.clone().imaskn(bits);\n };\n\n // Add plain number `num` to `this`\n BN.prototype.iaddn = function iaddn (num) {\n assert(typeof num === 'number');\n assert(num < 0x4000000);\n if (num < 0) return this.isubn(-num);\n\n // Possible sign change\n if (this.negative !== 0) {\n if (this.length === 1 && (this.words[0] | 0) <= num) {\n this.words[0] = num - (this.words[0] | 0);\n this.negative = 0;\n return this;\n }\n\n this.negative = 0;\n this.isubn(num);\n this.negative = 1;\n return this;\n }\n\n // Add without checks\n return this._iaddn(num);\n };\n\n BN.prototype._iaddn = function _iaddn (num) {\n this.words[0] += num;\n\n // Carry\n for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) {\n this.words[i] -= 0x4000000;\n if (i === this.length - 1) {\n this.words[i + 1] = 1;\n } else {\n this.words[i + 1]++;\n }\n }\n this.length = Math.max(this.length, i + 1);\n\n return this;\n };\n\n // Subtract plain number `num` from `this`\n BN.prototype.isubn = function isubn (num) {\n assert(typeof num === 'number');\n assert(num < 0x4000000);\n if (num < 0) return this.iaddn(-num);\n\n if (this.negative !== 0) {\n this.negative = 0;\n this.iaddn(num);\n this.negative = 1;\n return this;\n }\n\n this.words[0] -= num;\n\n if (this.length === 1 && this.words[0] < 0) {\n this.words[0] = -this.words[0];\n this.negative = 1;\n } else {\n // Carry\n for (var i = 0; i < this.length && this.words[i] < 0; i++) {\n this.words[i] += 0x4000000;\n this.words[i + 1] -= 1;\n }\n }\n\n return this._strip();\n };\n\n BN.prototype.addn = function addn (num) {\n return this.clone().iaddn(num);\n };\n\n BN.prototype.subn = function subn (num) {\n return this.clone().isubn(num);\n };\n\n BN.prototype.iabs = function iabs () {\n this.negative = 0;\n\n return this;\n };\n\n BN.prototype.abs = function abs () {\n return this.clone().iabs();\n };\n\n BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) {\n var len = num.length + shift;\n var i;\n\n this._expand(len);\n\n var w;\n var carry = 0;\n for (i = 0; i < num.length; i++) {\n w = (this.words[i + shift] | 0) + carry;\n var right = (num.words[i] | 0) * mul;\n w -= right & 0x3ffffff;\n carry = (w >> 26) - ((right / 0x4000000) | 0);\n this.words[i + shift] = w & 0x3ffffff;\n }\n for (; i < this.length - shift; i++) {\n w = (this.words[i + shift] | 0) + carry;\n carry = w >> 26;\n this.words[i + shift] = w & 0x3ffffff;\n }\n\n if (carry === 0) return this._strip();\n\n // Subtraction overflow\n assert(carry === -1);\n carry = 0;\n for (i = 0; i < this.length; i++) {\n w = -(this.words[i] | 0) + carry;\n carry = w >> 26;\n this.words[i] = w & 0x3ffffff;\n }\n this.negative = 1;\n\n return this._strip();\n };\n\n BN.prototype._wordDiv = function _wordDiv (num, mode) {\n var shift = this.length - num.length;\n\n var a = this.clone();\n var b = num;\n\n // Normalize\n var bhi = b.words[b.length - 1] | 0;\n var bhiBits = this._countBits(bhi);\n shift = 26 - bhiBits;\n if (shift !== 0) {\n b = b.ushln(shift);\n a.iushln(shift);\n bhi = b.words[b.length - 1] | 0;\n }\n\n // Initialize quotient\n var m = a.length - b.length;\n var q;\n\n if (mode !== 'mod') {\n q = new BN(null);\n q.length = m + 1;\n q.words = new Array(q.length);\n for (var i = 0; i < q.length; i++) {\n q.words[i] = 0;\n }\n }\n\n var diff = a.clone()._ishlnsubmul(b, 1, m);\n if (diff.negative === 0) {\n a = diff;\n if (q) {\n q.words[m] = 1;\n }\n }\n\n for (var j = m - 1; j >= 0; j--) {\n var qj = (a.words[b.length + j] | 0) * 0x4000000 +\n (a.words[b.length + j - 1] | 0);\n\n // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max\n // (0x7ffffff)\n qj = Math.min((qj / bhi) | 0, 0x3ffffff);\n\n a._ishlnsubmul(b, qj, j);\n while (a.negative !== 0) {\n qj--;\n a.negative = 0;\n a._ishlnsubmul(b, 1, j);\n if (!a.isZero()) {\n a.negative ^= 1;\n }\n }\n if (q) {\n q.words[j] = qj;\n }\n }\n if (q) {\n q._strip();\n }\n a._strip();\n\n // Denormalize\n if (mode !== 'div' && shift !== 0) {\n a.iushrn(shift);\n }\n\n return {\n div: q || null,\n mod: a\n };\n };\n\n // NOTE: 1) `mode` can be set to `mod` to request mod only,\n // to `div` to request div only, or be absent to\n // request both div & mod\n // 2) `positive` is true if unsigned mod is requested\n BN.prototype.divmod = function divmod (num, mode, positive) {\n assert(!num.isZero());\n\n if (this.isZero()) {\n return {\n div: new BN(0),\n mod: new BN(0)\n };\n }\n\n var div, mod, res;\n if (this.negative !== 0 && num.negative === 0) {\n res = this.neg().divmod(num, mode);\n\n if (mode !== 'mod') {\n div = res.div.neg();\n }\n\n if (mode !== 'div') {\n mod = res.mod.neg();\n if (positive && mod.negative !== 0) {\n mod.iadd(num);\n }\n }\n\n return {\n div: div,\n mod: mod\n };\n }\n\n if (this.negative === 0 && num.negative !== 0) {\n res = this.divmod(num.neg(), mode);\n\n if (mode !== 'mod') {\n div = res.div.neg();\n }\n\n return {\n div: div,\n mod: res.mod\n };\n }\n\n if ((this.negative & num.negative) !== 0) {\n res = this.neg().divmod(num.neg(), mode);\n\n if (mode !== 'div') {\n mod = res.mod.neg();\n if (positive && mod.negative !== 0) {\n mod.isub(num);\n }\n }\n\n return {\n div: res.div,\n mod: mod\n };\n }\n\n // Both numbers are positive at this point\n\n // Strip both numbers to approximate shift value\n if (num.length > this.length || this.cmp(num) < 0) {\n return {\n div: new BN(0),\n mod: this\n };\n }\n\n // Very short reduction\n if (num.length === 1) {\n if (mode === 'div') {\n return {\n div: this.divn(num.words[0]),\n mod: null\n };\n }\n\n if (mode === 'mod') {\n return {\n div: null,\n mod: new BN(this.modrn(num.words[0]))\n };\n }\n\n return {\n div: this.divn(num.words[0]),\n mod: new BN(this.modrn(num.words[0]))\n };\n }\n\n return this._wordDiv(num, mode);\n };\n\n // Find `this` / `num`\n BN.prototype.div = function div (num) {\n return this.divmod(num, 'div', false).div;\n };\n\n // Find `this` % `num`\n BN.prototype.mod = function mod (num) {\n return this.divmod(num, 'mod', false).mod;\n };\n\n BN.prototype.umod = function umod (num) {\n return this.divmod(num, 'mod', true).mod;\n };\n\n // Find Round(`this` / `num`)\n BN.prototype.divRound = function divRound (num) {\n var dm = this.divmod(num);\n\n // Fast case - exact division\n if (dm.mod.isZero()) return dm.div;\n\n var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;\n\n var half = num.ushrn(1);\n var r2 = num.andln(1);\n var cmp = mod.cmp(half);\n\n // Round down\n if (cmp < 0 || (r2 === 1 && cmp === 0)) return dm.div;\n\n // Round up\n return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);\n };\n\n BN.prototype.modrn = function modrn (num) {\n var isNegNum = num < 0;\n if (isNegNum) num = -num;\n\n assert(num <= 0x3ffffff);\n var p = (1 << 26) % num;\n\n var acc = 0;\n for (var i = this.length - 1; i >= 0; i--) {\n acc = (p * acc + (this.words[i] | 0)) % num;\n }\n\n return isNegNum ? -acc : acc;\n };\n\n // WARNING: DEPRECATED\n BN.prototype.modn = function modn (num) {\n return this.modrn(num);\n };\n\n // In-place division by number\n BN.prototype.idivn = function idivn (num) {\n var isNegNum = num < 0;\n if (isNegNum) num = -num;\n\n assert(num <= 0x3ffffff);\n\n var carry = 0;\n for (var i = this.length - 1; i >= 0; i--) {\n var w = (this.words[i] | 0) + carry * 0x4000000;\n this.words[i] = (w / num) | 0;\n carry = w % num;\n }\n\n this._strip();\n return isNegNum ? this.ineg() : this;\n };\n\n BN.prototype.divn = function divn (num) {\n return this.clone().idivn(num);\n };\n\n BN.prototype.egcd = function egcd (p) {\n assert(p.negative === 0);\n assert(!p.isZero());\n\n var x = this;\n var y = p.clone();\n\n if (x.negative !== 0) {\n x = x.umod(p);\n } else {\n x = x.clone();\n }\n\n // A * x + B * y = x\n var A = new BN(1);\n var B = new BN(0);\n\n // C * x + D * y = y\n var C = new BN(0);\n var D = new BN(1);\n\n var g = 0;\n\n while (x.isEven() && y.isEven()) {\n x.iushrn(1);\n y.iushrn(1);\n ++g;\n }\n\n var yp = y.clone();\n var xp = x.clone();\n\n while (!x.isZero()) {\n for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1);\n if (i > 0) {\n x.iushrn(i);\n while (i-- > 0) {\n if (A.isOdd() || B.isOdd()) {\n A.iadd(yp);\n B.isub(xp);\n }\n\n A.iushrn(1);\n B.iushrn(1);\n }\n }\n\n for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);\n if (j > 0) {\n y.iushrn(j);\n while (j-- > 0) {\n if (C.isOdd() || D.isOdd()) {\n C.iadd(yp);\n D.isub(xp);\n }\n\n C.iushrn(1);\n D.iushrn(1);\n }\n }\n\n if (x.cmp(y) >= 0) {\n x.isub(y);\n A.isub(C);\n B.isub(D);\n } else {\n y.isub(x);\n C.isub(A);\n D.isub(B);\n }\n }\n\n return {\n a: C,\n b: D,\n gcd: y.iushln(g)\n };\n };\n\n // This is reduced incarnation of the binary EEA\n // above, designated to invert members of the\n // _prime_ fields F(p) at a maximal speed\n BN.prototype._invmp = function _invmp (p) {\n assert(p.negative === 0);\n assert(!p.isZero());\n\n var a = this;\n var b = p.clone();\n\n if (a.negative !== 0) {\n a = a.umod(p);\n } else {\n a = a.clone();\n }\n\n var x1 = new BN(1);\n var x2 = new BN(0);\n\n var delta = b.clone();\n\n while (a.cmpn(1) > 0 && b.cmpn(1) > 0) {\n for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1);\n if (i > 0) {\n a.iushrn(i);\n while (i-- > 0) {\n if (x1.isOdd()) {\n x1.iadd(delta);\n }\n\n x1.iushrn(1);\n }\n }\n\n for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1);\n if (j > 0) {\n b.iushrn(j);\n while (j-- > 0) {\n if (x2.isOdd()) {\n x2.iadd(delta);\n }\n\n x2.iushrn(1);\n }\n }\n\n if (a.cmp(b) >= 0) {\n a.isub(b);\n x1.isub(x2);\n } else {\n b.isub(a);\n x2.isub(x1);\n }\n }\n\n var res;\n if (a.cmpn(1) === 0) {\n res = x1;\n } else {\n res = x2;\n }\n\n if (res.cmpn(0) < 0) {\n res.iadd(p);\n }\n\n return res;\n };\n\n BN.prototype.gcd = function gcd (num) {\n if (this.isZero()) return num.abs();\n if (num.isZero()) return this.abs();\n\n var a = this.clone();\n var b = num.clone();\n a.negative = 0;\n b.negative = 0;\n\n // Remove common factor of two\n for (var shift = 0; a.isEven() && b.isEven(); shift++) {\n a.iushrn(1);\n b.iushrn(1);\n }\n\n do {\n while (a.isEven()) {\n a.iushrn(1);\n }\n while (b.isEven()) {\n b.iushrn(1);\n }\n\n var r = a.cmp(b);\n if (r < 0) {\n // Swap `a` and `b` to make `a` always bigger than `b`\n var t = a;\n a = b;\n b = t;\n } else if (r === 0 || b.cmpn(1) === 0) {\n break;\n }\n\n a.isub(b);\n } while (true);\n\n return b.iushln(shift);\n };\n\n // Invert number in the field F(num)\n BN.prototype.invm = function invm (num) {\n return this.egcd(num).a.umod(num);\n };\n\n BN.prototype.isEven = function isEven () {\n return (this.words[0] & 1) === 0;\n };\n\n BN.prototype.isOdd = function isOdd () {\n return (this.words[0] & 1) === 1;\n };\n\n // And first word and num\n BN.prototype.andln = function andln (num) {\n return this.words[0] & num;\n };\n\n // Increment at the bit position in-line\n BN.prototype.bincn = function bincn (bit) {\n assert(typeof bit === 'number');\n var r = bit % 26;\n var s = (bit - r) / 26;\n var q = 1 << r;\n\n // Fast case: bit is much higher than all existing words\n if (this.length <= s) {\n this._expand(s + 1);\n this.words[s] |= q;\n return this;\n }\n\n // Add bit and propagate, if needed\n var carry = q;\n for (var i = s; carry !== 0 && i < this.length; i++) {\n var w = this.words[i] | 0;\n w += carry;\n carry = w >>> 26;\n w &= 0x3ffffff;\n this.words[i] = w;\n }\n if (carry !== 0) {\n this.words[i] = carry;\n this.length++;\n }\n return this;\n };\n\n BN.prototype.isZero = function isZero () {\n return this.length === 1 && this.words[0] === 0;\n };\n\n BN.prototype.cmpn = function cmpn (num) {\n var negative = num < 0;\n\n if (this.negative !== 0 && !negative) return -1;\n if (this.negative === 0 && negative) return 1;\n\n this._strip();\n\n var res;\n if (this.length > 1) {\n res = 1;\n } else {\n if (negative) {\n num = -num;\n }\n\n assert(num <= 0x3ffffff, 'Number is too big');\n\n var w = this.words[0] | 0;\n res = w === num ? 0 : w < num ? -1 : 1;\n }\n if (this.negative !== 0) return -res | 0;\n return res;\n };\n\n // Compare two numbers and return:\n // 1 - if `this` > `num`\n // 0 - if `this` == `num`\n // -1 - if `this` < `num`\n BN.prototype.cmp = function cmp (num) {\n if (this.negative !== 0 && num.negative === 0) return -1;\n if (this.negative === 0 && num.negative !== 0) return 1;\n\n var res = this.ucmp(num);\n if (this.negative !== 0) return -res | 0;\n return res;\n };\n\n // Unsigned comparison\n BN.prototype.ucmp = function ucmp (num) {\n // At this point both numbers have the same sign\n if (this.length > num.length) return 1;\n if (this.length < num.length) return -1;\n\n var res = 0;\n for (var i = this.length - 1; i >= 0; i--) {\n var a = this.words[i] | 0;\n var b = num.words[i] | 0;\n\n if (a === b) continue;\n if (a < b) {\n res = -1;\n } else if (a > b) {\n res = 1;\n }\n break;\n }\n return res;\n };\n\n BN.prototype.gtn = function gtn (num) {\n return this.cmpn(num) === 1;\n };\n\n BN.prototype.gt = function gt (num) {\n return this.cmp(num) === 1;\n };\n\n BN.prototype.gten = function gten (num) {\n return this.cmpn(num) >= 0;\n };\n\n BN.prototype.gte = function gte (num) {\n return this.cmp(num) >= 0;\n };\n\n BN.prototype.ltn = function ltn (num) {\n return this.cmpn(num) === -1;\n };\n\n BN.prototype.lt = function lt (num) {\n return this.cmp(num) === -1;\n };\n\n BN.prototype.lten = function lten (num) {\n return this.cmpn(num) <= 0;\n };\n\n BN.prototype.lte = function lte (num) {\n return this.cmp(num) <= 0;\n };\n\n BN.prototype.eqn = function eqn (num) {\n return this.cmpn(num) === 0;\n };\n\n BN.prototype.eq = function eq (num) {\n return this.cmp(num) === 0;\n };\n\n //\n // A reduce context, could be using montgomery or something better, depending\n // on the `m` itself.\n //\n BN.red = function red (num) {\n return new Red(num);\n };\n\n BN.prototype.toRed = function toRed (ctx) {\n assert(!this.red, 'Already a number in reduction context');\n assert(this.negative === 0, 'red works only with positives');\n return ctx.convertTo(this)._forceRed(ctx);\n };\n\n BN.prototype.fromRed = function fromRed () {\n assert(this.red, 'fromRed works only with numbers in reduction context');\n return this.red.convertFrom(this);\n };\n\n BN.prototype._forceRed = function _forceRed (ctx) {\n this.red = ctx;\n return this;\n };\n\n BN.prototype.forceRed = function forceRed (ctx) {\n assert(!this.red, 'Already a number in reduction context');\n return this._forceRed(ctx);\n };\n\n BN.prototype.redAdd = function redAdd (num) {\n assert(this.red, 'redAdd works only with red numbers');\n return this.red.add(this, num);\n };\n\n BN.prototype.redIAdd = function redIAdd (num) {\n assert(this.red, 'redIAdd works only with red numbers');\n return this.red.iadd(this, num);\n };\n\n BN.prototype.redSub = function redSub (num) {\n assert(this.red, 'redSub works only with red numbers');\n return this.red.sub(this, num);\n };\n\n BN.prototype.redISub = function redISub (num) {\n assert(this.red, 'redISub works only with red numbers');\n return this.red.isub(this, num);\n };\n\n BN.prototype.redShl = function redShl (num) {\n assert(this.red, 'redShl works only with red numbers');\n return this.red.shl(this, num);\n };\n\n BN.prototype.redMul = function redMul (num) {\n assert(this.red, 'redMul works only with red numbers');\n this.red._verify2(this, num);\n return this.red.mul(this, num);\n };\n\n BN.prototype.redIMul = function redIMul (num) {\n assert(this.red, 'redMul works only with red numbers');\n this.red._verify2(this, num);\n return this.red.imul(this, num);\n };\n\n BN.prototype.redSqr = function redSqr () {\n assert(this.red, 'redSqr works only with red numbers');\n this.red._verify1(this);\n return this.red.sqr(this);\n };\n\n BN.prototype.redISqr = function redISqr () {\n assert(this.red, 'redISqr works only with red numbers');\n this.red._verify1(this);\n return this.red.isqr(this);\n };\n\n // Square root over p\n BN.prototype.redSqrt = function redSqrt () {\n assert(this.red, 'redSqrt works only with red numbers');\n this.red._verify1(this);\n return this.red.sqrt(this);\n };\n\n BN.prototype.redInvm = function redInvm () {\n assert(this.red, 'redInvm works only with red numbers');\n this.red._verify1(this);\n return this.red.invm(this);\n };\n\n // Return negative clone of `this` % `red modulo`\n BN.prototype.redNeg = function redNeg () {\n assert(this.red, 'redNeg works only with red numbers');\n this.red._verify1(this);\n return this.red.neg(this);\n };\n\n BN.prototype.redPow = function redPow (num) {\n assert(this.red && !num.red, 'redPow(normalNum)');\n this.red._verify1(this);\n return this.red.pow(this, num);\n };\n\n // Prime numbers with efficient reduction\n var primes = {\n k256: null,\n p224: null,\n p192: null,\n p25519: null\n };\n\n // Pseudo-Mersenne prime\n function MPrime (name, p) {\n // P = 2 ^ N - K\n this.name = name;\n this.p = new BN(p, 16);\n this.n = this.p.bitLength();\n this.k = new BN(1).iushln(this.n).isub(this.p);\n\n this.tmp = this._tmp();\n }\n\n MPrime.prototype._tmp = function _tmp () {\n var tmp = new BN(null);\n tmp.words = new Array(Math.ceil(this.n / 13));\n return tmp;\n };\n\n MPrime.prototype.ireduce = function ireduce (num) {\n // Assumes that `num` is less than `P^2`\n // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)\n var r = num;\n var rlen;\n\n do {\n this.split(r, this.tmp);\n r = this.imulK(r);\n r = r.iadd(this.tmp);\n rlen = r.bitLength();\n } while (rlen > this.n);\n\n var cmp = rlen < this.n ? -1 : r.ucmp(this.p);\n if (cmp === 0) {\n r.words[0] = 0;\n r.length = 1;\n } else if (cmp > 0) {\n r.isub(this.p);\n } else {\n if (r.strip !== undefined) {\n // r is a BN v4 instance\n r.strip();\n } else {\n // r is a BN v5 instance\n r._strip();\n }\n }\n\n return r;\n };\n\n MPrime.prototype.split = function split (input, out) {\n input.iushrn(this.n, 0, out);\n };\n\n MPrime.prototype.imulK = function imulK (num) {\n return num.imul(this.k);\n };\n\n function K256 () {\n MPrime.call(\n this,\n 'k256',\n 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');\n }\n inherits(K256, MPrime);\n\n K256.prototype.split = function split (input, output) {\n // 256 = 9 * 26 + 22\n var mask = 0x3fffff;\n\n var outLen = Math.min(input.length, 9);\n for (var i = 0; i < outLen; i++) {\n output.words[i] = input.words[i];\n }\n output.length = outLen;\n\n if (input.length <= 9) {\n input.words[0] = 0;\n input.length = 1;\n return;\n }\n\n // Shift by 9 limbs\n var prev = input.words[9];\n output.words[output.length++] = prev & mask;\n\n for (i = 10; i < input.length; i++) {\n var next = input.words[i] | 0;\n input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22);\n prev = next;\n }\n prev >>>= 22;\n input.words[i - 10] = prev;\n if (prev === 0 && input.length > 10) {\n input.length -= 10;\n } else {\n input.length -= 9;\n }\n };\n\n K256.prototype.imulK = function imulK (num) {\n // K = 0x1000003d1 = [ 0x40, 0x3d1 ]\n num.words[num.length] = 0;\n num.words[num.length + 1] = 0;\n num.length += 2;\n\n // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390\n var lo = 0;\n for (var i = 0; i < num.length; i++) {\n var w = num.words[i] | 0;\n lo += w * 0x3d1;\n num.words[i] = lo & 0x3ffffff;\n lo = w * 0x40 + ((lo / 0x4000000) | 0);\n }\n\n // Fast length reduction\n if (num.words[num.length - 1] === 0) {\n num.length--;\n if (num.words[num.length - 1] === 0) {\n num.length--;\n }\n }\n return num;\n };\n\n function P224 () {\n MPrime.call(\n this,\n 'p224',\n 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001');\n }\n inherits(P224, MPrime);\n\n function P192 () {\n MPrime.call(\n this,\n 'p192',\n 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff');\n }\n inherits(P192, MPrime);\n\n function P25519 () {\n // 2 ^ 255 - 19\n MPrime.call(\n this,\n '25519',\n '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed');\n }\n inherits(P25519, MPrime);\n\n P25519.prototype.imulK = function imulK (num) {\n // K = 0x13\n var carry = 0;\n for (var i = 0; i < num.length; i++) {\n var hi = (num.words[i] | 0) * 0x13 + carry;\n var lo = hi & 0x3ffffff;\n hi >>>= 26;\n\n num.words[i] = lo;\n carry = hi;\n }\n if (carry !== 0) {\n num.words[num.length++] = carry;\n }\n return num;\n };\n\n // Exported mostly for testing purposes, use plain name instead\n BN._prime = function prime (name) {\n // Cached version of prime\n if (primes[name]) return primes[name];\n\n var prime;\n if (name === 'k256') {\n prime = new K256();\n } else if (name === 'p224') {\n prime = new P224();\n } else if (name === 'p192') {\n prime = new P192();\n } else if (name === 'p25519') {\n prime = new P25519();\n } else {\n throw new Error('Unknown prime ' + name);\n }\n primes[name] = prime;\n\n return prime;\n };\n\n //\n // Base reduction engine\n //\n function Red (m) {\n if (typeof m === 'string') {\n var prime = BN._prime(m);\n this.m = prime.p;\n this.prime = prime;\n } else {\n assert(m.gtn(1), 'modulus must be greater than 1');\n this.m = m;\n this.prime = null;\n }\n }\n\n Red.prototype._verify1 = function _verify1 (a) {\n assert(a.negative === 0, 'red works only with positives');\n assert(a.red, 'red works only with red numbers');\n };\n\n Red.prototype._verify2 = function _verify2 (a, b) {\n assert((a.negative | b.negative) === 0, 'red works only with positives');\n assert(a.red && a.red === b.red,\n 'red works only with red numbers');\n };\n\n Red.prototype.imod = function imod (a) {\n if (this.prime) return this.prime.ireduce(a)._forceRed(this);\n\n move(a, a.umod(this.m)._forceRed(this));\n return a;\n };\n\n Red.prototype.neg = function neg (a) {\n if (a.isZero()) {\n return a.clone();\n }\n\n return this.m.sub(a)._forceRed(this);\n };\n\n Red.prototype.add = function add (a, b) {\n this._verify2(a, b);\n\n var res = a.add(b);\n if (res.cmp(this.m) >= 0) {\n res.isub(this.m);\n }\n return res._forceRed(this);\n };\n\n Red.prototype.iadd = function iadd (a, b) {\n this._verify2(a, b);\n\n var res = a.iadd(b);\n if (res.cmp(this.m) >= 0) {\n res.isub(this.m);\n }\n return res;\n };\n\n Red.prototype.sub = function sub (a, b) {\n this._verify2(a, b);\n\n var res = a.sub(b);\n if (res.cmpn(0) < 0) {\n res.iadd(this.m);\n }\n return res._forceRed(this);\n };\n\n Red.prototype.isub = function isub (a, b) {\n this._verify2(a, b);\n\n var res = a.isub(b);\n if (res.cmpn(0) < 0) {\n res.iadd(this.m);\n }\n return res;\n };\n\n Red.prototype.shl = function shl (a, num) {\n this._verify1(a);\n return this.imod(a.ushln(num));\n };\n\n Red.prototype.imul = function imul (a, b) {\n this._verify2(a, b);\n return this.imod(a.imul(b));\n };\n\n Red.prototype.mul = function mul (a, b) {\n this._verify2(a, b);\n return this.imod(a.mul(b));\n };\n\n Red.prototype.isqr = function isqr (a) {\n return this.imul(a, a.clone());\n };\n\n Red.prototype.sqr = function sqr (a) {\n return this.mul(a, a);\n };\n\n Red.prototype.sqrt = function sqrt (a) {\n if (a.isZero()) return a.clone();\n\n var mod3 = this.m.andln(3);\n assert(mod3 % 2 === 1);\n\n // Fast case\n if (mod3 === 3) {\n var pow = this.m.add(new BN(1)).iushrn(2);\n return this.pow(a, pow);\n }\n\n // Tonelli-Shanks algorithm (Totally unoptimized and slow)\n //\n // Find Q and S, that Q * 2 ^ S = (P - 1)\n var q = this.m.subn(1);\n var s = 0;\n while (!q.isZero() && q.andln(1) === 0) {\n s++;\n q.iushrn(1);\n }\n assert(!q.isZero());\n\n var one = new BN(1).toRed(this);\n var nOne = one.redNeg();\n\n // Find quadratic non-residue\n // NOTE: Max is such because of generalized Riemann hypothesis.\n var lpow = this.m.subn(1).iushrn(1);\n var z = this.m.bitLength();\n z = new BN(2 * z * z).toRed(this);\n\n while (this.pow(z, lpow).cmp(nOne) !== 0) {\n z.redIAdd(nOne);\n }\n\n var c = this.pow(z, q);\n var r = this.pow(a, q.addn(1).iushrn(1));\n var t = this.pow(a, q);\n var m = s;\n while (t.cmp(one) !== 0) {\n var tmp = t;\n for (var i = 0; tmp.cmp(one) !== 0; i++) {\n tmp = tmp.redSqr();\n }\n assert(i < m);\n var b = this.pow(c, new BN(1).iushln(m - i - 1));\n\n r = r.redMul(b);\n c = b.redSqr();\n t = t.redMul(c);\n m = i;\n }\n\n return r;\n };\n\n Red.prototype.invm = function invm (a) {\n var inv = a._invmp(this.m);\n if (inv.negative !== 0) {\n inv.negative = 0;\n return this.imod(inv).redNeg();\n } else {\n return this.imod(inv);\n }\n };\n\n Red.prototype.pow = function pow (a, num) {\n if (num.isZero()) return new BN(1).toRed(this);\n if (num.cmpn(1) === 0) return a.clone();\n\n var windowSize = 4;\n var wnd = new Array(1 << windowSize);\n wnd[0] = new BN(1).toRed(this);\n wnd[1] = a;\n for (var i = 2; i < wnd.length; i++) {\n wnd[i] = this.mul(wnd[i - 1], a);\n }\n\n var res = wnd[0];\n var current = 0;\n var currentLen = 0;\n var start = num.bitLength() % 26;\n if (start === 0) {\n start = 26;\n }\n\n for (i = num.length - 1; i >= 0; i--) {\n var word = num.words[i];\n for (var j = start - 1; j >= 0; j--) {\n var bit = (word >> j) & 1;\n if (res !== wnd[0]) {\n res = this.sqr(res);\n }\n\n if (bit === 0 && current === 0) {\n currentLen = 0;\n continue;\n }\n\n current <<= 1;\n current |= bit;\n currentLen++;\n if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue;\n\n res = this.mul(res, wnd[current]);\n currentLen = 0;\n current = 0;\n }\n start = 26;\n }\n\n return res;\n };\n\n Red.prototype.convertTo = function convertTo (num) {\n var r = num.umod(this.m);\n\n return r === num ? r.clone() : r;\n };\n\n Red.prototype.convertFrom = function convertFrom (num) {\n var res = num.clone();\n res.red = null;\n return res;\n };\n\n //\n // Montgomery method engine\n //\n\n BN.mont = function mont (num) {\n return new Mont(num);\n };\n\n function Mont (m) {\n Red.call(this, m);\n\n this.shift = this.m.bitLength();\n if (this.shift % 26 !== 0) {\n this.shift += 26 - (this.shift % 26);\n }\n\n this.r = new BN(1).iushln(this.shift);\n this.r2 = this.imod(this.r.sqr());\n this.rinv = this.r._invmp(this.m);\n\n this.minv = this.rinv.mul(this.r).isubn(1).div(this.m);\n this.minv = this.minv.umod(this.r);\n this.minv = this.r.sub(this.minv);\n }\n inherits(Mont, Red);\n\n Mont.prototype.convertTo = function convertTo (num) {\n return this.imod(num.ushln(this.shift));\n };\n\n Mont.prototype.convertFrom = function convertFrom (num) {\n var r = this.imod(num.mul(this.rinv));\n r.red = null;\n return r;\n };\n\n Mont.prototype.imul = function imul (a, b) {\n if (a.isZero() || b.isZero()) {\n a.words[0] = 0;\n a.length = 1;\n return a;\n }\n\n var t = a.imul(b);\n var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);\n var u = t.isub(c).iushrn(this.shift);\n var res = u;\n\n if (u.cmp(this.m) >= 0) {\n res = u.isub(this.m);\n } else if (u.cmpn(0) < 0) {\n res = u.iadd(this.m);\n }\n\n return res._forceRed(this);\n };\n\n Mont.prototype.mul = function mul (a, b) {\n if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this);\n\n var t = a.mul(b);\n var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);\n var u = t.isub(c).iushrn(this.shift);\n var res = u;\n if (u.cmp(this.m) >= 0) {\n res = u.isub(this.m);\n } else if (u.cmpn(0) < 0) {\n res = u.iadd(this.m);\n }\n\n return res._forceRed(this);\n };\n\n Mont.prototype.invm = function invm (a) {\n // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R\n var res = this.imod(a._invmp(this.m).mul(this.r2));\n return res._forceRed(this);\n };\n})(typeof module === 'undefined' || module, this);\n","\"use strict\";","var basex = require('base-x')\nvar ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'\n\nmodule.exports = basex(ALPHABET)\n","'use strict'\n// base-x encoding / decoding\n// Copyright (c) 2018 base-x contributors\n// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)\n// Distributed under the MIT software license, see the accompanying\n// file LICENSE or http://www.opensource.org/licenses/mit-license.php.\n// @ts-ignore\nvar _Buffer = require('safe-buffer').Buffer\nfunction base (ALPHABET) {\n if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') }\n var BASE_MAP = new Uint8Array(256)\n for (var j = 0; j < BASE_MAP.length; j++) {\n BASE_MAP[j] = 255\n }\n for (var i = 0; i < ALPHABET.length; i++) {\n var x = ALPHABET.charAt(i)\n var xc = x.charCodeAt(0)\n if (BASE_MAP[xc] !== 255) { throw new TypeError(x + ' is ambiguous') }\n BASE_MAP[xc] = i\n }\n var BASE = ALPHABET.length\n var LEADER = ALPHABET.charAt(0)\n var FACTOR = Math.log(BASE) / Math.log(256) // log(BASE) / log(256), rounded up\n var iFACTOR = Math.log(256) / Math.log(BASE) // log(256) / log(BASE), rounded up\n function encode (source) {\n if (Array.isArray(source) || source instanceof Uint8Array) { source = _Buffer.from(source) }\n if (!_Buffer.isBuffer(source)) { throw new TypeError('Expected Buffer') }\n if (source.length === 0) { return '' }\n // Skip & count leading zeroes.\n var zeroes = 0\n var length = 0\n var pbegin = 0\n var pend = source.length\n while (pbegin !== pend && source[pbegin] === 0) {\n pbegin++\n zeroes++\n }\n // Allocate enough space in big-endian base58 representation.\n var size = ((pend - pbegin) * iFACTOR + 1) >>> 0\n var b58 = new Uint8Array(size)\n // Process the bytes.\n while (pbegin !== pend) {\n var carry = source[pbegin]\n // Apply \"b58 = b58 * 256 + ch\".\n var i = 0\n for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {\n carry += (256 * b58[it1]) >>> 0\n b58[it1] = (carry % BASE) >>> 0\n carry = (carry / BASE) >>> 0\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i\n pbegin++\n }\n // Skip leading zeroes in base58 result.\n var it2 = size - length\n while (it2 !== size && b58[it2] === 0) {\n it2++\n }\n // Translate the result into a string.\n var str = LEADER.repeat(zeroes)\n for (; it2 < size; ++it2) { str += ALPHABET.charAt(b58[it2]) }\n return str\n }\n function decodeUnsafe (source) {\n if (typeof source !== 'string') { throw new TypeError('Expected String') }\n if (source.length === 0) { return _Buffer.alloc(0) }\n var psz = 0\n // Skip and count leading '1's.\n var zeroes = 0\n var length = 0\n while (source[psz] === LEADER) {\n zeroes++\n psz++\n }\n // Allocate enough space in big-endian base256 representation.\n var size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up.\n var b256 = new Uint8Array(size)\n // Process the characters.\n while (psz < source.length) {\n // Decode character\n var carry = BASE_MAP[source.charCodeAt(psz)]\n // Invalid character\n if (carry === 255) { return }\n var i = 0\n for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {\n carry += (BASE * b256[it3]) >>> 0\n b256[it3] = (carry % 256) >>> 0\n carry = (carry / 256) >>> 0\n }\n if (carry !== 0) { throw new Error('Non-zero carry') }\n length = i\n psz++\n }\n // Skip leading zeroes in b256.\n var it4 = size - length\n while (it4 !== size && b256[it4] === 0) {\n it4++\n }\n var vch = _Buffer.allocUnsafe(zeroes + (size - it4))\n vch.fill(0x00, 0, zeroes)\n var j = zeroes\n while (it4 !== size) {\n vch[j++] = b256[it4++]\n }\n return vch\n }\n function decode (string) {\n var buffer = decodeUnsafe(string)\n if (buffer) { return buffer }\n throw new Error('Non-base' + BASE + ' character')\n }\n return {\n encode: encode,\n decodeUnsafe: decodeUnsafe,\n decode: decode\n }\n}\nmodule.exports = base\n","/*! safe-buffer. MIT License. Feross Aboukhadijeh */\n/* eslint-disable node/no-deprecated-api */\nvar buffer = require('buffer')\nvar Buffer = buffer.Buffer\n\n// alternative to using Object.keys for old browsers\nfunction copyProps (src, dst) {\n for (var key in src) {\n dst[key] = src[key]\n }\n}\nif (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {\n module.exports = buffer\n} else {\n // Copy properties from require('buffer')\n copyProps(buffer, exports)\n exports.Buffer = SafeBuffer\n}\n\nfunction SafeBuffer (arg, encodingOrOffset, length) {\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.prototype = Object.create(Buffer.prototype)\n\n// Copy static methods from Buffer\ncopyProps(Buffer, SafeBuffer)\n\nSafeBuffer.from = function (arg, encodingOrOffset, length) {\n if (typeof arg === 'number') {\n throw new TypeError('Argument must not be a number')\n }\n return Buffer(arg, encodingOrOffset, length)\n}\n\nSafeBuffer.alloc = function (size, fill, encoding) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n var buf = Buffer(size)\n if (fill !== undefined) {\n if (typeof encoding === 'string') {\n buf.fill(fill, encoding)\n } else {\n buf.fill(fill)\n }\n } else {\n buf.fill(0)\n }\n return buf\n}\n\nSafeBuffer.allocUnsafe = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return Buffer(size)\n}\n\nSafeBuffer.allocUnsafeSlow = function (size) {\n if (typeof size !== 'number') {\n throw new TypeError('Argument must be a number')\n }\n return buffer.SlowBuffer(size)\n}\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.sha224 = exports.sha256 = exports.SHA256 = void 0;\n/**\n * SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3.\n *\n * To break sha256 using birthday attack, attackers need to try 2^128 hashes.\n * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.\n *\n * Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).\n * @module\n */\nconst _md_js_1 = require(\"./_md.js\");\nconst utils_js_1 = require(\"./utils.js\");\n/** Round constants: first 32 bits of fractional parts of the cube roots of the first 64 primes 2..311). */\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n/** Initial state: first 32 bits of fractional parts of the square roots of the first 8 primes 2..19. */\n// prettier-ignore\nconst SHA256_IV = /* @__PURE__ */ new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19\n]);\n/**\n * Temporary buffer, not used to store anything between runs.\n * Named this way because it matches specification.\n */\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\nclass SHA256 extends _md_js_1.HashMD {\n constructor() {\n super(64, 32, 8, false);\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n this.A = SHA256_IV[0] | 0;\n this.B = SHA256_IV[1] | 0;\n this.C = SHA256_IV[2] | 0;\n this.D = SHA256_IV[3] | 0;\n this.E = SHA256_IV[4] | 0;\n this.F = SHA256_IV[5] | 0;\n this.G = SHA256_IV[6] | 0;\n this.H = SHA256_IV[7] | 0;\n }\n get() {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n set(A, B, C, D, E, F, G, H) {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n process(view, offset) {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4)\n SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = (0, utils_js_1.rotr)(W15, 7) ^ (0, utils_js_1.rotr)(W15, 18) ^ (W15 >>> 3);\n const s1 = (0, utils_js_1.rotr)(W2, 17) ^ (0, utils_js_1.rotr)(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = (0, utils_js_1.rotr)(E, 6) ^ (0, utils_js_1.rotr)(E, 11) ^ (0, utils_js_1.rotr)(E, 25);\n const T1 = (H + sigma1 + (0, _md_js_1.Chi)(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = (0, utils_js_1.rotr)(A, 2) ^ (0, utils_js_1.rotr)(A, 13) ^ (0, utils_js_1.rotr)(A, 22);\n const T2 = (sigma0 + (0, _md_js_1.Maj)(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n roundClean() {\n SHA256_W.fill(0);\n }\n destroy() {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\nexports.SHA256 = SHA256;\n/**\n * Constants taken from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf.\n */\nclass SHA224 extends SHA256 {\n constructor() {\n super();\n this.A = 0xc1059ed8 | 0;\n this.B = 0x367cd507 | 0;\n this.C = 0x3070dd17 | 0;\n this.D = 0xf70e5939 | 0;\n this.E = 0xffc00b31 | 0;\n this.F = 0x68581511 | 0;\n this.G = 0x64f98fa7 | 0;\n this.H = 0xbefa4fa4 | 0;\n this.outputLen = 28;\n }\n}\n/** SHA2-256 hash function */\nexports.sha256 = (0, utils_js_1.wrapConstructor)(() => new SHA256());\n/** SHA2-224 hash function */\nexports.sha224 = (0, utils_js_1.wrapConstructor)(() => new SHA224());\n//# sourceMappingURL=sha256.js.map","/**\n * SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3.\n *\n * To break sha256 using birthday attack, attackers need to try 2^128 hashes.\n * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.\n *\n * Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).\n * @module\n */\nimport { Chi, HashMD, Maj } from './_md.js';\nimport { type CHash, rotr, wrapConstructor } from './utils.js';\n\n/** Round constants: first 32 bits of fractional parts of the cube roots of the first 64 primes 2..311). */\n// prettier-ignore\nconst SHA256_K = /* @__PURE__ */ new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n]);\n\n/** Initial state: first 32 bits of fractional parts of the square roots of the first 8 primes 2..19. */\n// prettier-ignore\nconst SHA256_IV = /* @__PURE__ */ new Uint32Array([\n 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19\n]);\n\n/**\n * Temporary buffer, not used to store anything between runs.\n * Named this way because it matches specification.\n */\nconst SHA256_W = /* @__PURE__ */ new Uint32Array(64);\nexport class SHA256 extends HashMD {\n // We cannot use array here since array allows indexing by variable\n // which means optimizer/compiler cannot use registers.\n protected A: number = SHA256_IV[0] | 0;\n protected B: number = SHA256_IV[1] | 0;\n protected C: number = SHA256_IV[2] | 0;\n protected D: number = SHA256_IV[3] | 0;\n protected E: number = SHA256_IV[4] | 0;\n protected F: number = SHA256_IV[5] | 0;\n protected G: number = SHA256_IV[6] | 0;\n protected H: number = SHA256_IV[7] | 0;\n\n constructor() {\n super(64, 32, 8, false);\n }\n protected get(): [number, number, number, number, number, number, number, number] {\n const { A, B, C, D, E, F, G, H } = this;\n return [A, B, C, D, E, F, G, H];\n }\n // prettier-ignore\n protected set(\n A: number, B: number, C: number, D: number, E: number, F: number, G: number, H: number\n ): void {\n this.A = A | 0;\n this.B = B | 0;\n this.C = C | 0;\n this.D = D | 0;\n this.E = E | 0;\n this.F = F | 0;\n this.G = G | 0;\n this.H = H | 0;\n }\n protected process(view: DataView, offset: number): void {\n // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array\n for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);\n for (let i = 16; i < 64; i++) {\n const W15 = SHA256_W[i - 15];\n const W2 = SHA256_W[i - 2];\n const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);\n const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);\n SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;\n }\n // Compression function main loop, 64 rounds\n let { A, B, C, D, E, F, G, H } = this;\n for (let i = 0; i < 64; i++) {\n const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);\n const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;\n const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);\n const T2 = (sigma0 + Maj(A, B, C)) | 0;\n H = G;\n G = F;\n F = E;\n E = (D + T1) | 0;\n D = C;\n C = B;\n B = A;\n A = (T1 + T2) | 0;\n }\n // Add the compressed chunk to the current hash value\n A = (A + this.A) | 0;\n B = (B + this.B) | 0;\n C = (C + this.C) | 0;\n D = (D + this.D) | 0;\n E = (E + this.E) | 0;\n F = (F + this.F) | 0;\n G = (G + this.G) | 0;\n H = (H + this.H) | 0;\n this.set(A, B, C, D, E, F, G, H);\n }\n protected roundClean(): void {\n SHA256_W.fill(0);\n }\n destroy(): void {\n this.set(0, 0, 0, 0, 0, 0, 0, 0);\n this.buffer.fill(0);\n }\n}\n\n/**\n * Constants taken from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf.\n */\nclass SHA224 extends SHA256 {\n protected A = 0xc1059ed8 | 0;\n protected B = 0x367cd507 | 0;\n protected C = 0x3070dd17 | 0;\n protected D = 0xf70e5939 | 0;\n protected E = 0xffc00b31 | 0;\n protected F = 0x68581511 | 0;\n protected G = 0x64f98fa7 | 0;\n protected H = 0xbefa4fa4 | 0;\n constructor() {\n super();\n this.outputLen = 28;\n }\n}\n\n/** SHA2-256 hash function */\nexport const sha256: CHash = /* @__PURE__ */ wrapConstructor(() => new SHA256());\n/** SHA2-224 hash function */\nexport const sha224: CHash = /* @__PURE__ */ wrapConstructor(() => new SHA224());\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\n return c > 3 && r && Object.defineProperty(target, key, r), r;\n};\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.deserializeUnchecked = exports.deserialize = exports.serialize = exports.BinaryReader = exports.BinaryWriter = exports.BorshError = exports.baseDecode = exports.baseEncode = void 0;\nconst bn_js_1 = __importDefault(require(\"bn.js\"));\nconst bs58_1 = __importDefault(require(\"bs58\"));\n// TODO: Make sure this polyfill not included when not required\nconst encoding = __importStar(require(\"text-encoding-utf-8\"));\nconst ResolvedTextDecoder = typeof TextDecoder !== \"function\" ? encoding.TextDecoder : TextDecoder;\nconst textDecoder = new ResolvedTextDecoder(\"utf-8\", { fatal: true });\nfunction baseEncode(value) {\n if (typeof value === \"string\") {\n value = Buffer.from(value, \"utf8\");\n }\n return bs58_1.default.encode(Buffer.from(value));\n}\nexports.baseEncode = baseEncode;\nfunction baseDecode(value) {\n return Buffer.from(bs58_1.default.decode(value));\n}\nexports.baseDecode = baseDecode;\nconst INITIAL_LENGTH = 1024;\nclass BorshError extends Error {\n constructor(message) {\n super(message);\n this.fieldPath = [];\n this.originalMessage = message;\n }\n addToFieldPath(fieldName) {\n this.fieldPath.splice(0, 0, fieldName);\n // NOTE: Modifying message directly as jest doesn't use .toString()\n this.message = this.originalMessage + \": \" + this.fieldPath.join(\".\");\n }\n}\nexports.BorshError = BorshError;\n/// Binary encoder.\nclass BinaryWriter {\n constructor() {\n this.buf = Buffer.alloc(INITIAL_LENGTH);\n this.length = 0;\n }\n maybeResize() {\n if (this.buf.length < 16 + this.length) {\n this.buf = Buffer.concat([this.buf, Buffer.alloc(INITIAL_LENGTH)]);\n }\n }\n writeU8(value) {\n this.maybeResize();\n this.buf.writeUInt8(value, this.length);\n this.length += 1;\n }\n writeU16(value) {\n this.maybeResize();\n this.buf.writeUInt16LE(value, this.length);\n this.length += 2;\n }\n writeU32(value) {\n this.maybeResize();\n this.buf.writeUInt32LE(value, this.length);\n this.length += 4;\n }\n writeU64(value) {\n this.maybeResize();\n this.writeBuffer(Buffer.from(new bn_js_1.default(value).toArray(\"le\", 8)));\n }\n writeU128(value) {\n this.maybeResize();\n this.writeBuffer(Buffer.from(new bn_js_1.default(value).toArray(\"le\", 16)));\n }\n writeU256(value) {\n this.maybeResize();\n this.writeBuffer(Buffer.from(new bn_js_1.default(value).toArray(\"le\", 32)));\n }\n writeU512(value) {\n this.maybeResize();\n this.writeBuffer(Buffer.from(new bn_js_1.default(value).toArray(\"le\", 64)));\n }\n writeBuffer(buffer) {\n // Buffer.from is needed as this.buf.subarray can return plain Uint8Array in browser\n this.buf = Buffer.concat([\n Buffer.from(this.buf.subarray(0, this.length)),\n buffer,\n Buffer.alloc(INITIAL_LENGTH),\n ]);\n this.length += buffer.length;\n }\n writeString(str) {\n this.maybeResize();\n const b = Buffer.from(str, \"utf8\");\n this.writeU32(b.length);\n this.writeBuffer(b);\n }\n writeFixedArray(array) {\n this.writeBuffer(Buffer.from(array));\n }\n writeArray(array, fn) {\n this.maybeResize();\n this.writeU32(array.length);\n for (const elem of array) {\n this.maybeResize();\n fn(elem);\n }\n }\n toArray() {\n return this.buf.subarray(0, this.length);\n }\n}\nexports.BinaryWriter = BinaryWriter;\nfunction handlingRangeError(target, propertyKey, propertyDescriptor) {\n const originalMethod = propertyDescriptor.value;\n propertyDescriptor.value = function (...args) {\n try {\n return originalMethod.apply(this, args);\n }\n catch (e) {\n if (e instanceof RangeError) {\n const code = e.code;\n if ([\"ERR_BUFFER_OUT_OF_BOUNDS\", \"ERR_OUT_OF_RANGE\"].indexOf(code) >= 0) {\n throw new BorshError(\"Reached the end of buffer when deserializing\");\n }\n }\n throw e;\n }\n };\n}\nclass BinaryReader {\n constructor(buf) {\n this.buf = buf;\n this.offset = 0;\n }\n readU8() {\n const value = this.buf.readUInt8(this.offset);\n this.offset += 1;\n return value;\n }\n readU16() {\n const value = this.buf.readUInt16LE(this.offset);\n this.offset += 2;\n return value;\n }\n readU32() {\n const value = this.buf.readUInt32LE(this.offset);\n this.offset += 4;\n return value;\n }\n readU64() {\n const buf = this.readBuffer(8);\n return new bn_js_1.default(buf, \"le\");\n }\n readU128() {\n const buf = this.readBuffer(16);\n return new bn_js_1.default(buf, \"le\");\n }\n readU256() {\n const buf = this.readBuffer(32);\n return new bn_js_1.default(buf, \"le\");\n }\n readU512() {\n const buf = this.readBuffer(64);\n return new bn_js_1.default(buf, \"le\");\n }\n readBuffer(len) {\n if (this.offset + len > this.buf.length) {\n throw new BorshError(`Expected buffer length ${len} isn't within bounds`);\n }\n const result = this.buf.slice(this.offset, this.offset + len);\n this.offset += len;\n return result;\n }\n readString() {\n const len = this.readU32();\n const buf = this.readBuffer(len);\n try {\n // NOTE: Using TextDecoder to fail on invalid UTF-8\n return textDecoder.decode(buf);\n }\n catch (e) {\n throw new BorshError(`Error decoding UTF-8 string: ${e}`);\n }\n }\n readFixedArray(len) {\n return new Uint8Array(this.readBuffer(len));\n }\n readArray(fn) {\n const len = this.readU32();\n const result = Array();\n for (let i = 0; i < len; ++i) {\n result.push(fn());\n }\n return result;\n }\n}\n__decorate([\n handlingRangeError\n], BinaryReader.prototype, \"readU8\", null);\n__decorate([\n handlingRangeError\n], BinaryReader.prototype, \"readU16\", null);\n__decorate([\n handlingRangeError\n], BinaryReader.prototype, \"readU32\", null);\n__decorate([\n handlingRangeError\n], BinaryReader.prototype, \"readU64\", null);\n__decorate([\n handlingRangeError\n], BinaryReader.prototype, \"readU128\", null);\n__decorate([\n handlingRangeError\n], BinaryReader.prototype, \"readU256\", null);\n__decorate([\n handlingRangeError\n], BinaryReader.prototype, \"readU512\", null);\n__decorate([\n handlingRangeError\n], BinaryReader.prototype, \"readString\", null);\n__decorate([\n handlingRangeError\n], BinaryReader.prototype, \"readFixedArray\", null);\n__decorate([\n handlingRangeError\n], BinaryReader.prototype, \"readArray\", null);\nexports.BinaryReader = BinaryReader;\nfunction capitalizeFirstLetter(string) {\n return string.charAt(0).toUpperCase() + string.slice(1);\n}\nfunction serializeField(schema, fieldName, value, fieldType, writer) {\n try {\n // TODO: Handle missing values properly (make sure they never result in just skipped write)\n if (typeof fieldType === \"string\") {\n writer[`write${capitalizeFirstLetter(fieldType)}`](value);\n }\n else if (fieldType instanceof Array) {\n if (typeof fieldType[0] === \"number\") {\n if (value.length !== fieldType[0]) {\n throw new BorshError(`Expecting byte array of length ${fieldType[0]}, but got ${value.length} bytes`);\n }\n writer.writeFixedArray(value);\n }\n else if (fieldType.length === 2 && typeof fieldType[1] === \"number\") {\n if (value.length !== fieldType[1]) {\n throw new BorshError(`Expecting byte array of length ${fieldType[1]}, but got ${value.length} bytes`);\n }\n for (let i = 0; i < fieldType[1]; i++) {\n serializeField(schema, null, value[i], fieldType[0], writer);\n }\n }\n else {\n writer.writeArray(value, (item) => {\n serializeField(schema, fieldName, item, fieldType[0], writer);\n });\n }\n }\n else if (fieldType.kind !== undefined) {\n switch (fieldType.kind) {\n case \"option\": {\n if (value === null || value === undefined) {\n writer.writeU8(0);\n }\n else {\n writer.writeU8(1);\n serializeField(schema, fieldName, value, fieldType.type, writer);\n }\n break;\n }\n case \"map\": {\n writer.writeU32(value.size);\n value.forEach((val, key) => {\n serializeField(schema, fieldName, key, fieldType.key, writer);\n serializeField(schema, fieldName, val, fieldType.value, writer);\n });\n break;\n }\n default:\n throw new BorshError(`FieldType ${fieldType} unrecognized`);\n }\n }\n else {\n serializeStruct(schema, value, writer);\n }\n }\n catch (error) {\n if (error instanceof BorshError) {\n error.addToFieldPath(fieldName);\n }\n throw error;\n }\n}\nfunction serializeStruct(schema, obj, writer) {\n if (typeof obj.borshSerialize === \"function\") {\n obj.borshSerialize(writer);\n return;\n }\n const structSchema = schema.get(obj.constructor);\n if (!structSchema) {\n throw new BorshError(`Class ${obj.constructor.name} is missing in schema`);\n }\n if (structSchema.kind === \"struct\") {\n structSchema.fields.map(([fieldName, fieldType]) => {\n serializeField(schema, fieldName, obj[fieldName], fieldType, writer);\n });\n }\n else if (structSchema.kind === \"enum\") {\n const name = obj[structSchema.field];\n for (let idx = 0; idx < structSchema.values.length; ++idx) {\n const [fieldName, fieldType] = structSchema.values[idx];\n if (fieldName === name) {\n writer.writeU8(idx);\n serializeField(schema, fieldName, obj[fieldName], fieldType, writer);\n break;\n }\n }\n }\n else {\n throw new BorshError(`Unexpected schema kind: ${structSchema.kind} for ${obj.constructor.name}`);\n }\n}\n/// Serialize given object using schema of the form:\n/// { class_name -> [ [field_name, field_type], .. ], .. }\nfunction serialize(schema, obj, Writer = BinaryWriter) {\n const writer = new Writer();\n serializeStruct(schema, obj, writer);\n return writer.toArray();\n}\nexports.serialize = serialize;\nfunction deserializeField(schema, fieldName, fieldType, reader) {\n try {\n if (typeof fieldType === \"string\") {\n return reader[`read${capitalizeFirstLetter(fieldType)}`]();\n }\n if (fieldType instanceof Array) {\n if (typeof fieldType[0] === \"number\") {\n return reader.readFixedArray(fieldType[0]);\n }\n else if (typeof fieldType[1] === \"number\") {\n const arr = [];\n for (let i = 0; i < fieldType[1]; i++) {\n arr.push(deserializeField(schema, null, fieldType[0], reader));\n }\n return arr;\n }\n else {\n return reader.readArray(() => deserializeField(schema, fieldName, fieldType[0], reader));\n }\n }\n if (fieldType.kind === \"option\") {\n const option = reader.readU8();\n if (option) {\n return deserializeField(schema, fieldName, fieldType.type, reader);\n }\n return undefined;\n }\n if (fieldType.kind === \"map\") {\n let map = new Map();\n const length = reader.readU32();\n for (let i = 0; i < length; i++) {\n const key = deserializeField(schema, fieldName, fieldType.key, reader);\n const val = deserializeField(schema, fieldName, fieldType.value, reader);\n map.set(key, val);\n }\n return map;\n }\n return deserializeStruct(schema, fieldType, reader);\n }\n catch (error) {\n if (error instanceof BorshError) {\n error.addToFieldPath(fieldName);\n }\n throw error;\n }\n}\nfunction deserializeStruct(schema, classType, reader) {\n if (typeof classType.borshDeserialize === \"function\") {\n return classType.borshDeserialize(reader);\n }\n const structSchema = schema.get(classType);\n if (!structSchema) {\n throw new BorshError(`Class ${classType.name} is missing in schema`);\n }\n if (structSchema.kind === \"struct\") {\n const result = {};\n for (const [fieldName, fieldType] of schema.get(classType).fields) {\n result[fieldName] = deserializeField(schema, fieldName, fieldType, reader);\n }\n return new classType(result);\n }\n if (structSchema.kind === \"enum\") {\n const idx = reader.readU8();\n if (idx >= structSchema.values.length) {\n throw new BorshError(`Enum index: ${idx} is out of range`);\n }\n const [fieldName, fieldType] = structSchema.values[idx];\n const fieldValue = deserializeField(schema, fieldName, fieldType, reader);\n return new classType({ [fieldName]: fieldValue });\n }\n throw new BorshError(`Unexpected schema kind: ${structSchema.kind} for ${classType.constructor.name}`);\n}\n/// Deserializes object from bytes using schema.\nfunction deserialize(schema, classType, buffer, Reader = BinaryReader) {\n const reader = new Reader(buffer);\n const result = deserializeStruct(schema, classType, reader);\n if (reader.offset < buffer.length) {\n throw new BorshError(`Unexpected ${buffer.length - reader.offset} bytes after deserialized data`);\n }\n return result;\n}\nexports.deserialize = deserialize;\n/// Deserializes object from bytes using schema, without checking the length read\nfunction deserializeUnchecked(schema, classType, buffer, Reader = BinaryReader) {\n const reader = new Reader(buffer);\n return deserializeStruct(schema, classType, reader);\n}\nexports.deserializeUnchecked = deserializeUnchecked;\n","'use strict';\n\n// This is free and unencumbered software released into the public domain.\n// See LICENSE.md for more information.\n\n//\n// Utilities\n//\n\n/**\n * @param {number} a The number to test.\n * @param {number} min The minimum value in the range, inclusive.\n * @param {number} max The maximum value in the range, inclusive.\n * @return {boolean} True if a >= min and a <= max.\n */\nfunction inRange(a, min, max) {\n return min <= a && a <= max;\n}\n\n/**\n * @param {*} o\n * @return {Object}\n */\nfunction ToDictionary(o) {\n if (o === undefined) return {};\n if (o === Object(o)) return o;\n throw TypeError('Could not convert argument to dictionary');\n}\n\n/**\n * @param {string} string Input string of UTF-16 code units.\n * @return {!Array.} Code points.\n */\nfunction stringToCodePoints(string) {\n // https://heycam.github.io/webidl/#dfn-obtain-unicode\n\n // 1. Let S be the DOMString value.\n var s = String(string);\n\n // 2. Let n be the length of S.\n var n = s.length;\n\n // 3. Initialize i to 0.\n var i = 0;\n\n // 4. Initialize U to be an empty sequence of Unicode characters.\n var u = [];\n\n // 5. While i < n:\n while (i < n) {\n\n // 1. Let c be the code unit in S at index i.\n var c = s.charCodeAt(i);\n\n // 2. Depending on the value of c:\n\n // c < 0xD800 or c > 0xDFFF\n if (c < 0xD800 || c > 0xDFFF) {\n // Append to U the Unicode character with code point c.\n u.push(c);\n }\n\n // 0xDC00 ≤ c ≤ 0xDFFF\n else if (0xDC00 <= c && c <= 0xDFFF) {\n // Append to U a U+FFFD REPLACEMENT CHARACTER.\n u.push(0xFFFD);\n }\n\n // 0xD800 ≤ c ≤ 0xDBFF\n else if (0xD800 <= c && c <= 0xDBFF) {\n // 1. If i = n−1, then append to U a U+FFFD REPLACEMENT\n // CHARACTER.\n if (i === n - 1) {\n u.push(0xFFFD);\n }\n // 2. Otherwise, i < n−1:\n else {\n // 1. Let d be the code unit in S at index i+1.\n var d = string.charCodeAt(i + 1);\n\n // 2. If 0xDC00 ≤ d ≤ 0xDFFF, then:\n if (0xDC00 <= d && d <= 0xDFFF) {\n // 1. Let a be c & 0x3FF.\n var a = c & 0x3FF;\n\n // 2. Let b be d & 0x3FF.\n var b = d & 0x3FF;\n\n // 3. Append to U the Unicode character with code point\n // 2^16+2^10*a+b.\n u.push(0x10000 + (a << 10) + b);\n\n // 4. Set i to i+1.\n i += 1;\n }\n\n // 3. Otherwise, d < 0xDC00 or d > 0xDFFF. Append to U a\n // U+FFFD REPLACEMENT CHARACTER.\n else {\n u.push(0xFFFD);\n }\n }\n }\n\n // 3. Set i to i+1.\n i += 1;\n }\n\n // 6. Return U.\n return u;\n}\n\n/**\n * @param {!Array.} code_points Array of code points.\n * @return {string} string String of UTF-16 code units.\n */\nfunction codePointsToString(code_points) {\n var s = '';\n for (var i = 0; i < code_points.length; ++i) {\n var cp = code_points[i];\n if (cp <= 0xFFFF) {\n s += String.fromCharCode(cp);\n } else {\n cp -= 0x10000;\n s += String.fromCharCode((cp >> 10) + 0xD800,\n (cp & 0x3FF) + 0xDC00);\n }\n }\n return s;\n}\n\n\n//\n// Implementation of Encoding specification\n// https://encoding.spec.whatwg.org/\n//\n\n//\n// 3. Terminology\n//\n\n/**\n * End-of-stream is a special token that signifies no more tokens\n * are in the stream.\n * @const\n */ var end_of_stream = -1;\n\n/**\n * A stream represents an ordered sequence of tokens.\n *\n * @constructor\n * @param {!(Array.|Uint8Array)} tokens Array of tokens that provide the\n * stream.\n */\nfunction Stream(tokens) {\n /** @type {!Array.} */\n this.tokens = [].slice.call(tokens);\n}\n\nStream.prototype = {\n /**\n * @return {boolean} True if end-of-stream has been hit.\n */\n endOfStream: function() {\n return !this.tokens.length;\n },\n\n /**\n * When a token is read from a stream, the first token in the\n * stream must be returned and subsequently removed, and\n * end-of-stream must be returned otherwise.\n *\n * @return {number} Get the next token from the stream, or\n * end_of_stream.\n */\n read: function() {\n if (!this.tokens.length)\n return end_of_stream;\n return this.tokens.shift();\n },\n\n /**\n * When one or more tokens are prepended to a stream, those tokens\n * must be inserted, in given order, before the first token in the\n * stream.\n *\n * @param {(number|!Array.)} token The token(s) to prepend to the stream.\n */\n prepend: function(token) {\n if (Array.isArray(token)) {\n var tokens = /**@type {!Array.}*/(token);\n while (tokens.length)\n this.tokens.unshift(tokens.pop());\n } else {\n this.tokens.unshift(token);\n }\n },\n\n /**\n * When one or more tokens are pushed to a stream, those tokens\n * must be inserted, in given order, after the last token in the\n * stream.\n *\n * @param {(number|!Array.)} token The tokens(s) to prepend to the stream.\n */\n push: function(token) {\n if (Array.isArray(token)) {\n var tokens = /**@type {!Array.}*/(token);\n while (tokens.length)\n this.tokens.push(tokens.shift());\n } else {\n this.tokens.push(token);\n }\n }\n};\n\n//\n// 4. Encodings\n//\n\n// 4.1 Encoders and decoders\n\n/** @const */\nvar finished = -1;\n\n/**\n * @param {boolean} fatal If true, decoding errors raise an exception.\n * @param {number=} opt_code_point Override the standard fallback code point.\n * @return {number} The code point to insert on a decoding error.\n */\nfunction decoderError(fatal, opt_code_point) {\n if (fatal)\n throw TypeError('Decoder error');\n return opt_code_point || 0xFFFD;\n}\n\n//\n// 7. API\n//\n\n/** @const */ var DEFAULT_ENCODING = 'utf-8';\n\n// 7.1 Interface TextDecoder\n\n/**\n * @constructor\n * @param {string=} encoding The label of the encoding;\n * defaults to 'utf-8'.\n * @param {Object=} options\n */\nfunction TextDecoder(encoding, options) {\n if (!(this instanceof TextDecoder)) {\n return new TextDecoder(encoding, options);\n }\n encoding = encoding !== undefined ? String(encoding).toLowerCase() : DEFAULT_ENCODING;\n if (encoding !== DEFAULT_ENCODING) {\n throw new Error('Encoding not supported. Only utf-8 is supported');\n }\n options = ToDictionary(options);\n\n /** @private @type {boolean} */\n this._streaming = false;\n /** @private @type {boolean} */\n this._BOMseen = false;\n /** @private @type {?Decoder} */\n this._decoder = null;\n /** @private @type {boolean} */\n this._fatal = Boolean(options['fatal']);\n /** @private @type {boolean} */\n this._ignoreBOM = Boolean(options['ignoreBOM']);\n\n Object.defineProperty(this, 'encoding', {value: 'utf-8'});\n Object.defineProperty(this, 'fatal', {value: this._fatal});\n Object.defineProperty(this, 'ignoreBOM', {value: this._ignoreBOM});\n}\n\nTextDecoder.prototype = {\n /**\n * @param {ArrayBufferView=} input The buffer of bytes to decode.\n * @param {Object=} options\n * @return {string} The decoded string.\n */\n decode: function decode(input, options) {\n var bytes;\n if (typeof input === 'object' && input instanceof ArrayBuffer) {\n bytes = new Uint8Array(input);\n } else if (typeof input === 'object' && 'buffer' in input &&\n input.buffer instanceof ArrayBuffer) {\n bytes = new Uint8Array(input.buffer,\n input.byteOffset,\n input.byteLength);\n } else {\n bytes = new Uint8Array(0);\n }\n\n options = ToDictionary(options);\n\n if (!this._streaming) {\n this._decoder = new UTF8Decoder({fatal: this._fatal});\n this._BOMseen = false;\n }\n this._streaming = Boolean(options['stream']);\n\n var input_stream = new Stream(bytes);\n\n var code_points = [];\n\n /** @type {?(number|!Array.)} */\n var result;\n\n while (!input_stream.endOfStream()) {\n result = this._decoder.handler(input_stream, input_stream.read());\n if (result === finished)\n break;\n if (result === null)\n continue;\n if (Array.isArray(result))\n code_points.push.apply(code_points, /**@type {!Array.}*/(result));\n else\n code_points.push(result);\n }\n if (!this._streaming) {\n do {\n result = this._decoder.handler(input_stream, input_stream.read());\n if (result === finished)\n break;\n if (result === null)\n continue;\n if (Array.isArray(result))\n code_points.push.apply(code_points, /**@type {!Array.}*/(result));\n else\n code_points.push(result);\n } while (!input_stream.endOfStream());\n this._decoder = null;\n }\n\n if (code_points.length) {\n // If encoding is one of utf-8, utf-16be, and utf-16le, and\n // ignore BOM flag and BOM seen flag are unset, run these\n // subsubsteps:\n if (['utf-8'].indexOf(this.encoding) !== -1 &&\n !this._ignoreBOM && !this._BOMseen) {\n // If token is U+FEFF, set BOM seen flag.\n if (code_points[0] === 0xFEFF) {\n this._BOMseen = true;\n code_points.shift();\n } else {\n // Otherwise, if token is not end-of-stream, set BOM seen\n // flag and append token to output.\n this._BOMseen = true;\n }\n }\n }\n\n return codePointsToString(code_points);\n }\n};\n\n// 7.2 Interface TextEncoder\n\n/**\n * @constructor\n * @param {string=} encoding The label of the encoding;\n * defaults to 'utf-8'.\n * @param {Object=} options\n */\nfunction TextEncoder(encoding, options) {\n if (!(this instanceof TextEncoder))\n return new TextEncoder(encoding, options);\n encoding = encoding !== undefined ? String(encoding).toLowerCase() : DEFAULT_ENCODING;\n if (encoding !== DEFAULT_ENCODING) {\n throw new Error('Encoding not supported. Only utf-8 is supported');\n }\n options = ToDictionary(options);\n\n /** @private @type {boolean} */\n this._streaming = false;\n /** @private @type {?Encoder} */\n this._encoder = null;\n /** @private @type {{fatal: boolean}} */\n this._options = {fatal: Boolean(options['fatal'])};\n\n Object.defineProperty(this, 'encoding', {value: 'utf-8'});\n}\n\nTextEncoder.prototype = {\n /**\n * @param {string=} opt_string The string to encode.\n * @param {Object=} options\n * @return {Uint8Array} Encoded bytes, as a Uint8Array.\n */\n encode: function encode(opt_string, options) {\n opt_string = opt_string ? String(opt_string) : '';\n options = ToDictionary(options);\n\n // NOTE: This option is nonstandard. None of the encodings\n // permitted for encoding (i.e. UTF-8, UTF-16) are stateful,\n // so streaming is not necessary.\n if (!this._streaming)\n this._encoder = new UTF8Encoder(this._options);\n this._streaming = Boolean(options['stream']);\n\n var bytes = [];\n var input_stream = new Stream(stringToCodePoints(opt_string));\n /** @type {?(number|!Array.)} */\n var result;\n while (!input_stream.endOfStream()) {\n result = this._encoder.handler(input_stream, input_stream.read());\n if (result === finished)\n break;\n if (Array.isArray(result))\n bytes.push.apply(bytes, /**@type {!Array.}*/(result));\n else\n bytes.push(result);\n }\n if (!this._streaming) {\n while (true) {\n result = this._encoder.handler(input_stream, input_stream.read());\n if (result === finished)\n break;\n if (Array.isArray(result))\n bytes.push.apply(bytes, /**@type {!Array.}*/(result));\n else\n bytes.push(result);\n }\n this._encoder = null;\n }\n return new Uint8Array(bytes);\n }\n};\n\n//\n// 8. The encoding\n//\n\n// 8.1 utf-8\n\n/**\n * @constructor\n * @implements {Decoder}\n * @param {{fatal: boolean}} options\n */\nfunction UTF8Decoder(options) {\n var fatal = options.fatal;\n\n // utf-8's decoder's has an associated utf-8 code point, utf-8\n // bytes seen, and utf-8 bytes needed (all initially 0), a utf-8\n // lower boundary (initially 0x80), and a utf-8 upper boundary\n // (initially 0xBF).\n var /** @type {number} */ utf8_code_point = 0,\n /** @type {number} */ utf8_bytes_seen = 0,\n /** @type {number} */ utf8_bytes_needed = 0,\n /** @type {number} */ utf8_lower_boundary = 0x80,\n /** @type {number} */ utf8_upper_boundary = 0xBF;\n\n /**\n * @param {Stream} stream The stream of bytes being decoded.\n * @param {number} bite The next byte read from the stream.\n * @return {?(number|!Array.)} The next code point(s)\n * decoded, or null if not enough data exists in the input\n * stream to decode a complete code point.\n */\n this.handler = function(stream, bite) {\n // 1. If byte is end-of-stream and utf-8 bytes needed is not 0,\n // set utf-8 bytes needed to 0 and return error.\n if (bite === end_of_stream && utf8_bytes_needed !== 0) {\n utf8_bytes_needed = 0;\n return decoderError(fatal);\n }\n\n // 2. If byte is end-of-stream, return finished.\n if (bite === end_of_stream)\n return finished;\n\n // 3. If utf-8 bytes needed is 0, based on byte:\n if (utf8_bytes_needed === 0) {\n\n // 0x00 to 0x7F\n if (inRange(bite, 0x00, 0x7F)) {\n // Return a code point whose value is byte.\n return bite;\n }\n\n // 0xC2 to 0xDF\n if (inRange(bite, 0xC2, 0xDF)) {\n // Set utf-8 bytes needed to 1 and utf-8 code point to byte\n // − 0xC0.\n utf8_bytes_needed = 1;\n utf8_code_point = bite - 0xC0;\n }\n\n // 0xE0 to 0xEF\n else if (inRange(bite, 0xE0, 0xEF)) {\n // 1. If byte is 0xE0, set utf-8 lower boundary to 0xA0.\n if (bite === 0xE0)\n utf8_lower_boundary = 0xA0;\n // 2. If byte is 0xED, set utf-8 upper boundary to 0x9F.\n if (bite === 0xED)\n utf8_upper_boundary = 0x9F;\n // 3. Set utf-8 bytes needed to 2 and utf-8 code point to\n // byte − 0xE0.\n utf8_bytes_needed = 2;\n utf8_code_point = bite - 0xE0;\n }\n\n // 0xF0 to 0xF4\n else if (inRange(bite, 0xF0, 0xF4)) {\n // 1. If byte is 0xF0, set utf-8 lower boundary to 0x90.\n if (bite === 0xF0)\n utf8_lower_boundary = 0x90;\n // 2. If byte is 0xF4, set utf-8 upper boundary to 0x8F.\n if (bite === 0xF4)\n utf8_upper_boundary = 0x8F;\n // 3. Set utf-8 bytes needed to 3 and utf-8 code point to\n // byte − 0xF0.\n utf8_bytes_needed = 3;\n utf8_code_point = bite - 0xF0;\n }\n\n // Otherwise\n else {\n // Return error.\n return decoderError(fatal);\n }\n\n // Then (byte is in the range 0xC2 to 0xF4) set utf-8 code\n // point to utf-8 code point << (6 × utf-8 bytes needed) and\n // return continue.\n utf8_code_point = utf8_code_point << (6 * utf8_bytes_needed);\n return null;\n }\n\n // 4. If byte is not in the range utf-8 lower boundary to utf-8\n // upper boundary, run these substeps:\n if (!inRange(bite, utf8_lower_boundary, utf8_upper_boundary)) {\n\n // 1. Set utf-8 code point, utf-8 bytes needed, and utf-8\n // bytes seen to 0, set utf-8 lower boundary to 0x80, and set\n // utf-8 upper boundary to 0xBF.\n utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;\n utf8_lower_boundary = 0x80;\n utf8_upper_boundary = 0xBF;\n\n // 2. Prepend byte to stream.\n stream.prepend(bite);\n\n // 3. Return error.\n return decoderError(fatal);\n }\n\n // 5. Set utf-8 lower boundary to 0x80 and utf-8 upper boundary\n // to 0xBF.\n utf8_lower_boundary = 0x80;\n utf8_upper_boundary = 0xBF;\n\n // 6. Increase utf-8 bytes seen by one and set utf-8 code point\n // to utf-8 code point + (byte − 0x80) << (6 × (utf-8 bytes\n // needed − utf-8 bytes seen)).\n utf8_bytes_seen += 1;\n utf8_code_point += (bite - 0x80) << (6 * (utf8_bytes_needed - utf8_bytes_seen));\n\n // 7. If utf-8 bytes seen is not equal to utf-8 bytes needed,\n // continue.\n if (utf8_bytes_seen !== utf8_bytes_needed)\n return null;\n\n // 8. Let code point be utf-8 code point.\n var code_point = utf8_code_point;\n\n // 9. Set utf-8 code point, utf-8 bytes needed, and utf-8 bytes\n // seen to 0.\n utf8_code_point = utf8_bytes_needed = utf8_bytes_seen = 0;\n\n // 10. Return a code point whose value is code point.\n return code_point;\n };\n}\n\n/**\n * @constructor\n * @implements {Encoder}\n * @param {{fatal: boolean}} options\n */\nfunction UTF8Encoder(options) {\n var fatal = options.fatal;\n /**\n * @param {Stream} stream Input stream.\n * @param {number} code_point Next code point read from the stream.\n * @return {(number|!Array.)} Byte(s) to emit.\n */\n this.handler = function(stream, code_point) {\n // 1. If code point is end-of-stream, return finished.\n if (code_point === end_of_stream)\n return finished;\n\n // 2. If code point is in the range U+0000 to U+007F, return a\n // byte whose value is code point.\n if (inRange(code_point, 0x0000, 0x007f))\n return code_point;\n\n // 3. Set count and offset based on the range code point is in:\n var count, offset;\n // U+0080 to U+07FF: 1 and 0xC0\n if (inRange(code_point, 0x0080, 0x07FF)) {\n count = 1;\n offset = 0xC0;\n }\n // U+0800 to U+FFFF: 2 and 0xE0\n else if (inRange(code_point, 0x0800, 0xFFFF)) {\n count = 2;\n offset = 0xE0;\n }\n // U+10000 to U+10FFFF: 3 and 0xF0\n else if (inRange(code_point, 0x10000, 0x10FFFF)) {\n count = 3;\n offset = 0xF0;\n }\n\n // 4.Let bytes be a byte sequence whose first byte is (code\n // point >> (6 × count)) + offset.\n var bytes = [(code_point >> (6 * count)) + offset];\n\n // 5. Run these substeps while count is greater than 0:\n while (count > 0) {\n\n // 1. Set temp to code point >> (6 × (count − 1)).\n var temp = code_point >> (6 * (count - 1));\n\n // 2. Append to bytes 0x80 | (temp & 0x3F).\n bytes.push(0x80 | (temp & 0x3F));\n\n // 3. Decrease count by one.\n count -= 1;\n }\n\n // 6. Return bytes bytes, in order.\n return bytes;\n };\n}\n\nexports.TextEncoder = TextEncoder;\nexports.TextDecoder = TextDecoder;","/* The MIT License (MIT)\n *\n * Copyright 2015-2018 Peter A. Bigot\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\n/**\n * Support for translating between Uint8Array instances and JavaScript\n * native types.\n *\n * {@link module:Layout~Layout|Layout} is the basis of a class\n * hierarchy that associates property names with sequences of encoded\n * bytes.\n *\n * Layouts are supported for these scalar (numeric) types:\n * * {@link module:Layout~UInt|Unsigned integers in little-endian\n * format} with {@link module:Layout.u8|8-bit}, {@link\n * module:Layout.u16|16-bit}, {@link module:Layout.u24|24-bit},\n * {@link module:Layout.u32|32-bit}, {@link\n * module:Layout.u40|40-bit}, and {@link module:Layout.u48|48-bit}\n * representation ranges;\n * * {@link module:Layout~UIntBE|Unsigned integers in big-endian\n * format} with {@link module:Layout.u16be|16-bit}, {@link\n * module:Layout.u24be|24-bit}, {@link module:Layout.u32be|32-bit},\n * {@link module:Layout.u40be|40-bit}, and {@link\n * module:Layout.u48be|48-bit} representation ranges;\n * * {@link module:Layout~Int|Signed integers in little-endian\n * format} with {@link module:Layout.s8|8-bit}, {@link\n * module:Layout.s16|16-bit}, {@link module:Layout.s24|24-bit},\n * {@link module:Layout.s32|32-bit}, {@link\n * module:Layout.s40|40-bit}, and {@link module:Layout.s48|48-bit}\n * representation ranges;\n * * {@link module:Layout~IntBE|Signed integers in big-endian format}\n * with {@link module:Layout.s16be|16-bit}, {@link\n * module:Layout.s24be|24-bit}, {@link module:Layout.s32be|32-bit},\n * {@link module:Layout.s40be|40-bit}, and {@link\n * module:Layout.s48be|48-bit} representation ranges;\n * * 64-bit integral values that decode to an exact (if magnitude is\n * less than 2^53) or nearby integral Number in {@link\n * module:Layout.nu64|unsigned little-endian}, {@link\n * module:Layout.nu64be|unsigned big-endian}, {@link\n * module:Layout.ns64|signed little-endian}, and {@link\n * module:Layout.ns64be|unsigned big-endian} encodings;\n * * 32-bit floating point values with {@link\n * module:Layout.f32|little-endian} and {@link\n * module:Layout.f32be|big-endian} representations;\n * * 64-bit floating point values with {@link\n * module:Layout.f64|little-endian} and {@link\n * module:Layout.f64be|big-endian} representations;\n * * {@link module:Layout.const|Constants} that take no space in the\n * encoded expression.\n *\n * and for these aggregate types:\n * * {@link module:Layout.seq|Sequence}s of instances of a {@link\n * module:Layout~Layout|Layout}, with JavaScript representation as\n * an Array and constant or data-dependent {@link\n * module:Layout~Sequence#count|length};\n * * {@link module:Layout.struct|Structure}s that aggregate a\n * heterogeneous sequence of {@link module:Layout~Layout|Layout}\n * instances, with JavaScript representation as an Object;\n * * {@link module:Layout.union|Union}s that support multiple {@link\n * module:Layout~VariantLayout|variant layouts} over a fixed\n * (padded) or variable (not padded) span of bytes, using an\n * unsigned integer at the start of the data or a separate {@link\n * module:Layout.unionLayoutDiscriminator|layout element} to\n * determine which layout to use when interpreting the buffer\n * contents;\n * * {@link module:Layout.bits|BitStructure}s that contain a sequence\n * of individual {@link\n * module:Layout~BitStructure#addField|BitField}s packed into an 8,\n * 16, 24, or 32-bit unsigned integer starting at the least- or\n * most-significant bit;\n * * {@link module:Layout.cstr|C strings} of varying length;\n * * {@link module:Layout.blob|Blobs} of fixed- or variable-{@link\n * module:Layout~Blob#length|length} raw data.\n *\n * All {@link module:Layout~Layout|Layout} instances are immutable\n * after construction, to prevent internal state from becoming\n * inconsistent.\n *\n * @local Layout\n * @local ExternalLayout\n * @local GreedyCount\n * @local OffsetLayout\n * @local UInt\n * @local UIntBE\n * @local Int\n * @local IntBE\n * @local NearUInt64\n * @local NearUInt64BE\n * @local NearInt64\n * @local NearInt64BE\n * @local Float\n * @local FloatBE\n * @local Double\n * @local DoubleBE\n * @local Sequence\n * @local Structure\n * @local UnionDiscriminator\n * @local UnionLayoutDiscriminator\n * @local Union\n * @local VariantLayout\n * @local BitStructure\n * @local BitField\n * @local Boolean\n * @local Blob\n * @local CString\n * @local Constant\n * @local bindConstructorLayout\n * @module Layout\n * @license MIT\n * @author Peter A. Bigot\n * @see {@link https://github.com/pabigot/buffer-layout|buffer-layout on GitHub}\n */\n'use strict';\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.s16 = exports.s8 = exports.nu64be = exports.u48be = exports.u40be = exports.u32be = exports.u24be = exports.u16be = exports.nu64 = exports.u48 = exports.u40 = exports.u32 = exports.u24 = exports.u16 = exports.u8 = exports.offset = exports.greedy = exports.Constant = exports.UTF8 = exports.CString = exports.Blob = exports.Boolean = exports.BitField = exports.BitStructure = exports.VariantLayout = exports.Union = exports.UnionLayoutDiscriminator = exports.UnionDiscriminator = exports.Structure = exports.Sequence = exports.DoubleBE = exports.Double = exports.FloatBE = exports.Float = exports.NearInt64BE = exports.NearInt64 = exports.NearUInt64BE = exports.NearUInt64 = exports.IntBE = exports.Int = exports.UIntBE = exports.UInt = exports.OffsetLayout = exports.GreedyCount = exports.ExternalLayout = exports.bindConstructorLayout = exports.nameWithProperty = exports.Layout = exports.uint8ArrayToBuffer = exports.checkUint8Array = void 0;\nexports.constant = exports.utf8 = exports.cstr = exports.blob = exports.unionLayoutDiscriminator = exports.union = exports.seq = exports.bits = exports.struct = exports.f64be = exports.f64 = exports.f32be = exports.f32 = exports.ns64be = exports.s48be = exports.s40be = exports.s32be = exports.s24be = exports.s16be = exports.ns64 = exports.s48 = exports.s40 = exports.s32 = exports.s24 = void 0;\nconst buffer_1 = require(\"buffer\");\n/* Check if a value is a Uint8Array.\n *\n * @ignore */\nfunction checkUint8Array(b) {\n if (!(b instanceof Uint8Array)) {\n throw new TypeError('b must be a Uint8Array');\n }\n}\nexports.checkUint8Array = checkUint8Array;\n/* Create a Buffer instance from a Uint8Array.\n *\n * @ignore */\nfunction uint8ArrayToBuffer(b) {\n checkUint8Array(b);\n return buffer_1.Buffer.from(b.buffer, b.byteOffset, b.length);\n}\nexports.uint8ArrayToBuffer = uint8ArrayToBuffer;\n/**\n * Base class for layout objects.\n *\n * **NOTE** This is an abstract base class; you can create instances\n * if it amuses you, but they won't support the {@link\n * Layout#encode|encode} or {@link Layout#decode|decode} functions.\n *\n * @param {Number} span - Initializer for {@link Layout#span|span}. The\n * parameter must be an integer; a negative value signifies that the\n * span is {@link Layout#getSpan|value-specific}.\n *\n * @param {string} [property] - Initializer for {@link\n * Layout#property|property}.\n *\n * @abstract\n */\nclass Layout {\n constructor(span, property) {\n if (!Number.isInteger(span)) {\n throw new TypeError('span must be an integer');\n }\n /** The span of the layout in bytes.\n *\n * Positive values are generally expected.\n *\n * Zero will only appear in {@link Constant}s and in {@link\n * Sequence}s where the {@link Sequence#count|count} is zero.\n *\n * A negative value indicates that the span is value-specific, and\n * must be obtained using {@link Layout#getSpan|getSpan}. */\n this.span = span;\n /** The property name used when this layout is represented in an\n * Object.\n *\n * Used only for layouts that {@link Layout#decode|decode} to Object\n * instances. If left undefined the span of the unnamed layout will\n * be treated as padding: it will not be mutated by {@link\n * Layout#encode|encode} nor represented as a property in the\n * decoded Object. */\n this.property = property;\n }\n /** Function to create an Object into which decoded properties will\n * be written.\n *\n * Used only for layouts that {@link Layout#decode|decode} to Object\n * instances, which means:\n * * {@link Structure}\n * * {@link Union}\n * * {@link VariantLayout}\n * * {@link BitStructure}\n *\n * If left undefined the JavaScript representation of these layouts\n * will be Object instances.\n *\n * See {@link bindConstructorLayout}.\n */\n makeDestinationObject() {\n return {};\n }\n /**\n * Calculate the span of a specific instance of a layout.\n *\n * @param {Uint8Array} b - the buffer that contains an encoded instance.\n *\n * @param {Number} [offset] - the offset at which the encoded instance\n * starts. If absent a zero offset is inferred.\n *\n * @return {Number} - the number of bytes covered by the layout\n * instance. If this method is not overridden in a subclass the\n * definition-time constant {@link Layout#span|span} will be\n * returned.\n *\n * @throws {RangeError} - if the length of the value cannot be\n * determined.\n */\n getSpan(b, offset) {\n if (0 > this.span) {\n throw new RangeError('indeterminate span');\n }\n return this.span;\n }\n /**\n * Replicate the layout using a new property.\n *\n * This function must be used to get a structurally-equivalent layout\n * with a different name since all {@link Layout} instances are\n * immutable.\n *\n * **NOTE** This is a shallow copy. All fields except {@link\n * Layout#property|property} are strictly equal to the origin layout.\n *\n * @param {String} property - the value for {@link\n * Layout#property|property} in the replica.\n *\n * @returns {Layout} - the copy with {@link Layout#property|property}\n * set to `property`.\n */\n replicate(property) {\n const rv = Object.create(this.constructor.prototype);\n Object.assign(rv, this);\n rv.property = property;\n return rv;\n }\n /**\n * Create an object from layout properties and an array of values.\n *\n * **NOTE** This function returns `undefined` if invoked on a layout\n * that does not return its value as an Object. Objects are\n * returned for things that are a {@link Structure}, which includes\n * {@link VariantLayout|variant layouts} if they are structures, and\n * excludes {@link Union}s. If you want this feature for a union\n * you must use {@link Union.getVariant|getVariant} to select the\n * desired layout.\n *\n * @param {Array} values - an array of values that correspond to the\n * default order for properties. As with {@link Layout#decode|decode}\n * layout elements that have no property name are skipped when\n * iterating over the array values. Only the top-level properties are\n * assigned; arguments are not assigned to properties of contained\n * layouts. Any unused values are ignored.\n *\n * @return {(Object|undefined)}\n */\n fromArray(values) {\n return undefined;\n }\n}\nexports.Layout = Layout;\n/* Provide text that carries a name (such as for a function that will\n * be throwing an error) annotated with the property of a given layout\n * (such as one for which the value was unacceptable).\n *\n * @ignore */\nfunction nameWithProperty(name, lo) {\n if (lo.property) {\n return name + '[' + lo.property + ']';\n }\n return name;\n}\nexports.nameWithProperty = nameWithProperty;\n/**\n * Augment a class so that instances can be encoded/decoded using a\n * given layout.\n *\n * Calling this function couples `Class` with `layout` in several ways:\n *\n * * `Class.layout_` becomes a static member property equal to `layout`;\n * * `layout.boundConstructor_` becomes a static member property equal\n * to `Class`;\n * * The {@link Layout#makeDestinationObject|makeDestinationObject()}\n * property of `layout` is set to a function that returns a `new\n * Class()`;\n * * `Class.decode(b, offset)` becomes a static member function that\n * delegates to {@link Layout#decode|layout.decode}. The\n * synthesized function may be captured and extended.\n * * `Class.prototype.encode(b, offset)` provides an instance member\n * function that delegates to {@link Layout#encode|layout.encode}\n * with `src` set to `this`. The synthesized function may be\n * captured and extended, but when the extension is invoked `this`\n * must be explicitly bound to the instance.\n *\n * @param {class} Class - a JavaScript class with a nullary\n * constructor.\n *\n * @param {Layout} layout - the {@link Layout} instance used to encode\n * instances of `Class`.\n */\n// `Class` must be a constructor Function, but the assignment of a `layout_` property to it makes it difficult to type\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nfunction bindConstructorLayout(Class, layout) {\n if ('function' !== typeof Class) {\n throw new TypeError('Class must be constructor');\n }\n if (Object.prototype.hasOwnProperty.call(Class, 'layout_')) {\n throw new Error('Class is already bound to a layout');\n }\n if (!(layout && (layout instanceof Layout))) {\n throw new TypeError('layout must be a Layout');\n }\n if (Object.prototype.hasOwnProperty.call(layout, 'boundConstructor_')) {\n throw new Error('layout is already bound to a constructor');\n }\n Class.layout_ = layout;\n layout.boundConstructor_ = Class;\n layout.makeDestinationObject = (() => new Class());\n Object.defineProperty(Class.prototype, 'encode', {\n value(b, offset) {\n return layout.encode(this, b, offset);\n },\n writable: true,\n });\n Object.defineProperty(Class, 'decode', {\n value(b, offset) {\n return layout.decode(b, offset);\n },\n writable: true,\n });\n}\nexports.bindConstructorLayout = bindConstructorLayout;\n/**\n * An object that behaves like a layout but does not consume space\n * within its containing layout.\n *\n * This is primarily used to obtain metadata about a member, such as a\n * {@link OffsetLayout} that can provide data about a {@link\n * Layout#getSpan|value-specific span}.\n *\n * **NOTE** This is an abstract base class; you can create instances\n * if it amuses you, but they won't support {@link\n * ExternalLayout#isCount|isCount} or other {@link Layout} functions.\n *\n * @param {Number} span - initializer for {@link Layout#span|span}.\n * The parameter can range from 1 through 6.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @abstract\n * @augments {Layout}\n */\nclass ExternalLayout extends Layout {\n /**\n * Return `true` iff the external layout decodes to an unsigned\n * integer layout.\n *\n * In that case it can be used as the source of {@link\n * Sequence#count|Sequence counts}, {@link Blob#length|Blob lengths},\n * or as {@link UnionLayoutDiscriminator#layout|external union\n * discriminators}.\n *\n * @abstract\n */\n isCount() {\n throw new Error('ExternalLayout is abstract');\n }\n}\nexports.ExternalLayout = ExternalLayout;\n/**\n * An {@link ExternalLayout} that determines its {@link\n * Layout#decode|value} based on offset into and length of the buffer\n * on which it is invoked.\n *\n * *Factory*: {@link module:Layout.greedy|greedy}\n *\n * @param {Number} [elementSpan] - initializer for {@link\n * GreedyCount#elementSpan|elementSpan}.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {ExternalLayout}\n */\nclass GreedyCount extends ExternalLayout {\n constructor(elementSpan = 1, property) {\n if ((!Number.isInteger(elementSpan)) || (0 >= elementSpan)) {\n throw new TypeError('elementSpan must be a (positive) integer');\n }\n super(-1, property);\n /** The layout for individual elements of the sequence. The value\n * must be a positive integer. If not provided, the value will be\n * 1. */\n this.elementSpan = elementSpan;\n }\n /** @override */\n isCount() {\n return true;\n }\n /** @override */\n decode(b, offset = 0) {\n checkUint8Array(b);\n const rem = b.length - offset;\n return Math.floor(rem / this.elementSpan);\n }\n /** @override */\n encode(src, b, offset) {\n return 0;\n }\n}\nexports.GreedyCount = GreedyCount;\n/**\n * An {@link ExternalLayout} that supports accessing a {@link Layout}\n * at a fixed offset from the start of another Layout. The offset may\n * be before, within, or after the base layout.\n *\n * *Factory*: {@link module:Layout.offset|offset}\n *\n * @param {Layout} layout - initializer for {@link\n * OffsetLayout#layout|layout}, modulo `property`.\n *\n * @param {Number} [offset] - Initializes {@link\n * OffsetLayout#offset|offset}. Defaults to zero.\n *\n * @param {string} [property] - Optional new property name for a\n * {@link Layout#replicate| replica} of `layout` to be used as {@link\n * OffsetLayout#layout|layout}. If not provided the `layout` is used\n * unchanged.\n *\n * @augments {Layout}\n */\nclass OffsetLayout extends ExternalLayout {\n constructor(layout, offset = 0, property) {\n if (!(layout instanceof Layout)) {\n throw new TypeError('layout must be a Layout');\n }\n if (!Number.isInteger(offset)) {\n throw new TypeError('offset must be integer or undefined');\n }\n super(layout.span, property || layout.property);\n /** The subordinated layout. */\n this.layout = layout;\n /** The location of {@link OffsetLayout#layout} relative to the\n * start of another layout.\n *\n * The value may be positive or negative, but an error will thrown\n * if at the point of use it goes outside the span of the Uint8Array\n * being accessed. */\n this.offset = offset;\n }\n /** @override */\n isCount() {\n return ((this.layout instanceof UInt)\n || (this.layout instanceof UIntBE));\n }\n /** @override */\n decode(b, offset = 0) {\n return this.layout.decode(b, offset + this.offset);\n }\n /** @override */\n encode(src, b, offset = 0) {\n return this.layout.encode(src, b, offset + this.offset);\n }\n}\nexports.OffsetLayout = OffsetLayout;\n/**\n * Represent an unsigned integer in little-endian format.\n *\n * *Factory*: {@link module:Layout.u8|u8}, {@link\n * module:Layout.u16|u16}, {@link module:Layout.u24|u24}, {@link\n * module:Layout.u32|u32}, {@link module:Layout.u40|u40}, {@link\n * module:Layout.u48|u48}\n *\n * @param {Number} span - initializer for {@link Layout#span|span}.\n * The parameter can range from 1 through 6.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass UInt extends Layout {\n constructor(span, property) {\n super(span, property);\n if (6 < this.span) {\n throw new RangeError('span must not exceed 6 bytes');\n }\n }\n /** @override */\n decode(b, offset = 0) {\n return uint8ArrayToBuffer(b).readUIntLE(offset, this.span);\n }\n /** @override */\n encode(src, b, offset = 0) {\n uint8ArrayToBuffer(b).writeUIntLE(src, offset, this.span);\n return this.span;\n }\n}\nexports.UInt = UInt;\n/**\n * Represent an unsigned integer in big-endian format.\n *\n * *Factory*: {@link module:Layout.u8be|u8be}, {@link\n * module:Layout.u16be|u16be}, {@link module:Layout.u24be|u24be},\n * {@link module:Layout.u32be|u32be}, {@link\n * module:Layout.u40be|u40be}, {@link module:Layout.u48be|u48be}\n *\n * @param {Number} span - initializer for {@link Layout#span|span}.\n * The parameter can range from 1 through 6.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass UIntBE extends Layout {\n constructor(span, property) {\n super(span, property);\n if (6 < this.span) {\n throw new RangeError('span must not exceed 6 bytes');\n }\n }\n /** @override */\n decode(b, offset = 0) {\n return uint8ArrayToBuffer(b).readUIntBE(offset, this.span);\n }\n /** @override */\n encode(src, b, offset = 0) {\n uint8ArrayToBuffer(b).writeUIntBE(src, offset, this.span);\n return this.span;\n }\n}\nexports.UIntBE = UIntBE;\n/**\n * Represent a signed integer in little-endian format.\n *\n * *Factory*: {@link module:Layout.s8|s8}, {@link\n * module:Layout.s16|s16}, {@link module:Layout.s24|s24}, {@link\n * module:Layout.s32|s32}, {@link module:Layout.s40|s40}, {@link\n * module:Layout.s48|s48}\n *\n * @param {Number} span - initializer for {@link Layout#span|span}.\n * The parameter can range from 1 through 6.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass Int extends Layout {\n constructor(span, property) {\n super(span, property);\n if (6 < this.span) {\n throw new RangeError('span must not exceed 6 bytes');\n }\n }\n /** @override */\n decode(b, offset = 0) {\n return uint8ArrayToBuffer(b).readIntLE(offset, this.span);\n }\n /** @override */\n encode(src, b, offset = 0) {\n uint8ArrayToBuffer(b).writeIntLE(src, offset, this.span);\n return this.span;\n }\n}\nexports.Int = Int;\n/**\n * Represent a signed integer in big-endian format.\n *\n * *Factory*: {@link module:Layout.s8be|s8be}, {@link\n * module:Layout.s16be|s16be}, {@link module:Layout.s24be|s24be},\n * {@link module:Layout.s32be|s32be}, {@link\n * module:Layout.s40be|s40be}, {@link module:Layout.s48be|s48be}\n *\n * @param {Number} span - initializer for {@link Layout#span|span}.\n * The parameter can range from 1 through 6.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass IntBE extends Layout {\n constructor(span, property) {\n super(span, property);\n if (6 < this.span) {\n throw new RangeError('span must not exceed 6 bytes');\n }\n }\n /** @override */\n decode(b, offset = 0) {\n return uint8ArrayToBuffer(b).readIntBE(offset, this.span);\n }\n /** @override */\n encode(src, b, offset = 0) {\n uint8ArrayToBuffer(b).writeIntBE(src, offset, this.span);\n return this.span;\n }\n}\nexports.IntBE = IntBE;\nconst V2E32 = Math.pow(2, 32);\n/* True modulus high and low 32-bit words, where low word is always\n * non-negative. */\nfunction divmodInt64(src) {\n const hi32 = Math.floor(src / V2E32);\n const lo32 = src - (hi32 * V2E32);\n return { hi32, lo32 };\n}\n/* Reconstruct Number from quotient and non-negative remainder */\nfunction roundedInt64(hi32, lo32) {\n return hi32 * V2E32 + lo32;\n}\n/**\n * Represent an unsigned 64-bit integer in little-endian format when\n * encoded and as a near integral JavaScript Number when decoded.\n *\n * *Factory*: {@link module:Layout.nu64|nu64}\n *\n * **NOTE** Values with magnitude greater than 2^52 may not decode to\n * the exact value of the encoded representation.\n *\n * @augments {Layout}\n */\nclass NearUInt64 extends Layout {\n constructor(property) {\n super(8, property);\n }\n /** @override */\n decode(b, offset = 0) {\n const buffer = uint8ArrayToBuffer(b);\n const lo32 = buffer.readUInt32LE(offset);\n const hi32 = buffer.readUInt32LE(offset + 4);\n return roundedInt64(hi32, lo32);\n }\n /** @override */\n encode(src, b, offset = 0) {\n const split = divmodInt64(src);\n const buffer = uint8ArrayToBuffer(b);\n buffer.writeUInt32LE(split.lo32, offset);\n buffer.writeUInt32LE(split.hi32, offset + 4);\n return 8;\n }\n}\nexports.NearUInt64 = NearUInt64;\n/**\n * Represent an unsigned 64-bit integer in big-endian format when\n * encoded and as a near integral JavaScript Number when decoded.\n *\n * *Factory*: {@link module:Layout.nu64be|nu64be}\n *\n * **NOTE** Values with magnitude greater than 2^52 may not decode to\n * the exact value of the encoded representation.\n *\n * @augments {Layout}\n */\nclass NearUInt64BE extends Layout {\n constructor(property) {\n super(8, property);\n }\n /** @override */\n decode(b, offset = 0) {\n const buffer = uint8ArrayToBuffer(b);\n const hi32 = buffer.readUInt32BE(offset);\n const lo32 = buffer.readUInt32BE(offset + 4);\n return roundedInt64(hi32, lo32);\n }\n /** @override */\n encode(src, b, offset = 0) {\n const split = divmodInt64(src);\n const buffer = uint8ArrayToBuffer(b);\n buffer.writeUInt32BE(split.hi32, offset);\n buffer.writeUInt32BE(split.lo32, offset + 4);\n return 8;\n }\n}\nexports.NearUInt64BE = NearUInt64BE;\n/**\n * Represent a signed 64-bit integer in little-endian format when\n * encoded and as a near integral JavaScript Number when decoded.\n *\n * *Factory*: {@link module:Layout.ns64|ns64}\n *\n * **NOTE** Values with magnitude greater than 2^52 may not decode to\n * the exact value of the encoded representation.\n *\n * @augments {Layout}\n */\nclass NearInt64 extends Layout {\n constructor(property) {\n super(8, property);\n }\n /** @override */\n decode(b, offset = 0) {\n const buffer = uint8ArrayToBuffer(b);\n const lo32 = buffer.readUInt32LE(offset);\n const hi32 = buffer.readInt32LE(offset + 4);\n return roundedInt64(hi32, lo32);\n }\n /** @override */\n encode(src, b, offset = 0) {\n const split = divmodInt64(src);\n const buffer = uint8ArrayToBuffer(b);\n buffer.writeUInt32LE(split.lo32, offset);\n buffer.writeInt32LE(split.hi32, offset + 4);\n return 8;\n }\n}\nexports.NearInt64 = NearInt64;\n/**\n * Represent a signed 64-bit integer in big-endian format when\n * encoded and as a near integral JavaScript Number when decoded.\n *\n * *Factory*: {@link module:Layout.ns64be|ns64be}\n *\n * **NOTE** Values with magnitude greater than 2^52 may not decode to\n * the exact value of the encoded representation.\n *\n * @augments {Layout}\n */\nclass NearInt64BE extends Layout {\n constructor(property) {\n super(8, property);\n }\n /** @override */\n decode(b, offset = 0) {\n const buffer = uint8ArrayToBuffer(b);\n const hi32 = buffer.readInt32BE(offset);\n const lo32 = buffer.readUInt32BE(offset + 4);\n return roundedInt64(hi32, lo32);\n }\n /** @override */\n encode(src, b, offset = 0) {\n const split = divmodInt64(src);\n const buffer = uint8ArrayToBuffer(b);\n buffer.writeInt32BE(split.hi32, offset);\n buffer.writeUInt32BE(split.lo32, offset + 4);\n return 8;\n }\n}\nexports.NearInt64BE = NearInt64BE;\n/**\n * Represent a 32-bit floating point number in little-endian format.\n *\n * *Factory*: {@link module:Layout.f32|f32}\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass Float extends Layout {\n constructor(property) {\n super(4, property);\n }\n /** @override */\n decode(b, offset = 0) {\n return uint8ArrayToBuffer(b).readFloatLE(offset);\n }\n /** @override */\n encode(src, b, offset = 0) {\n uint8ArrayToBuffer(b).writeFloatLE(src, offset);\n return 4;\n }\n}\nexports.Float = Float;\n/**\n * Represent a 32-bit floating point number in big-endian format.\n *\n * *Factory*: {@link module:Layout.f32be|f32be}\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass FloatBE extends Layout {\n constructor(property) {\n super(4, property);\n }\n /** @override */\n decode(b, offset = 0) {\n return uint8ArrayToBuffer(b).readFloatBE(offset);\n }\n /** @override */\n encode(src, b, offset = 0) {\n uint8ArrayToBuffer(b).writeFloatBE(src, offset);\n return 4;\n }\n}\nexports.FloatBE = FloatBE;\n/**\n * Represent a 64-bit floating point number in little-endian format.\n *\n * *Factory*: {@link module:Layout.f64|f64}\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass Double extends Layout {\n constructor(property) {\n super(8, property);\n }\n /** @override */\n decode(b, offset = 0) {\n return uint8ArrayToBuffer(b).readDoubleLE(offset);\n }\n /** @override */\n encode(src, b, offset = 0) {\n uint8ArrayToBuffer(b).writeDoubleLE(src, offset);\n return 8;\n }\n}\nexports.Double = Double;\n/**\n * Represent a 64-bit floating point number in big-endian format.\n *\n * *Factory*: {@link module:Layout.f64be|f64be}\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass DoubleBE extends Layout {\n constructor(property) {\n super(8, property);\n }\n /** @override */\n decode(b, offset = 0) {\n return uint8ArrayToBuffer(b).readDoubleBE(offset);\n }\n /** @override */\n encode(src, b, offset = 0) {\n uint8ArrayToBuffer(b).writeDoubleBE(src, offset);\n return 8;\n }\n}\nexports.DoubleBE = DoubleBE;\n/**\n * Represent a contiguous sequence of a specific layout as an Array.\n *\n * *Factory*: {@link module:Layout.seq|seq}\n *\n * @param {Layout} elementLayout - initializer for {@link\n * Sequence#elementLayout|elementLayout}.\n *\n * @param {(Number|ExternalLayout)} count - initializer for {@link\n * Sequence#count|count}. The parameter must be either a positive\n * integer or an instance of {@link ExternalLayout}.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass Sequence extends Layout {\n constructor(elementLayout, count, property) {\n if (!(elementLayout instanceof Layout)) {\n throw new TypeError('elementLayout must be a Layout');\n }\n if (!(((count instanceof ExternalLayout) && count.isCount())\n || (Number.isInteger(count) && (0 <= count)))) {\n throw new TypeError('count must be non-negative integer '\n + 'or an unsigned integer ExternalLayout');\n }\n let span = -1;\n if ((!(count instanceof ExternalLayout))\n && (0 < elementLayout.span)) {\n span = count * elementLayout.span;\n }\n super(span, property);\n /** The layout for individual elements of the sequence. */\n this.elementLayout = elementLayout;\n /** The number of elements in the sequence.\n *\n * This will be either a non-negative integer or an instance of\n * {@link ExternalLayout} for which {@link\n * ExternalLayout#isCount|isCount()} is `true`. */\n this.count = count;\n }\n /** @override */\n getSpan(b, offset = 0) {\n if (0 <= this.span) {\n return this.span;\n }\n let span = 0;\n let count = this.count;\n if (count instanceof ExternalLayout) {\n count = count.decode(b, offset);\n }\n if (0 < this.elementLayout.span) {\n span = count * this.elementLayout.span;\n }\n else {\n let idx = 0;\n while (idx < count) {\n span += this.elementLayout.getSpan(b, offset + span);\n ++idx;\n }\n }\n return span;\n }\n /** @override */\n decode(b, offset = 0) {\n const rv = [];\n let i = 0;\n let count = this.count;\n if (count instanceof ExternalLayout) {\n count = count.decode(b, offset);\n }\n while (i < count) {\n rv.push(this.elementLayout.decode(b, offset));\n offset += this.elementLayout.getSpan(b, offset);\n i += 1;\n }\n return rv;\n }\n /** Implement {@link Layout#encode|encode} for {@link Sequence}.\n *\n * **NOTE** If `src` is shorter than {@link Sequence#count|count} then\n * the unused space in the buffer is left unchanged. If `src` is\n * longer than {@link Sequence#count|count} the unneeded elements are\n * ignored.\n *\n * **NOTE** If {@link Layout#count|count} is an instance of {@link\n * ExternalLayout} then the length of `src` will be encoded as the\n * count after `src` is encoded. */\n encode(src, b, offset = 0) {\n const elo = this.elementLayout;\n const span = src.reduce((span, v) => {\n return span + elo.encode(v, b, offset + span);\n }, 0);\n if (this.count instanceof ExternalLayout) {\n this.count.encode(src.length, b, offset);\n }\n return span;\n }\n}\nexports.Sequence = Sequence;\n/**\n * Represent a contiguous sequence of arbitrary layout elements as an\n * Object.\n *\n * *Factory*: {@link module:Layout.struct|struct}\n *\n * **NOTE** The {@link Layout#span|span} of the structure is variable\n * if any layout in {@link Structure#fields|fields} has a variable\n * span. When {@link Layout#encode|encoding} we must have a value for\n * all variable-length fields, or we wouldn't be able to figure out\n * how much space to use for storage. We can only identify the value\n * for a field when it has a {@link Layout#property|property}. As\n * such, although a structure may contain both unnamed fields and\n * variable-length fields, it cannot contain an unnamed\n * variable-length field.\n *\n * @param {Layout[]} fields - initializer for {@link\n * Structure#fields|fields}. An error is raised if this contains a\n * variable-length field for which a {@link Layout#property|property}\n * is not defined.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @param {Boolean} [decodePrefixes] - initializer for {@link\n * Structure#decodePrefixes|property}.\n *\n * @throws {Error} - if `fields` contains an unnamed variable-length\n * layout.\n *\n * @augments {Layout}\n */\nclass Structure extends Layout {\n constructor(fields, property, decodePrefixes) {\n if (!(Array.isArray(fields)\n && fields.reduce((acc, v) => acc && (v instanceof Layout), true))) {\n throw new TypeError('fields must be array of Layout instances');\n }\n if (('boolean' === typeof property)\n && (undefined === decodePrefixes)) {\n decodePrefixes = property;\n property = undefined;\n }\n /* Verify absence of unnamed variable-length fields. */\n for (const fd of fields) {\n if ((0 > fd.span)\n && (undefined === fd.property)) {\n throw new Error('fields cannot contain unnamed variable-length layout');\n }\n }\n let span = -1;\n try {\n span = fields.reduce((span, fd) => span + fd.getSpan(), 0);\n }\n catch (e) {\n // ignore error\n }\n super(span, property);\n /** The sequence of {@link Layout} values that comprise the\n * structure.\n *\n * The individual elements need not be the same type, and may be\n * either scalar or aggregate layouts. If a member layout leaves\n * its {@link Layout#property|property} undefined the\n * corresponding region of the buffer associated with the element\n * will not be mutated.\n *\n * @type {Layout[]} */\n this.fields = fields;\n /** Control behavior of {@link Layout#decode|decode()} given short\n * buffers.\n *\n * In some situations a structure many be extended with additional\n * fields over time, with older installations providing only a\n * prefix of the full structure. If this property is `true`\n * decoding will accept those buffers and leave subsequent fields\n * undefined, as long as the buffer ends at a field boundary.\n * Defaults to `false`. */\n this.decodePrefixes = !!decodePrefixes;\n }\n /** @override */\n getSpan(b, offset = 0) {\n if (0 <= this.span) {\n return this.span;\n }\n let span = 0;\n try {\n span = this.fields.reduce((span, fd) => {\n const fsp = fd.getSpan(b, offset);\n offset += fsp;\n return span + fsp;\n }, 0);\n }\n catch (e) {\n throw new RangeError('indeterminate span');\n }\n return span;\n }\n /** @override */\n decode(b, offset = 0) {\n checkUint8Array(b);\n const dest = this.makeDestinationObject();\n for (const fd of this.fields) {\n if (undefined !== fd.property) {\n dest[fd.property] = fd.decode(b, offset);\n }\n offset += fd.getSpan(b, offset);\n if (this.decodePrefixes\n && (b.length === offset)) {\n break;\n }\n }\n return dest;\n }\n /** Implement {@link Layout#encode|encode} for {@link Structure}.\n *\n * If `src` is missing a property for a member with a defined {@link\n * Layout#property|property} the corresponding region of the buffer is\n * left unmodified. */\n encode(src, b, offset = 0) {\n const firstOffset = offset;\n let lastOffset = 0;\n let lastWrote = 0;\n for (const fd of this.fields) {\n let span = fd.span;\n lastWrote = (0 < span) ? span : 0;\n if (undefined !== fd.property) {\n const fv = src[fd.property];\n if (undefined !== fv) {\n lastWrote = fd.encode(fv, b, offset);\n if (0 > span) {\n /* Read the as-encoded span, which is not necessarily the\n * same as what we wrote. */\n span = fd.getSpan(b, offset);\n }\n }\n }\n lastOffset = offset;\n offset += span;\n }\n /* Use (lastOffset + lastWrote) instead of offset because the last\n * item may have had a dynamic length and we don't want to include\n * the padding between it and the end of the space reserved for\n * it. */\n return (lastOffset + lastWrote) - firstOffset;\n }\n /** @override */\n fromArray(values) {\n const dest = this.makeDestinationObject();\n for (const fd of this.fields) {\n if ((undefined !== fd.property)\n && (0 < values.length)) {\n dest[fd.property] = values.shift();\n }\n }\n return dest;\n }\n /**\n * Get access to the layout of a given property.\n *\n * @param {String} property - the structure member of interest.\n *\n * @return {Layout} - the layout associated with `property`, or\n * undefined if there is no such property.\n */\n layoutFor(property) {\n if ('string' !== typeof property) {\n throw new TypeError('property must be string');\n }\n for (const fd of this.fields) {\n if (fd.property === property) {\n return fd;\n }\n }\n return undefined;\n }\n /**\n * Get the offset of a structure member.\n *\n * @param {String} property - the structure member of interest.\n *\n * @return {Number} - the offset in bytes to the start of `property`\n * within the structure, or undefined if `property` is not a field\n * within the structure. If the property is a member but follows a\n * variable-length structure member a negative number will be\n * returned.\n */\n offsetOf(property) {\n if ('string' !== typeof property) {\n throw new TypeError('property must be string');\n }\n let offset = 0;\n for (const fd of this.fields) {\n if (fd.property === property) {\n return offset;\n }\n if (0 > fd.span) {\n offset = -1;\n }\n else if (0 <= offset) {\n offset += fd.span;\n }\n }\n return undefined;\n }\n}\nexports.Structure = Structure;\n/**\n * An object that can provide a {@link\n * Union#discriminator|discriminator} API for {@link Union}.\n *\n * **NOTE** This is an abstract base class; you can create instances\n * if it amuses you, but they won't support the {@link\n * UnionDiscriminator#encode|encode} or {@link\n * UnionDiscriminator#decode|decode} functions.\n *\n * @param {string} [property] - Default for {@link\n * UnionDiscriminator#property|property}.\n *\n * @abstract\n */\nclass UnionDiscriminator {\n constructor(property) {\n /** The {@link Layout#property|property} to be used when the\n * discriminator is referenced in isolation (generally when {@link\n * Union#decode|Union decode} cannot delegate to a specific\n * variant). */\n this.property = property;\n }\n /** Analog to {@link Layout#decode|Layout decode} for union discriminators.\n *\n * The implementation of this method need not reference the buffer if\n * variant information is available through other means. */\n decode(b, offset) {\n throw new Error('UnionDiscriminator is abstract');\n }\n /** Analog to {@link Layout#decode|Layout encode} for union discriminators.\n *\n * The implementation of this method need not store the value if\n * variant information is maintained through other means. */\n encode(src, b, offset) {\n throw new Error('UnionDiscriminator is abstract');\n }\n}\nexports.UnionDiscriminator = UnionDiscriminator;\n/**\n * An object that can provide a {@link\n * UnionDiscriminator|discriminator API} for {@link Union} using an\n * unsigned integral {@link Layout} instance located either inside or\n * outside the union.\n *\n * @param {ExternalLayout} layout - initializes {@link\n * UnionLayoutDiscriminator#layout|layout}. Must satisfy {@link\n * ExternalLayout#isCount|isCount()}.\n *\n * @param {string} [property] - Default for {@link\n * UnionDiscriminator#property|property}, superseding the property\n * from `layout`, but defaulting to `variant` if neither `property`\n * nor layout provide a property name.\n *\n * @augments {UnionDiscriminator}\n */\nclass UnionLayoutDiscriminator extends UnionDiscriminator {\n constructor(layout, property) {\n if (!((layout instanceof ExternalLayout)\n && layout.isCount())) {\n throw new TypeError('layout must be an unsigned integer ExternalLayout');\n }\n super(property || layout.property || 'variant');\n /** The {@link ExternalLayout} used to access the discriminator\n * value. */\n this.layout = layout;\n }\n /** Delegate decoding to {@link UnionLayoutDiscriminator#layout|layout}. */\n decode(b, offset) {\n return this.layout.decode(b, offset);\n }\n /** Delegate encoding to {@link UnionLayoutDiscriminator#layout|layout}. */\n encode(src, b, offset) {\n return this.layout.encode(src, b, offset);\n }\n}\nexports.UnionLayoutDiscriminator = UnionLayoutDiscriminator;\n/**\n * Represent any number of span-compatible layouts.\n *\n * *Factory*: {@link module:Layout.union|union}\n *\n * If the union has a {@link Union#defaultLayout|default layout} that\n * layout must have a non-negative {@link Layout#span|span}. The span\n * of a fixed-span union includes its {@link\n * Union#discriminator|discriminator} if the variant is a {@link\n * Union#usesPrefixDiscriminator|prefix of the union}, plus the span\n * of its {@link Union#defaultLayout|default layout}.\n *\n * If the union does not have a default layout then the encoded span\n * of the union depends on the encoded span of its variant (which may\n * be fixed or variable).\n *\n * {@link VariantLayout#layout|Variant layout}s are added through\n * {@link Union#addVariant|addVariant}. If the union has a default\n * layout, the span of the {@link VariantLayout#layout|layout\n * contained by the variant} must not exceed the span of the {@link\n * Union#defaultLayout|default layout} (minus the span of a {@link\n * Union#usesPrefixDiscriminator|prefix disriminator}, if used). The\n * span of the variant will equal the span of the union itself.\n *\n * The variant for a buffer can only be identified from the {@link\n * Union#discriminator|discriminator} {@link\n * UnionDiscriminator#property|property} (in the case of the {@link\n * Union#defaultLayout|default layout}), or by using {@link\n * Union#getVariant|getVariant} and examining the resulting {@link\n * VariantLayout} instance.\n *\n * A variant compatible with a JavaScript object can be identified\n * using {@link Union#getSourceVariant|getSourceVariant}.\n *\n * @param {(UnionDiscriminator|ExternalLayout|Layout)} discr - How to\n * identify the layout used to interpret the union contents. The\n * parameter must be an instance of {@link UnionDiscriminator}, an\n * {@link ExternalLayout} that satisfies {@link\n * ExternalLayout#isCount|isCount()}, or {@link UInt} (or {@link\n * UIntBE}). When a non-external layout element is passed the layout\n * appears at the start of the union. In all cases the (synthesized)\n * {@link UnionDiscriminator} instance is recorded as {@link\n * Union#discriminator|discriminator}.\n *\n * @param {(Layout|null)} defaultLayout - initializer for {@link\n * Union#defaultLayout|defaultLayout}. If absent defaults to `null`.\n * If `null` there is no default layout: the union has data-dependent\n * length and attempts to decode or encode unrecognized variants will\n * throw an exception. A {@link Layout} instance must have a\n * non-negative {@link Layout#span|span}, and if it lacks a {@link\n * Layout#property|property} the {@link\n * Union#defaultLayout|defaultLayout} will be a {@link\n * Layout#replicate|replica} with property `content`.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass Union extends Layout {\n constructor(discr, defaultLayout, property) {\n let discriminator;\n if ((discr instanceof UInt)\n || (discr instanceof UIntBE)) {\n discriminator = new UnionLayoutDiscriminator(new OffsetLayout(discr));\n }\n else if ((discr instanceof ExternalLayout)\n && discr.isCount()) {\n discriminator = new UnionLayoutDiscriminator(discr);\n }\n else if (!(discr instanceof UnionDiscriminator)) {\n throw new TypeError('discr must be a UnionDiscriminator '\n + 'or an unsigned integer layout');\n }\n else {\n discriminator = discr;\n }\n if (undefined === defaultLayout) {\n defaultLayout = null;\n }\n if (!((null === defaultLayout)\n || (defaultLayout instanceof Layout))) {\n throw new TypeError('defaultLayout must be null or a Layout');\n }\n if (null !== defaultLayout) {\n if (0 > defaultLayout.span) {\n throw new Error('defaultLayout must have constant span');\n }\n if (undefined === defaultLayout.property) {\n defaultLayout = defaultLayout.replicate('content');\n }\n }\n /* The union span can be estimated only if there's a default\n * layout. The union spans its default layout, plus any prefix\n * variant layout. By construction both layouts, if present, have\n * non-negative span. */\n let span = -1;\n if (defaultLayout) {\n span = defaultLayout.span;\n if ((0 <= span) && ((discr instanceof UInt)\n || (discr instanceof UIntBE))) {\n span += discriminator.layout.span;\n }\n }\n super(span, property);\n /** The interface for the discriminator value in isolation.\n *\n * This a {@link UnionDiscriminator} either passed to the\n * constructor or synthesized from the `discr` constructor\n * argument. {@link\n * Union#usesPrefixDiscriminator|usesPrefixDiscriminator} will be\n * `true` iff the `discr` parameter was a non-offset {@link\n * Layout} instance. */\n this.discriminator = discriminator;\n /** `true` if the {@link Union#discriminator|discriminator} is the\n * first field in the union.\n *\n * If `false` the discriminator is obtained from somewhere\n * else. */\n this.usesPrefixDiscriminator = (discr instanceof UInt)\n || (discr instanceof UIntBE);\n /** The layout for non-discriminator content when the value of the\n * discriminator is not recognized.\n *\n * This is the value passed to the constructor. It is\n * structurally equivalent to the second component of {@link\n * Union#layout|layout} but may have a different property\n * name. */\n this.defaultLayout = defaultLayout;\n /** A registry of allowed variants.\n *\n * The keys are unsigned integers which should be compatible with\n * {@link Union.discriminator|discriminator}. The property value\n * is the corresponding {@link VariantLayout} instances assigned\n * to this union by {@link Union#addVariant|addVariant}.\n *\n * **NOTE** The registry remains mutable so that variants can be\n * {@link Union#addVariant|added} at any time. Users should not\n * manipulate the content of this property. */\n this.registry = {};\n /* Private variable used when invoking getSourceVariant */\n let boundGetSourceVariant = this.defaultGetSourceVariant.bind(this);\n /** Function to infer the variant selected by a source object.\n *\n * Defaults to {@link\n * Union#defaultGetSourceVariant|defaultGetSourceVariant} but may\n * be overridden using {@link\n * Union#configGetSourceVariant|configGetSourceVariant}.\n *\n * @param {Object} src - as with {@link\n * Union#defaultGetSourceVariant|defaultGetSourceVariant}.\n *\n * @returns {(undefined|VariantLayout)} The default variant\n * (`undefined`) or first registered variant that uses a property\n * available in `src`. */\n this.getSourceVariant = function (src) {\n return boundGetSourceVariant(src);\n };\n /** Function to override the implementation of {@link\n * Union#getSourceVariant|getSourceVariant}.\n *\n * Use this if the desired variant cannot be identified using the\n * algorithm of {@link\n * Union#defaultGetSourceVariant|defaultGetSourceVariant}.\n *\n * **NOTE** The provided function will be invoked bound to this\n * Union instance, providing local access to {@link\n * Union#registry|registry}.\n *\n * @param {Function} gsv - a function that follows the API of\n * {@link Union#defaultGetSourceVariant|defaultGetSourceVariant}. */\n this.configGetSourceVariant = function (gsv) {\n boundGetSourceVariant = gsv.bind(this);\n };\n }\n /** @override */\n getSpan(b, offset = 0) {\n if (0 <= this.span) {\n return this.span;\n }\n /* Default layouts always have non-negative span, so we don't have\n * one and we have to recognize the variant which will in turn\n * determine the span. */\n const vlo = this.getVariant(b, offset);\n if (!vlo) {\n throw new Error('unable to determine span for unrecognized variant');\n }\n return vlo.getSpan(b, offset);\n }\n /**\n * Method to infer a registered Union variant compatible with `src`.\n *\n * The first satisfied rule in the following sequence defines the\n * return value:\n * * If `src` has properties matching the Union discriminator and\n * the default layout, `undefined` is returned regardless of the\n * value of the discriminator property (this ensures the default\n * layout will be used);\n * * If `src` has a property matching the Union discriminator, the\n * value of the discriminator identifies a registered variant, and\n * either (a) the variant has no layout, or (b) `src` has the\n * variant's property, then the variant is returned (because the\n * source satisfies the constraints of the variant it identifies);\n * * If `src` does not have a property matching the Union\n * discriminator, but does have a property matching a registered\n * variant, then the variant is returned (because the source\n * matches a variant without an explicit conflict);\n * * An error is thrown (because we either can't identify a variant,\n * or we were explicitly told the variant but can't satisfy it).\n *\n * @param {Object} src - an object presumed to be compatible with\n * the content of the Union.\n *\n * @return {(undefined|VariantLayout)} - as described above.\n *\n * @throws {Error} - if `src` cannot be associated with a default or\n * registered variant.\n */\n defaultGetSourceVariant(src) {\n if (Object.prototype.hasOwnProperty.call(src, this.discriminator.property)) {\n if (this.defaultLayout && this.defaultLayout.property\n && Object.prototype.hasOwnProperty.call(src, this.defaultLayout.property)) {\n return undefined;\n }\n const vlo = this.registry[src[this.discriminator.property]];\n if (vlo\n && ((!vlo.layout)\n || (vlo.property && Object.prototype.hasOwnProperty.call(src, vlo.property)))) {\n return vlo;\n }\n }\n else {\n for (const tag in this.registry) {\n const vlo = this.registry[tag];\n if (vlo.property && Object.prototype.hasOwnProperty.call(src, vlo.property)) {\n return vlo;\n }\n }\n }\n throw new Error('unable to infer src variant');\n }\n /** Implement {@link Layout#decode|decode} for {@link Union}.\n *\n * If the variant is {@link Union#addVariant|registered} the return\n * value is an instance of that variant, with no explicit\n * discriminator. Otherwise the {@link Union#defaultLayout|default\n * layout} is used to decode the content. */\n decode(b, offset = 0) {\n let dest;\n const dlo = this.discriminator;\n const discr = dlo.decode(b, offset);\n const clo = this.registry[discr];\n if (undefined === clo) {\n const defaultLayout = this.defaultLayout;\n let contentOffset = 0;\n if (this.usesPrefixDiscriminator) {\n contentOffset = dlo.layout.span;\n }\n dest = this.makeDestinationObject();\n dest[dlo.property] = discr;\n // defaultLayout.property can be undefined, but this is allowed by buffer-layout\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n dest[defaultLayout.property] = defaultLayout.decode(b, offset + contentOffset);\n }\n else {\n dest = clo.decode(b, offset);\n }\n return dest;\n }\n /** Implement {@link Layout#encode|encode} for {@link Union}.\n *\n * This API assumes the `src` object is consistent with the union's\n * {@link Union#defaultLayout|default layout}. To encode variants\n * use the appropriate variant-specific {@link VariantLayout#encode}\n * method. */\n encode(src, b, offset = 0) {\n const vlo = this.getSourceVariant(src);\n if (undefined === vlo) {\n const dlo = this.discriminator;\n // this.defaultLayout is not undefined when vlo is undefined\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const clo = this.defaultLayout;\n let contentOffset = 0;\n if (this.usesPrefixDiscriminator) {\n contentOffset = dlo.layout.span;\n }\n dlo.encode(src[dlo.property], b, offset);\n // clo.property is not undefined when vlo is undefined\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return contentOffset + clo.encode(src[clo.property], b, offset + contentOffset);\n }\n return vlo.encode(src, b, offset);\n }\n /** Register a new variant structure within a union. The newly\n * created variant is returned.\n *\n * @param {Number} variant - initializer for {@link\n * VariantLayout#variant|variant}.\n *\n * @param {Layout} layout - initializer for {@link\n * VariantLayout#layout|layout}.\n *\n * @param {String} property - initializer for {@link\n * Layout#property|property}.\n *\n * @return {VariantLayout} */\n addVariant(variant, layout, property) {\n const rv = new VariantLayout(this, variant, layout, property);\n this.registry[variant] = rv;\n return rv;\n }\n /**\n * Get the layout associated with a registered variant.\n *\n * If `vb` does not produce a registered variant the function returns\n * `undefined`.\n *\n * @param {(Number|Uint8Array)} vb - either the variant number, or a\n * buffer from which the discriminator is to be read.\n *\n * @param {Number} offset - offset into `vb` for the start of the\n * union. Used only when `vb` is an instance of {Uint8Array}.\n *\n * @return {({VariantLayout}|undefined)}\n */\n getVariant(vb, offset = 0) {\n let variant;\n if (vb instanceof Uint8Array) {\n variant = this.discriminator.decode(vb, offset);\n }\n else {\n variant = vb;\n }\n return this.registry[variant];\n }\n}\nexports.Union = Union;\n/**\n * Represent a specific variant within a containing union.\n *\n * **NOTE** The {@link Layout#span|span} of the variant may include\n * the span of the {@link Union#discriminator|discriminator} used to\n * identify it, but values read and written using the variant strictly\n * conform to the content of {@link VariantLayout#layout|layout}.\n *\n * **NOTE** User code should not invoke this constructor directly. Use\n * the union {@link Union#addVariant|addVariant} helper method.\n *\n * @param {Union} union - initializer for {@link\n * VariantLayout#union|union}.\n *\n * @param {Number} variant - initializer for {@link\n * VariantLayout#variant|variant}.\n *\n * @param {Layout} [layout] - initializer for {@link\n * VariantLayout#layout|layout}. If absent the variant carries no\n * data.\n *\n * @param {String} [property] - initializer for {@link\n * Layout#property|property}. Unlike many other layouts, variant\n * layouts normally include a property name so they can be identified\n * within their containing {@link Union}. The property identifier may\n * be absent only if `layout` is is absent.\n *\n * @augments {Layout}\n */\nclass VariantLayout extends Layout {\n constructor(union, variant, layout, property) {\n if (!(union instanceof Union)) {\n throw new TypeError('union must be a Union');\n }\n if ((!Number.isInteger(variant)) || (0 > variant)) {\n throw new TypeError('variant must be a (non-negative) integer');\n }\n if (('string' === typeof layout)\n && (undefined === property)) {\n property = layout;\n layout = null;\n }\n if (layout) {\n if (!(layout instanceof Layout)) {\n throw new TypeError('layout must be a Layout');\n }\n if ((null !== union.defaultLayout)\n && (0 <= layout.span)\n && (layout.span > union.defaultLayout.span)) {\n throw new Error('variant span exceeds span of containing union');\n }\n if ('string' !== typeof property) {\n throw new TypeError('variant must have a String property');\n }\n }\n let span = union.span;\n if (0 > union.span) {\n span = layout ? layout.span : 0;\n if ((0 <= span) && union.usesPrefixDiscriminator) {\n span += union.discriminator.layout.span;\n }\n }\n super(span, property);\n /** The {@link Union} to which this variant belongs. */\n this.union = union;\n /** The unsigned integral value identifying this variant within\n * the {@link Union#discriminator|discriminator} of the containing\n * union. */\n this.variant = variant;\n /** The {@link Layout} to be used when reading/writing the\n * non-discriminator part of the {@link\n * VariantLayout#union|union}. If `null` the variant carries no\n * data. */\n this.layout = layout || null;\n }\n /** @override */\n getSpan(b, offset = 0) {\n if (0 <= this.span) {\n /* Will be equal to the containing union span if that is not\n * variable. */\n return this.span;\n }\n let contentOffset = 0;\n if (this.union.usesPrefixDiscriminator) {\n contentOffset = this.union.discriminator.layout.span;\n }\n /* Span is defined solely by the variant (and prefix discriminator) */\n let span = 0;\n if (this.layout) {\n span = this.layout.getSpan(b, offset + contentOffset);\n }\n return contentOffset + span;\n }\n /** @override */\n decode(b, offset = 0) {\n const dest = this.makeDestinationObject();\n if (this !== this.union.getVariant(b, offset)) {\n throw new Error('variant mismatch');\n }\n let contentOffset = 0;\n if (this.union.usesPrefixDiscriminator) {\n contentOffset = this.union.discriminator.layout.span;\n }\n if (this.layout) {\n dest[this.property] = this.layout.decode(b, offset + contentOffset);\n }\n else if (this.property) {\n dest[this.property] = true;\n }\n else if (this.union.usesPrefixDiscriminator) {\n dest[this.union.discriminator.property] = this.variant;\n }\n return dest;\n }\n /** @override */\n encode(src, b, offset = 0) {\n let contentOffset = 0;\n if (this.union.usesPrefixDiscriminator) {\n contentOffset = this.union.discriminator.layout.span;\n }\n if (this.layout\n && (!Object.prototype.hasOwnProperty.call(src, this.property))) {\n throw new TypeError('variant lacks property ' + this.property);\n }\n this.union.discriminator.encode(this.variant, b, offset);\n let span = contentOffset;\n if (this.layout) {\n this.layout.encode(src[this.property], b, offset + contentOffset);\n span += this.layout.getSpan(b, offset + contentOffset);\n if ((0 <= this.union.span)\n && (span > this.union.span)) {\n throw new Error('encoded variant overruns containing union');\n }\n }\n return span;\n }\n /** Delegate {@link Layout#fromArray|fromArray} to {@link\n * VariantLayout#layout|layout}. */\n fromArray(values) {\n if (this.layout) {\n return this.layout.fromArray(values);\n }\n return undefined;\n }\n}\nexports.VariantLayout = VariantLayout;\n/** JavaScript chose to define bitwise operations as operating on\n * signed 32-bit values in 2's complement form, meaning any integer\n * with bit 31 set is going to look negative. For right shifts that's\n * not a problem, because `>>>` is a logical shift, but for every\n * other bitwise operator we have to compensate for possible negative\n * results. */\nfunction fixBitwiseResult(v) {\n if (0 > v) {\n v += 0x100000000;\n }\n return v;\n}\n/**\n * Contain a sequence of bit fields as an unsigned integer.\n *\n * *Factory*: {@link module:Layout.bits|bits}\n *\n * This is a container element; within it there are {@link BitField}\n * instances that provide the extracted properties. The container\n * simply defines the aggregate representation and its bit ordering.\n * The representation is an object containing properties with numeric\n * or {@link Boolean} values.\n *\n * {@link BitField}s are added with the {@link\n * BitStructure#addField|addField} and {@link\n * BitStructure#addBoolean|addBoolean} methods.\n\n * @param {Layout} word - initializer for {@link\n * BitStructure#word|word}. The parameter must be an instance of\n * {@link UInt} (or {@link UIntBE}) that is no more than 4 bytes wide.\n *\n * @param {bool} [msb] - `true` if the bit numbering starts at the\n * most significant bit of the containing word; `false` (default) if\n * it starts at the least significant bit of the containing word. If\n * the parameter at this position is a string and `property` is\n * `undefined` the value of this argument will instead be used as the\n * value of `property`.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass BitStructure extends Layout {\n constructor(word, msb, property) {\n if (!((word instanceof UInt)\n || (word instanceof UIntBE))) {\n throw new TypeError('word must be a UInt or UIntBE layout');\n }\n if (('string' === typeof msb)\n && (undefined === property)) {\n property = msb;\n msb = false;\n }\n if (4 < word.span) {\n throw new RangeError('word cannot exceed 32 bits');\n }\n super(word.span, property);\n /** The layout used for the packed value. {@link BitField}\n * instances are packed sequentially depending on {@link\n * BitStructure#msb|msb}. */\n this.word = word;\n /** Whether the bit sequences are packed starting at the most\n * significant bit growing down (`true`), or the least significant\n * bit growing up (`false`).\n *\n * **NOTE** Regardless of this value, the least significant bit of\n * any {@link BitField} value is the least significant bit of the\n * corresponding section of the packed value. */\n this.msb = !!msb;\n /** The sequence of {@link BitField} layouts that comprise the\n * packed structure.\n *\n * **NOTE** The array remains mutable to allow fields to be {@link\n * BitStructure#addField|added} after construction. Users should\n * not manipulate the content of this property.*/\n this.fields = [];\n /* Storage for the value. Capture a variable instead of using an\n * instance property because we don't want anything to change the\n * value without going through the mutator. */\n let value = 0;\n this._packedSetValue = function (v) {\n value = fixBitwiseResult(v);\n return this;\n };\n this._packedGetValue = function () {\n return value;\n };\n }\n /** @override */\n decode(b, offset = 0) {\n const dest = this.makeDestinationObject();\n const value = this.word.decode(b, offset);\n this._packedSetValue(value);\n for (const fd of this.fields) {\n if (undefined !== fd.property) {\n dest[fd.property] = fd.decode(b);\n }\n }\n return dest;\n }\n /** Implement {@link Layout#encode|encode} for {@link BitStructure}.\n *\n * If `src` is missing a property for a member with a defined {@link\n * Layout#property|property} the corresponding region of the packed\n * value is left unmodified. Unused bits are also left unmodified. */\n encode(src, b, offset = 0) {\n const value = this.word.decode(b, offset);\n this._packedSetValue(value);\n for (const fd of this.fields) {\n if (undefined !== fd.property) {\n const fv = src[fd.property];\n if (undefined !== fv) {\n fd.encode(fv);\n }\n }\n }\n return this.word.encode(this._packedGetValue(), b, offset);\n }\n /** Register a new bitfield with a containing bit structure. The\n * resulting bitfield is returned.\n *\n * @param {Number} bits - initializer for {@link BitField#bits|bits}.\n *\n * @param {string} property - initializer for {@link\n * Layout#property|property}.\n *\n * @return {BitField} */\n addField(bits, property) {\n const bf = new BitField(this, bits, property);\n this.fields.push(bf);\n return bf;\n }\n /** As with {@link BitStructure#addField|addField} for single-bit\n * fields with `boolean` value representation.\n *\n * @param {string} property - initializer for {@link\n * Layout#property|property}.\n *\n * @return {Boolean} */\n // `Boolean` conflicts with the native primitive type\n // eslint-disable-next-line @typescript-eslint/ban-types\n addBoolean(property) {\n // This is my Boolean, not the Javascript one.\n const bf = new Boolean(this, property);\n this.fields.push(bf);\n return bf;\n }\n /**\n * Get access to the bit field for a given property.\n *\n * @param {String} property - the bit field of interest.\n *\n * @return {BitField} - the field associated with `property`, or\n * undefined if there is no such property.\n */\n fieldFor(property) {\n if ('string' !== typeof property) {\n throw new TypeError('property must be string');\n }\n for (const fd of this.fields) {\n if (fd.property === property) {\n return fd;\n }\n }\n return undefined;\n }\n}\nexports.BitStructure = BitStructure;\n/**\n * Represent a sequence of bits within a {@link BitStructure}.\n *\n * All bit field values are represented as unsigned integers.\n *\n * **NOTE** User code should not invoke this constructor directly.\n * Use the container {@link BitStructure#addField|addField} helper\n * method.\n *\n * **NOTE** BitField instances are not instances of {@link Layout}\n * since {@link Layout#span|span} measures 8-bit units.\n *\n * @param {BitStructure} container - initializer for {@link\n * BitField#container|container}.\n *\n * @param {Number} bits - initializer for {@link BitField#bits|bits}.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n */\nclass BitField {\n constructor(container, bits, property) {\n if (!(container instanceof BitStructure)) {\n throw new TypeError('container must be a BitStructure');\n }\n if ((!Number.isInteger(bits)) || (0 >= bits)) {\n throw new TypeError('bits must be positive integer');\n }\n const totalBits = 8 * container.span;\n const usedBits = container.fields.reduce((sum, fd) => sum + fd.bits, 0);\n if ((bits + usedBits) > totalBits) {\n throw new Error('bits too long for span remainder ('\n + (totalBits - usedBits) + ' of '\n + totalBits + ' remain)');\n }\n /** The {@link BitStructure} instance to which this bit field\n * belongs. */\n this.container = container;\n /** The span of this value in bits. */\n this.bits = bits;\n /** A mask of {@link BitField#bits|bits} bits isolating value bits\n * that fit within the field.\n *\n * That is, it masks a value that has not yet been shifted into\n * position within its containing packed integer. */\n this.valueMask = (1 << bits) - 1;\n if (32 === bits) { // shifted value out of range\n this.valueMask = 0xFFFFFFFF;\n }\n /** The offset of the value within the containing packed unsigned\n * integer. The least significant bit of the packed value is at\n * offset zero, regardless of bit ordering used. */\n this.start = usedBits;\n if (this.container.msb) {\n this.start = totalBits - usedBits - bits;\n }\n /** A mask of {@link BitField#bits|bits} isolating the field value\n * within the containing packed unsigned integer. */\n this.wordMask = fixBitwiseResult(this.valueMask << this.start);\n /** The property name used when this bitfield is represented in an\n * Object.\n *\n * Intended to be functionally equivalent to {@link\n * Layout#property}.\n *\n * If left undefined the corresponding span of bits will be\n * treated as padding: it will not be mutated by {@link\n * Layout#encode|encode} nor represented as a property in the\n * decoded Object. */\n this.property = property;\n }\n /** Store a value into the corresponding subsequence of the containing\n * bit field. */\n decode(b, offset) {\n const word = this.container._packedGetValue();\n const wordValue = fixBitwiseResult(word & this.wordMask);\n const value = wordValue >>> this.start;\n return value;\n }\n /** Store a value into the corresponding subsequence of the containing\n * bit field.\n *\n * **NOTE** This is not a specialization of {@link\n * Layout#encode|Layout.encode} and there is no return value. */\n encode(value) {\n if ('number' !== typeof value\n || !Number.isInteger(value)\n || (value !== fixBitwiseResult(value & this.valueMask))) {\n throw new TypeError(nameWithProperty('BitField.encode', this)\n + ' value must be integer not exceeding ' + this.valueMask);\n }\n const word = this.container._packedGetValue();\n const wordValue = fixBitwiseResult(value << this.start);\n this.container._packedSetValue(fixBitwiseResult(word & ~this.wordMask)\n | wordValue);\n }\n}\nexports.BitField = BitField;\n/**\n * Represent a single bit within a {@link BitStructure} as a\n * JavaScript boolean.\n *\n * **NOTE** User code should not invoke this constructor directly.\n * Use the container {@link BitStructure#addBoolean|addBoolean} helper\n * method.\n *\n * @param {BitStructure} container - initializer for {@link\n * BitField#container|container}.\n *\n * @param {string} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {BitField}\n */\n/* eslint-disable no-extend-native */\nclass Boolean extends BitField {\n constructor(container, property) {\n super(container, 1, property);\n }\n /** Override {@link BitField#decode|decode} for {@link Boolean|Boolean}.\n *\n * @returns {boolean} */\n decode(b, offset) {\n return !!super.decode(b, offset);\n }\n /** @override */\n encode(value) {\n if ('boolean' === typeof value) {\n // BitField requires integer values\n value = +value;\n }\n super.encode(value);\n }\n}\nexports.Boolean = Boolean;\n/* eslint-enable no-extend-native */\n/**\n * Contain a fixed-length block of arbitrary data, represented as a\n * Uint8Array.\n *\n * *Factory*: {@link module:Layout.blob|blob}\n *\n * @param {(Number|ExternalLayout)} length - initializes {@link\n * Blob#length|length}.\n *\n * @param {String} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass Blob extends Layout {\n constructor(length, property) {\n if (!(((length instanceof ExternalLayout) && length.isCount())\n || (Number.isInteger(length) && (0 <= length)))) {\n throw new TypeError('length must be positive integer '\n + 'or an unsigned integer ExternalLayout');\n }\n let span = -1;\n if (!(length instanceof ExternalLayout)) {\n span = length;\n }\n super(span, property);\n /** The number of bytes in the blob.\n *\n * This may be a non-negative integer, or an instance of {@link\n * ExternalLayout} that satisfies {@link\n * ExternalLayout#isCount|isCount()}. */\n this.length = length;\n }\n /** @override */\n getSpan(b, offset) {\n let span = this.span;\n if (0 > span) {\n span = this.length.decode(b, offset);\n }\n return span;\n }\n /** @override */\n decode(b, offset = 0) {\n let span = this.span;\n if (0 > span) {\n span = this.length.decode(b, offset);\n }\n return uint8ArrayToBuffer(b).slice(offset, offset + span);\n }\n /** Implement {@link Layout#encode|encode} for {@link Blob}.\n *\n * **NOTE** If {@link Layout#count|count} is an instance of {@link\n * ExternalLayout} then the length of `src` will be encoded as the\n * count after `src` is encoded. */\n encode(src, b, offset) {\n let span = this.length;\n if (this.length instanceof ExternalLayout) {\n span = src.length;\n }\n if (!(src instanceof Uint8Array && span === src.length)) {\n throw new TypeError(nameWithProperty('Blob.encode', this)\n + ' requires (length ' + span + ') Uint8Array as src');\n }\n if ((offset + span) > b.length) {\n throw new RangeError('encoding overruns Uint8Array');\n }\n const srcBuffer = uint8ArrayToBuffer(src);\n uint8ArrayToBuffer(b).write(srcBuffer.toString('hex'), offset, span, 'hex');\n if (this.length instanceof ExternalLayout) {\n this.length.encode(span, b, offset);\n }\n return span;\n }\n}\nexports.Blob = Blob;\n/**\n * Contain a `NUL`-terminated UTF8 string.\n *\n * *Factory*: {@link module:Layout.cstr|cstr}\n *\n * **NOTE** Any UTF8 string that incorporates a zero-valued byte will\n * not be correctly decoded by this layout.\n *\n * @param {String} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass CString extends Layout {\n constructor(property) {\n super(-1, property);\n }\n /** @override */\n getSpan(b, offset = 0) {\n checkUint8Array(b);\n let idx = offset;\n while ((idx < b.length) && (0 !== b[idx])) {\n idx += 1;\n }\n return 1 + idx - offset;\n }\n /** @override */\n decode(b, offset = 0) {\n const span = this.getSpan(b, offset);\n return uint8ArrayToBuffer(b).slice(offset, offset + span - 1).toString('utf-8');\n }\n /** @override */\n encode(src, b, offset = 0) {\n /* Must force this to a string, lest it be a number and the\n * \"utf8-encoding\" below actually allocate a buffer of length\n * src */\n if ('string' !== typeof src) {\n src = String(src);\n }\n const srcb = buffer_1.Buffer.from(src, 'utf8');\n const span = srcb.length;\n if ((offset + span) > b.length) {\n throw new RangeError('encoding overruns Buffer');\n }\n const buffer = uint8ArrayToBuffer(b);\n srcb.copy(buffer, offset);\n buffer[offset + span] = 0;\n return span + 1;\n }\n}\nexports.CString = CString;\n/**\n * Contain a UTF8 string with implicit length.\n *\n * *Factory*: {@link module:Layout.utf8|utf8}\n *\n * **NOTE** Because the length is implicit in the size of the buffer\n * this layout should be used only in isolation, or in a situation\n * where the length can be expressed by operating on a slice of the\n * containing buffer.\n *\n * @param {Number} [maxSpan] - the maximum length allowed for encoded\n * string content. If not provided there is no bound on the allowed\n * content.\n *\n * @param {String} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass UTF8 extends Layout {\n constructor(maxSpan, property) {\n if (('string' === typeof maxSpan) && (undefined === property)) {\n property = maxSpan;\n maxSpan = undefined;\n }\n if (undefined === maxSpan) {\n maxSpan = -1;\n }\n else if (!Number.isInteger(maxSpan)) {\n throw new TypeError('maxSpan must be an integer');\n }\n super(-1, property);\n /** The maximum span of the layout in bytes.\n *\n * Positive values are generally expected. Zero is abnormal.\n * Attempts to encode or decode a value that exceeds this length\n * will throw a `RangeError`.\n *\n * A negative value indicates that there is no bound on the length\n * of the content. */\n this.maxSpan = maxSpan;\n }\n /** @override */\n getSpan(b, offset = 0) {\n checkUint8Array(b);\n return b.length - offset;\n }\n /** @override */\n decode(b, offset = 0) {\n const span = this.getSpan(b, offset);\n if ((0 <= this.maxSpan)\n && (this.maxSpan < span)) {\n throw new RangeError('text length exceeds maxSpan');\n }\n return uint8ArrayToBuffer(b).slice(offset, offset + span).toString('utf-8');\n }\n /** @override */\n encode(src, b, offset = 0) {\n /* Must force this to a string, lest it be a number and the\n * \"utf8-encoding\" below actually allocate a buffer of length\n * src */\n if ('string' !== typeof src) {\n src = String(src);\n }\n const srcb = buffer_1.Buffer.from(src, 'utf8');\n const span = srcb.length;\n if ((0 <= this.maxSpan)\n && (this.maxSpan < span)) {\n throw new RangeError('text length exceeds maxSpan');\n }\n if ((offset + span) > b.length) {\n throw new RangeError('encoding overruns Buffer');\n }\n srcb.copy(uint8ArrayToBuffer(b), offset);\n return span;\n }\n}\nexports.UTF8 = UTF8;\n/**\n * Contain a constant value.\n *\n * This layout may be used in cases where a JavaScript value can be\n * inferred without an expression in the binary encoding. An example\n * would be a {@link VariantLayout|variant layout} where the content\n * is implied by the union {@link Union#discriminator|discriminator}.\n *\n * @param {Object|Number|String} value - initializer for {@link\n * Constant#value|value}. If the value is an object (or array) and\n * the application intends the object to remain unchanged regardless\n * of what is done to values decoded by this layout, the value should\n * be frozen prior passing it to this constructor.\n *\n * @param {String} [property] - initializer for {@link\n * Layout#property|property}.\n *\n * @augments {Layout}\n */\nclass Constant extends Layout {\n constructor(value, property) {\n super(0, property);\n /** The value produced by this constant when the layout is {@link\n * Constant#decode|decoded}.\n *\n * Any JavaScript value including `null` and `undefined` is\n * permitted.\n *\n * **WARNING** If `value` passed in the constructor was not\n * frozen, it is possible for users of decoded values to change\n * the content of the value. */\n this.value = value;\n }\n /** @override */\n decode(b, offset) {\n return this.value;\n }\n /** @override */\n encode(src, b, offset) {\n /* Constants take no space */\n return 0;\n }\n}\nexports.Constant = Constant;\n/** Factory for {@link GreedyCount}. */\nexports.greedy = ((elementSpan, property) => new GreedyCount(elementSpan, property));\n/** Factory for {@link OffsetLayout}. */\nexports.offset = ((layout, offset, property) => new OffsetLayout(layout, offset, property));\n/** Factory for {@link UInt|unsigned int layouts} spanning one\n * byte. */\nexports.u8 = ((property) => new UInt(1, property));\n/** Factory for {@link UInt|little-endian unsigned int layouts}\n * spanning two bytes. */\nexports.u16 = ((property) => new UInt(2, property));\n/** Factory for {@link UInt|little-endian unsigned int layouts}\n * spanning three bytes. */\nexports.u24 = ((property) => new UInt(3, property));\n/** Factory for {@link UInt|little-endian unsigned int layouts}\n * spanning four bytes. */\nexports.u32 = ((property) => new UInt(4, property));\n/** Factory for {@link UInt|little-endian unsigned int layouts}\n * spanning five bytes. */\nexports.u40 = ((property) => new UInt(5, property));\n/** Factory for {@link UInt|little-endian unsigned int layouts}\n * spanning six bytes. */\nexports.u48 = ((property) => new UInt(6, property));\n/** Factory for {@link NearUInt64|little-endian unsigned int\n * layouts} interpreted as Numbers. */\nexports.nu64 = ((property) => new NearUInt64(property));\n/** Factory for {@link UInt|big-endian unsigned int layouts}\n * spanning two bytes. */\nexports.u16be = ((property) => new UIntBE(2, property));\n/** Factory for {@link UInt|big-endian unsigned int layouts}\n * spanning three bytes. */\nexports.u24be = ((property) => new UIntBE(3, property));\n/** Factory for {@link UInt|big-endian unsigned int layouts}\n * spanning four bytes. */\nexports.u32be = ((property) => new UIntBE(4, property));\n/** Factory for {@link UInt|big-endian unsigned int layouts}\n * spanning five bytes. */\nexports.u40be = ((property) => new UIntBE(5, property));\n/** Factory for {@link UInt|big-endian unsigned int layouts}\n * spanning six bytes. */\nexports.u48be = ((property) => new UIntBE(6, property));\n/** Factory for {@link NearUInt64BE|big-endian unsigned int\n * layouts} interpreted as Numbers. */\nexports.nu64be = ((property) => new NearUInt64BE(property));\n/** Factory for {@link Int|signed int layouts} spanning one\n * byte. */\nexports.s8 = ((property) => new Int(1, property));\n/** Factory for {@link Int|little-endian signed int layouts}\n * spanning two bytes. */\nexports.s16 = ((property) => new Int(2, property));\n/** Factory for {@link Int|little-endian signed int layouts}\n * spanning three bytes. */\nexports.s24 = ((property) => new Int(3, property));\n/** Factory for {@link Int|little-endian signed int layouts}\n * spanning four bytes. */\nexports.s32 = ((property) => new Int(4, property));\n/** Factory for {@link Int|little-endian signed int layouts}\n * spanning five bytes. */\nexports.s40 = ((property) => new Int(5, property));\n/** Factory for {@link Int|little-endian signed int layouts}\n * spanning six bytes. */\nexports.s48 = ((property) => new Int(6, property));\n/** Factory for {@link NearInt64|little-endian signed int layouts}\n * interpreted as Numbers. */\nexports.ns64 = ((property) => new NearInt64(property));\n/** Factory for {@link Int|big-endian signed int layouts}\n * spanning two bytes. */\nexports.s16be = ((property) => new IntBE(2, property));\n/** Factory for {@link Int|big-endian signed int layouts}\n * spanning three bytes. */\nexports.s24be = ((property) => new IntBE(3, property));\n/** Factory for {@link Int|big-endian signed int layouts}\n * spanning four bytes. */\nexports.s32be = ((property) => new IntBE(4, property));\n/** Factory for {@link Int|big-endian signed int layouts}\n * spanning five bytes. */\nexports.s40be = ((property) => new IntBE(5, property));\n/** Factory for {@link Int|big-endian signed int layouts}\n * spanning six bytes. */\nexports.s48be = ((property) => new IntBE(6, property));\n/** Factory for {@link NearInt64BE|big-endian signed int layouts}\n * interpreted as Numbers. */\nexports.ns64be = ((property) => new NearInt64BE(property));\n/** Factory for {@link Float|little-endian 32-bit floating point} values. */\nexports.f32 = ((property) => new Float(property));\n/** Factory for {@link FloatBE|big-endian 32-bit floating point} values. */\nexports.f32be = ((property) => new FloatBE(property));\n/** Factory for {@link Double|little-endian 64-bit floating point} values. */\nexports.f64 = ((property) => new Double(property));\n/** Factory for {@link DoubleBE|big-endian 64-bit floating point} values. */\nexports.f64be = ((property) => new DoubleBE(property));\n/** Factory for {@link Structure} values. */\nexports.struct = ((fields, property, decodePrefixes) => new Structure(fields, property, decodePrefixes));\n/** Factory for {@link BitStructure} values. */\nexports.bits = ((word, msb, property) => new BitStructure(word, msb, property));\n/** Factory for {@link Sequence} values. */\nexports.seq = ((elementLayout, count, property) => new Sequence(elementLayout, count, property));\n/** Factory for {@link Union} values. */\nexports.union = ((discr, defaultLayout, property) => new Union(discr, defaultLayout, property));\n/** Factory for {@link UnionLayoutDiscriminator} values. */\nexports.unionLayoutDiscriminator = ((layout, property) => new UnionLayoutDiscriminator(layout, property));\n/** Factory for {@link Blob} values. */\nexports.blob = ((length, property) => new Blob(length, property));\n/** Factory for {@link CString} values. */\nexports.cstr = ((property) => new CString(property));\n/** Factory for {@link UTF8} values. */\nexports.utf8 = ((maxSpan, property) => new UTF8(maxSpan, property));\n/** Factory for {@link Constant} values. */\nexports.constant = ((value, property) => new Constant(value, property));\n//# sourceMappingURL=Layout.js.map",null,"'use strict';\n\nObject.defineProperty(exports, \"__esModule\", { value: true });\nlet converter;\n/**\n * Convert a little-endian buffer into a BigInt.\n * @param buf The little-endian buffer to convert\n * @returns A BigInt with the little-endian representation of buf.\n */\nfunction toBigIntLE(buf) {\n {\n const reversed = Buffer.from(buf);\n reversed.reverse();\n const hex = reversed.toString('hex');\n if (hex.length === 0) {\n return BigInt(0);\n }\n return BigInt(`0x${hex}`);\n }\n return converter.toBigInt(buf, false);\n}\nexports.toBigIntLE = toBigIntLE;\n/**\n * Convert a big-endian buffer into a BigInt\n * @param buf The big-endian buffer to convert.\n * @returns A BigInt with the big-endian representation of buf.\n */\nfunction toBigIntBE(buf) {\n {\n const hex = buf.toString('hex');\n if (hex.length === 0) {\n return BigInt(0);\n }\n return BigInt(`0x${hex}`);\n }\n return converter.toBigInt(buf, true);\n}\nexports.toBigIntBE = toBigIntBE;\n/**\n * Convert a BigInt to a little-endian buffer.\n * @param num The BigInt to convert.\n * @param width The number of bytes that the resulting buffer should be.\n * @returns A little-endian buffer representation of num.\n */\nfunction toBufferLE(num, width) {\n {\n const hex = num.toString(16);\n const buffer = Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');\n buffer.reverse();\n return buffer;\n }\n // Allocation is done here, since it is slower using napi in C\n return converter.fromBigInt(num, Buffer.allocUnsafe(width), false);\n}\nexports.toBufferLE = toBufferLE;\n/**\n * Convert a BigInt to a big-endian buffer.\n * @param num The BigInt to convert.\n * @param width The number of bytes that the resulting buffer should be.\n * @returns A big-endian buffer representation of num.\n */\nfunction toBufferBE(num, width) {\n {\n const hex = num.toString(16);\n return Buffer.from(hex.padStart(width * 2, '0').slice(0, width * 2), 'hex');\n }\n return converter.fromBigInt(num, Buffer.allocUnsafe(width), true);\n}\nexports.toBufferBE = toBufferBE;\n","/**\n * A `StructFailure` represents a single specific failure in validation.\n */\n/**\n * `StructError` objects are thrown (or returned) when validation fails.\n *\n * Validation logic is design to exit early for maximum performance. The error\n * represents the first error encountered during validation. For more detail,\n * the `error.failures` property is a generator function that can be run to\n * continue validation and receive all the failures in the data.\n */\nclass StructError extends TypeError {\n constructor(failure, failures) {\n let cached;\n const { message, explanation, ...rest } = failure;\n const { path } = failure;\n const msg = path.length === 0 ? message : `At path: ${path.join('.')} -- ${message}`;\n super(explanation ?? msg);\n if (explanation != null)\n this.cause = msg;\n Object.assign(this, rest);\n this.name = this.constructor.name;\n this.failures = () => {\n return (cached ?? (cached = [failure, ...failures()]));\n };\n }\n}\n\n/**\n * Check if a value is an iterator.\n */\nfunction isIterable(x) {\n return isObject(x) && typeof x[Symbol.iterator] === 'function';\n}\n/**\n * Check if a value is a plain object.\n */\nfunction isObject(x) {\n return typeof x === 'object' && x != null;\n}\n/**\n * Check if a value is a non-array object.\n */\nfunction isNonArrayObject(x) {\n return isObject(x) && !Array.isArray(x);\n}\n/**\n * Check if a value is a plain object.\n */\nfunction isPlainObject(x) {\n if (Object.prototype.toString.call(x) !== '[object Object]') {\n return false;\n }\n const prototype = Object.getPrototypeOf(x);\n return prototype === null || prototype === Object.prototype;\n}\n/**\n * Return a value as a printable string.\n */\nfunction print(value) {\n if (typeof value === 'symbol') {\n return value.toString();\n }\n return typeof value === 'string' ? JSON.stringify(value) : `${value}`;\n}\n/**\n * Shifts (removes and returns) the first value from the `input` iterator.\n * Like `Array.prototype.shift()` but for an `Iterator`.\n */\nfunction shiftIterator(input) {\n const { done, value } = input.next();\n return done ? undefined : value;\n}\n/**\n * Convert a single validation result to a failure.\n */\nfunction toFailure(result, context, struct, value) {\n if (result === true) {\n return;\n }\n else if (result === false) {\n result = {};\n }\n else if (typeof result === 'string') {\n result = { message: result };\n }\n const { path, branch } = context;\n const { type } = struct;\n const { refinement, message = `Expected a value of type \\`${type}\\`${refinement ? ` with refinement \\`${refinement}\\`` : ''}, but received: \\`${print(value)}\\``, } = result;\n return {\n value,\n type,\n refinement,\n key: path[path.length - 1],\n path,\n branch,\n ...result,\n message,\n };\n}\n/**\n * Convert a validation result to an iterable of failures.\n */\nfunction* toFailures(result, context, struct, value) {\n if (!isIterable(result)) {\n result = [result];\n }\n for (const r of result) {\n const failure = toFailure(r, context, struct, value);\n if (failure) {\n yield failure;\n }\n }\n}\n/**\n * Check a value against a struct, traversing deeply into nested values, and\n * returning an iterator of failures or success.\n */\nfunction* run(value, struct, options = {}) {\n const { path = [], branch = [value], coerce = false, mask = false } = options;\n const ctx = { path, branch, mask };\n if (coerce) {\n value = struct.coercer(value, ctx);\n }\n let status = 'valid';\n for (const failure of struct.validator(value, ctx)) {\n failure.explanation = options.message;\n status = 'not_valid';\n yield [failure, undefined];\n }\n for (let [k, v, s] of struct.entries(value, ctx)) {\n const ts = run(v, s, {\n path: k === undefined ? path : [...path, k],\n branch: k === undefined ? branch : [...branch, v],\n coerce,\n mask,\n message: options.message,\n });\n for (const t of ts) {\n if (t[0]) {\n status = t[0].refinement != null ? 'not_refined' : 'not_valid';\n yield [t[0], undefined];\n }\n else if (coerce) {\n v = t[1];\n if (k === undefined) {\n value = v;\n }\n else if (value instanceof Map) {\n value.set(k, v);\n }\n else if (value instanceof Set) {\n value.add(v);\n }\n else if (isObject(value)) {\n if (v !== undefined || k in value)\n value[k] = v;\n }\n }\n }\n }\n if (status !== 'not_valid') {\n for (const failure of struct.refiner(value, ctx)) {\n failure.explanation = options.message;\n status = 'not_refined';\n yield [failure, undefined];\n }\n }\n if (status === 'valid') {\n yield [undefined, value];\n }\n}\n\n/**\n * `Struct` objects encapsulate the validation logic for a specific type of\n * values. Once constructed, you use the `assert`, `is` or `validate` helpers to\n * validate unknown input data against the struct.\n */\nclass Struct {\n constructor(props) {\n const { type, schema, validator, refiner, coercer = (value) => value, entries = function* () { }, } = props;\n this.type = type;\n this.schema = schema;\n this.entries = entries;\n this.coercer = coercer;\n if (validator) {\n this.validator = (value, context) => {\n const result = validator(value, context);\n return toFailures(result, context, this, value);\n };\n }\n else {\n this.validator = () => [];\n }\n if (refiner) {\n this.refiner = (value, context) => {\n const result = refiner(value, context);\n return toFailures(result, context, this, value);\n };\n }\n else {\n this.refiner = () => [];\n }\n }\n /**\n * Assert that a value passes the struct's validation, throwing if it doesn't.\n */\n assert(value, message) {\n return assert(value, this, message);\n }\n /**\n * Create a value with the struct's coercion logic, then validate it.\n */\n create(value, message) {\n return create(value, this, message);\n }\n /**\n * Check if a value passes the struct's validation.\n */\n is(value) {\n return is(value, this);\n }\n /**\n * Mask a value, coercing and validating it, but returning only the subset of\n * properties defined by the struct's schema. Masking applies recursively to\n * props of `object` structs only.\n */\n mask(value, message) {\n return mask(value, this, message);\n }\n /**\n * Validate a value with the struct's validation logic, returning a tuple\n * representing the result.\n *\n * You may optionally pass `true` for the `coerce` argument to coerce\n * the value before attempting to validate it. If you do, the result will\n * contain the coerced result when successful. Also, `mask` will turn on\n * masking of the unknown `object` props recursively if passed.\n */\n validate(value, options = {}) {\n return validate(value, this, options);\n }\n}\n/**\n * Assert that a value passes a struct, throwing if it doesn't.\n */\nfunction assert(value, struct, message) {\n const result = validate(value, struct, { message });\n if (result[0]) {\n throw result[0];\n }\n}\n/**\n * Create a value with the coercion logic of struct and validate it.\n */\nfunction create(value, struct, message) {\n const result = validate(value, struct, { coerce: true, message });\n if (result[0]) {\n throw result[0];\n }\n else {\n return result[1];\n }\n}\n/**\n * Mask a value, returning only the subset of properties defined by a struct.\n */\nfunction mask(value, struct, message) {\n const result = validate(value, struct, { coerce: true, mask: true, message });\n if (result[0]) {\n throw result[0];\n }\n else {\n return result[1];\n }\n}\n/**\n * Check if a value passes a struct.\n */\nfunction is(value, struct) {\n const result = validate(value, struct);\n return !result[0];\n}\n/**\n * Validate a value against a struct, returning an error if invalid, or the\n * value (with potential coercion) if valid.\n */\nfunction validate(value, struct, options = {}) {\n const tuples = run(value, struct, options);\n const tuple = shiftIterator(tuples);\n if (tuple[0]) {\n const error = new StructError(tuple[0], function* () {\n for (const t of tuples) {\n if (t[0]) {\n yield t[0];\n }\n }\n });\n return [error, undefined];\n }\n else {\n const v = tuple[1];\n return [undefined, v];\n }\n}\n\nfunction assign(...Structs) {\n const isType = Structs[0].type === 'type';\n const schemas = Structs.map((s) => s.schema);\n const schema = Object.assign({}, ...schemas);\n return isType ? type(schema) : object(schema);\n}\n/**\n * Define a new struct type with a custom validation function.\n */\nfunction define(name, validator) {\n return new Struct({ type: name, schema: null, validator });\n}\n/**\n * Create a new struct based on an existing struct, but the value is allowed to\n * be `undefined`. `log` will be called if the value is not `undefined`.\n */\nfunction deprecated(struct, log) {\n return new Struct({\n ...struct,\n refiner: (value, ctx) => value === undefined || struct.refiner(value, ctx),\n validator(value, ctx) {\n if (value === undefined) {\n return true;\n }\n else {\n log(value, ctx);\n return struct.validator(value, ctx);\n }\n },\n });\n}\n/**\n * Create a struct with dynamic validation logic.\n *\n * The callback will receive the value currently being validated, and must\n * return a struct object to validate it with. This can be useful to model\n * validation logic that changes based on its input.\n */\nfunction dynamic(fn) {\n return new Struct({\n type: 'dynamic',\n schema: null,\n *entries(value, ctx) {\n const struct = fn(value, ctx);\n yield* struct.entries(value, ctx);\n },\n validator(value, ctx) {\n const struct = fn(value, ctx);\n return struct.validator(value, ctx);\n },\n coercer(value, ctx) {\n const struct = fn(value, ctx);\n return struct.coercer(value, ctx);\n },\n refiner(value, ctx) {\n const struct = fn(value, ctx);\n return struct.refiner(value, ctx);\n },\n });\n}\n/**\n * Create a struct with lazily evaluated validation logic.\n *\n * The first time validation is run with the struct, the callback will be called\n * and must return a struct object to use. This is useful for cases where you\n * want to have self-referential structs for nested data structures to avoid a\n * circular definition problem.\n */\nfunction lazy(fn) {\n let struct;\n return new Struct({\n type: 'lazy',\n schema: null,\n *entries(value, ctx) {\n struct ?? (struct = fn());\n yield* struct.entries(value, ctx);\n },\n validator(value, ctx) {\n struct ?? (struct = fn());\n return struct.validator(value, ctx);\n },\n coercer(value, ctx) {\n struct ?? (struct = fn());\n return struct.coercer(value, ctx);\n },\n refiner(value, ctx) {\n struct ?? (struct = fn());\n return struct.refiner(value, ctx);\n },\n });\n}\n/**\n * Create a new struct based on an existing object struct, but excluding\n * specific properties.\n *\n * Like TypeScript's `Omit` utility.\n */\nfunction omit(struct, keys) {\n const { schema } = struct;\n const subschema = { ...schema };\n for (const key of keys) {\n delete subschema[key];\n }\n switch (struct.type) {\n case 'type':\n return type(subschema);\n default:\n return object(subschema);\n }\n}\n/**\n * Create a new struct based on an existing object struct, but with all of its\n * properties allowed to be `undefined`.\n *\n * Like TypeScript's `Partial` utility.\n */\nfunction partial(struct) {\n const isStruct = struct instanceof Struct;\n const schema = isStruct ? { ...struct.schema } : { ...struct };\n for (const key in schema) {\n schema[key] = optional(schema[key]);\n }\n if (isStruct && struct.type === 'type') {\n return type(schema);\n }\n return object(schema);\n}\n/**\n * Create a new struct based on an existing object struct, but only including\n * specific properties.\n *\n * Like TypeScript's `Pick` utility.\n */\nfunction pick(struct, keys) {\n const { schema } = struct;\n const subschema = {};\n for (const key of keys) {\n subschema[key] = schema[key];\n }\n switch (struct.type) {\n case 'type':\n return type(subschema);\n default:\n return object(subschema);\n }\n}\n/**\n * Define a new struct type with a custom validation function.\n *\n * @deprecated This function has been renamed to `define`.\n */\nfunction struct(name, validator) {\n console.warn('superstruct@0.11 - The `struct` helper has been renamed to `define`.');\n return define(name, validator);\n}\n\n/**\n * Ensure that any value passes validation.\n */\nfunction any() {\n return define('any', () => true);\n}\nfunction array(Element) {\n return new Struct({\n type: 'array',\n schema: Element,\n *entries(value) {\n if (Element && Array.isArray(value)) {\n for (const [i, v] of value.entries()) {\n yield [i, v, Element];\n }\n }\n },\n coercer(value) {\n return Array.isArray(value) ? value.slice() : value;\n },\n validator(value) {\n return (Array.isArray(value) ||\n `Expected an array value, but received: ${print(value)}`);\n },\n });\n}\n/**\n * Ensure that a value is a bigint.\n */\nfunction bigint() {\n return define('bigint', (value) => {\n return typeof value === 'bigint';\n });\n}\n/**\n * Ensure that a value is a boolean.\n */\nfunction boolean() {\n return define('boolean', (value) => {\n return typeof value === 'boolean';\n });\n}\n/**\n * Ensure that a value is a valid `Date`.\n *\n * Note: this also ensures that the value is *not* an invalid `Date` object,\n * which can occur when parsing a date fails but still returns a `Date`.\n */\nfunction date() {\n return define('date', (value) => {\n return ((value instanceof Date && !isNaN(value.getTime())) ||\n `Expected a valid \\`Date\\` object, but received: ${print(value)}`);\n });\n}\nfunction enums(values) {\n const schema = {};\n const description = values.map((v) => print(v)).join();\n for (const key of values) {\n schema[key] = key;\n }\n return new Struct({\n type: 'enums',\n schema,\n validator(value) {\n return (values.includes(value) ||\n `Expected one of \\`${description}\\`, but received: ${print(value)}`);\n },\n });\n}\n/**\n * Ensure that a value is a function.\n */\nfunction func() {\n return define('func', (value) => {\n return (typeof value === 'function' ||\n `Expected a function, but received: ${print(value)}`);\n });\n}\n/**\n * Ensure that a value is an instance of a specific class.\n */\nfunction instance(Class) {\n return define('instance', (value) => {\n return (value instanceof Class ||\n `Expected a \\`${Class.name}\\` instance, but received: ${print(value)}`);\n });\n}\n/**\n * Ensure that a value is an integer.\n */\nfunction integer() {\n return define('integer', (value) => {\n return ((typeof value === 'number' && !isNaN(value) && Number.isInteger(value)) ||\n `Expected an integer, but received: ${print(value)}`);\n });\n}\n/**\n * Ensure that a value matches all of a set of types.\n */\nfunction intersection(Structs) {\n return new Struct({\n type: 'intersection',\n schema: null,\n *entries(value, ctx) {\n for (const S of Structs) {\n yield* S.entries(value, ctx);\n }\n },\n *validator(value, ctx) {\n for (const S of Structs) {\n yield* S.validator(value, ctx);\n }\n },\n *refiner(value, ctx) {\n for (const S of Structs) {\n yield* S.refiner(value, ctx);\n }\n },\n });\n}\nfunction literal(constant) {\n const description = print(constant);\n const t = typeof constant;\n return new Struct({\n type: 'literal',\n schema: t === 'string' || t === 'number' || t === 'boolean' ? constant : null,\n validator(value) {\n return (value === constant ||\n `Expected the literal \\`${description}\\`, but received: ${print(value)}`);\n },\n });\n}\nfunction map(Key, Value) {\n return new Struct({\n type: 'map',\n schema: null,\n *entries(value) {\n if (Key && Value && value instanceof Map) {\n for (const [k, v] of value.entries()) {\n yield [k, k, Key];\n yield [k, v, Value];\n }\n }\n },\n coercer(value) {\n return value instanceof Map ? new Map(value) : value;\n },\n validator(value) {\n return (value instanceof Map ||\n `Expected a \\`Map\\` object, but received: ${print(value)}`);\n },\n });\n}\n/**\n * Ensure that no value ever passes validation.\n */\nfunction never() {\n return define('never', () => false);\n}\n/**\n * Augment an existing struct to allow `null` values.\n */\nfunction nullable(struct) {\n return new Struct({\n ...struct,\n validator: (value, ctx) => value === null || struct.validator(value, ctx),\n refiner: (value, ctx) => value === null || struct.refiner(value, ctx),\n });\n}\n/**\n * Ensure that a value is a number.\n */\nfunction number() {\n return define('number', (value) => {\n return ((typeof value === 'number' && !isNaN(value)) ||\n `Expected a number, but received: ${print(value)}`);\n });\n}\nfunction object(schema) {\n const knowns = schema ? Object.keys(schema) : [];\n const Never = never();\n return new Struct({\n type: 'object',\n schema: schema ? schema : null,\n *entries(value) {\n if (schema && isObject(value)) {\n const unknowns = new Set(Object.keys(value));\n for (const key of knowns) {\n unknowns.delete(key);\n yield [key, value[key], schema[key]];\n }\n for (const key of unknowns) {\n yield [key, value[key], Never];\n }\n }\n },\n validator(value) {\n return (isNonArrayObject(value) ||\n `Expected an object, but received: ${print(value)}`);\n },\n coercer(value, ctx) {\n if (!isNonArrayObject(value)) {\n return value;\n }\n const coerced = { ...value };\n // The `object` struct has special behaviour enabled by the mask flag.\n // When masking, properties that are not in the schema are deleted from\n // the coerced object instead of eventually failing validaiton.\n if (ctx.mask && schema) {\n for (const key in coerced) {\n if (schema[key] === undefined) {\n delete coerced[key];\n }\n }\n }\n return coerced;\n },\n });\n}\n/**\n * Augment a struct to allow `undefined` values.\n */\nfunction optional(struct) {\n return new Struct({\n ...struct,\n validator: (value, ctx) => value === undefined || struct.validator(value, ctx),\n refiner: (value, ctx) => value === undefined || struct.refiner(value, ctx),\n });\n}\n/**\n * Ensure that a value is an object with keys and values of specific types, but\n * without ensuring any specific shape of properties.\n *\n * Like TypeScript's `Record` utility.\n */\nfunction record(Key, Value) {\n return new Struct({\n type: 'record',\n schema: null,\n *entries(value) {\n if (isObject(value)) {\n for (const k in value) {\n const v = value[k];\n yield [k, k, Key];\n yield [k, v, Value];\n }\n }\n },\n validator(value) {\n return (isNonArrayObject(value) ||\n `Expected an object, but received: ${print(value)}`);\n },\n coercer(value) {\n return isNonArrayObject(value) ? { ...value } : value;\n },\n });\n}\n/**\n * Ensure that a value is a `RegExp`.\n *\n * Note: this does not test the value against the regular expression! For that\n * you need to use the `pattern()` refinement.\n */\nfunction regexp() {\n return define('regexp', (value) => {\n return value instanceof RegExp;\n });\n}\nfunction set(Element) {\n return new Struct({\n type: 'set',\n schema: null,\n *entries(value) {\n if (Element && value instanceof Set) {\n for (const v of value) {\n yield [v, v, Element];\n }\n }\n },\n coercer(value) {\n return value instanceof Set ? new Set(value) : value;\n },\n validator(value) {\n return (value instanceof Set ||\n `Expected a \\`Set\\` object, but received: ${print(value)}`);\n },\n });\n}\n/**\n * Ensure that a value is a string.\n */\nfunction string() {\n return define('string', (value) => {\n return (typeof value === 'string' ||\n `Expected a string, but received: ${print(value)}`);\n });\n}\n/**\n * Ensure that a value is a tuple of a specific length, and that each of its\n * elements is of a specific type.\n */\nfunction tuple(Structs) {\n const Never = never();\n return new Struct({\n type: 'tuple',\n schema: null,\n *entries(value) {\n if (Array.isArray(value)) {\n const length = Math.max(Structs.length, value.length);\n for (let i = 0; i < length; i++) {\n yield [i, value[i], Structs[i] || Never];\n }\n }\n },\n validator(value) {\n return (Array.isArray(value) ||\n `Expected an array, but received: ${print(value)}`);\n },\n coercer(value) {\n return Array.isArray(value) ? value.slice() : value;\n },\n });\n}\n/**\n * Ensure that a value has a set of known properties of specific types.\n *\n * Note: Unrecognized properties are allowed and untouched. This is similar to\n * how TypeScript's structural typing works.\n */\nfunction type(schema) {\n const keys = Object.keys(schema);\n return new Struct({\n type: 'type',\n schema,\n *entries(value) {\n if (isObject(value)) {\n for (const k of keys) {\n yield [k, value[k], schema[k]];\n }\n }\n },\n validator(value) {\n return (isNonArrayObject(value) ||\n `Expected an object, but received: ${print(value)}`);\n },\n coercer(value) {\n return isNonArrayObject(value) ? { ...value } : value;\n },\n });\n}\n/**\n * Ensure that a value matches one of a set of types.\n */\nfunction union(Structs) {\n const description = Structs.map((s) => s.type).join(' | ');\n return new Struct({\n type: 'union',\n schema: null,\n coercer(value, ctx) {\n for (const S of Structs) {\n const [error, coerced] = S.validate(value, {\n coerce: true,\n mask: ctx.mask,\n });\n if (!error) {\n return coerced;\n }\n }\n return value;\n },\n validator(value, ctx) {\n const failures = [];\n for (const S of Structs) {\n const [...tuples] = run(value, S, ctx);\n const [first] = tuples;\n if (!first[0]) {\n return [];\n }\n else {\n for (const [failure] of tuples) {\n if (failure) {\n failures.push(failure);\n }\n }\n }\n }\n return [\n `Expected the value to satisfy a union of \\`${description}\\`, but received: ${print(value)}`,\n ...failures,\n ];\n },\n });\n}\n/**\n * Ensure that any value passes validation, without widening its type to `any`.\n */\nfunction unknown() {\n return define('unknown', () => true);\n}\n\n/**\n * Augment a `Struct` to add an additional coercion step to its input.\n *\n * This allows you to transform input data before validating it, to increase the\n * likelihood that it passes validation—for example for default values, parsing\n * different formats, etc.\n *\n * Note: You must use `create(value, Struct)` on the value to have the coercion\n * take effect! Using simply `assert()` or `is()` will not use coercion.\n */\nfunction coerce(struct, condition, coercer) {\n return new Struct({\n ...struct,\n coercer: (value, ctx) => {\n return is(value, condition)\n ? struct.coercer(coercer(value, ctx), ctx)\n : struct.coercer(value, ctx);\n },\n });\n}\n/**\n * Augment a struct to replace `undefined` values with a default.\n *\n * Note: You must use `create(value, Struct)` on the value to have the coercion\n * take effect! Using simply `assert()` or `is()` will not use coercion.\n */\nfunction defaulted(struct, fallback, options = {}) {\n return coerce(struct, unknown(), (x) => {\n const f = typeof fallback === 'function' ? fallback() : fallback;\n if (x === undefined) {\n return f;\n }\n if (!options.strict && isPlainObject(x) && isPlainObject(f)) {\n const ret = { ...x };\n let changed = false;\n for (const key in f) {\n if (ret[key] === undefined) {\n ret[key] = f[key];\n changed = true;\n }\n }\n if (changed) {\n return ret;\n }\n }\n return x;\n });\n}\n/**\n * Augment a struct to trim string inputs.\n *\n * Note: You must use `create(value, Struct)` on the value to have the coercion\n * take effect! Using simply `assert()` or `is()` will not use coercion.\n */\nfunction trimmed(struct) {\n return coerce(struct, string(), (x) => x.trim());\n}\n\n/**\n * Ensure that a string, array, map, or set is empty.\n */\nfunction empty(struct) {\n return refine(struct, 'empty', (value) => {\n const size = getSize(value);\n return (size === 0 ||\n `Expected an empty ${struct.type} but received one with a size of \\`${size}\\``);\n });\n}\nfunction getSize(value) {\n if (value instanceof Map || value instanceof Set) {\n return value.size;\n }\n else {\n return value.length;\n }\n}\n/**\n * Ensure that a number or date is below a threshold.\n */\nfunction max(struct, threshold, options = {}) {\n const { exclusive } = options;\n return refine(struct, 'max', (value) => {\n return exclusive\n ? value < threshold\n : value <= threshold ||\n `Expected a ${struct.type} less than ${exclusive ? '' : 'or equal to '}${threshold} but received \\`${value}\\``;\n });\n}\n/**\n * Ensure that a number or date is above a threshold.\n */\nfunction min(struct, threshold, options = {}) {\n const { exclusive } = options;\n return refine(struct, 'min', (value) => {\n return exclusive\n ? value > threshold\n : value >= threshold ||\n `Expected a ${struct.type} greater than ${exclusive ? '' : 'or equal to '}${threshold} but received \\`${value}\\``;\n });\n}\n/**\n * Ensure that a string, array, map or set is not empty.\n */\nfunction nonempty(struct) {\n return refine(struct, 'nonempty', (value) => {\n const size = getSize(value);\n return (size > 0 || `Expected a nonempty ${struct.type} but received an empty one`);\n });\n}\n/**\n * Ensure that a string matches a regular expression.\n */\nfunction pattern(struct, regexp) {\n return refine(struct, 'pattern', (value) => {\n return (regexp.test(value) ||\n `Expected a ${struct.type} matching \\`/${regexp.source}/\\` but received \"${value}\"`);\n });\n}\n/**\n * Ensure that a string, array, number, date, map, or set has a size (or length, or time) between `min` and `max`.\n */\nfunction size(struct, min, max = min) {\n const expected = `Expected a ${struct.type}`;\n const of = min === max ? `of \\`${min}\\`` : `between \\`${min}\\` and \\`${max}\\``;\n return refine(struct, 'size', (value) => {\n if (typeof value === 'number' || value instanceof Date) {\n return ((min <= value && value <= max) ||\n `${expected} ${of} but received \\`${value}\\``);\n }\n else if (value instanceof Map || value instanceof Set) {\n const { size } = value;\n return ((min <= size && size <= max) ||\n `${expected} with a size ${of} but received one with a size of \\`${size}\\``);\n }\n else {\n const { length } = value;\n return ((min <= length && length <= max) ||\n `${expected} with a length ${of} but received one with a length of \\`${length}\\``);\n }\n });\n}\n/**\n * Augment a `Struct` to add an additional refinement to the validation.\n *\n * The refiner function is guaranteed to receive a value of the struct's type,\n * because the struct's existing validation will already have passed. This\n * allows you to layer additional validation on top of existing structs.\n */\nfunction refine(struct, name, refiner) {\n return new Struct({\n ...struct,\n *refiner(value, ctx) {\n yield* struct.refiner(value, ctx);\n const result = refiner(value, ctx);\n const failures = toFailures(result, ctx, struct, value);\n for (const failure of failures) {\n yield { ...failure, refinement: name };\n }\n },\n });\n}\n\nexport { Struct, StructError, any, array, assert, assign, bigint, boolean, coerce, create, date, defaulted, define, deprecated, dynamic, empty, enums, func, instance, integer, intersection, is, lazy, literal, map, mask, max, min, never, nonempty, nullable, number, object, omit, optional, partial, pattern, pick, record, refine, regexp, set, size, string, struct, trimmed, tuple, type, union, unknown, validate };\n//# sourceMappingURL=index.mjs.map\n",null,null,null,null,null,null,null,"'use strict';\n\nconst uuid = require('uuid').v4;\nconst generateRequest = require('../../generateRequest');\n\n/**\n * Constructor for a Jayson Browser Client that does not depend any node.js core libraries\n * @class ClientBrowser\n * @param {Function} callServer Method that calls the server, receives the stringified request and a regular node-style callback\n * @param {Object} [options]\n * @param {Function} [options.reviver] Reviver function for JSON\n * @param {Function} [options.replacer] Replacer function for JSON\n * @param {Number} [options.version=2] JSON-RPC version to use (1|2)\n * @param {Function} [options.generator] Function to use for generating request IDs\n * @param {Boolean} [options.notificationIdNull=false] When true, version 2 requests will set id to null instead of omitting it\n * @return {ClientBrowser}\n */\nconst ClientBrowser = function(callServer, options) {\n if(!(this instanceof ClientBrowser)) {\n return new ClientBrowser(callServer, options);\n }\n\n if (!options) {\n options = {};\n }\n\n this.options = {\n reviver: typeof options.reviver !== 'undefined' ? options.reviver : null,\n replacer: typeof options.replacer !== 'undefined' ? options.replacer : null,\n generator: typeof options.generator !== 'undefined' ? options.generator : function() { return uuid(); },\n version: typeof options.version !== 'undefined' ? options.version : 2,\n notificationIdNull: typeof options.notificationIdNull === 'boolean' ? options.notificationIdNull : false,\n };\n\n this.callServer = callServer;\n};\n\nmodule.exports = ClientBrowser;\n\n/**\n * Creates a request and dispatches it if given a callback.\n * @param {String|Array} method A batch request if passed an Array, or a method name if passed a String\n * @param {Array|Object} [params] Parameters for the method\n * @param {String|Number} [id] Optional id. If undefined an id will be generated. If null it creates a notification request\n * @param {Function} [callback] Request callback. If specified, executes the request rather than only returning it.\n * @throws {TypeError} Invalid parameters\n * @return {Object} JSON-RPC 1.0 or 2.0 compatible request\n */\nClientBrowser.prototype.request = function(method, params, id, callback) {\n const self = this;\n let request = null;\n\n // is this a batch request?\n const isBatch = Array.isArray(method) && typeof params === 'function';\n\n if (this.options.version === 1 && isBatch) {\n throw new TypeError('JSON-RPC 1.0 does not support batching');\n }\n\n // is this a raw request?\n const isRaw = !isBatch && method && typeof method === 'object' && typeof params === 'function';\n\n if(isBatch || isRaw) {\n callback = params;\n request = method;\n } else {\n if(typeof id === 'function') {\n callback = id;\n // specifically undefined because \"null\" is a notification request\n id = undefined;\n }\n\n const hasCallback = typeof callback === 'function';\n\n try {\n request = generateRequest(method, params, id, {\n generator: this.options.generator,\n version: this.options.version,\n notificationIdNull: this.options.notificationIdNull,\n });\n } catch(err) {\n if(hasCallback) {\n return callback(err);\n }\n throw err;\n }\n\n // no callback means we should just return a raw request\n if(!hasCallback) {\n return request;\n }\n\n }\n\n let message;\n try {\n message = JSON.stringify(request, this.options.replacer);\n } catch(err) {\n return callback(err);\n }\n\n this.callServer(message, function(err, response) {\n self._parseResponse(err, response, callback);\n });\n\n // always return the raw request\n return request;\n};\n\n/**\n * Parses a response from a server\n * @param {Object} err Error to pass on that is unrelated to the actual response\n * @param {String} responseText JSON-RPC 1.0 or 2.0 response\n * @param {Function} callback Callback that will receive different arguments depending on the amount of parameters\n * @private\n */\nClientBrowser.prototype._parseResponse = function(err, responseText, callback) {\n if(err) {\n callback(err);\n return;\n }\n\n if(!responseText) {\n // empty response text, assume that is correct because it could be a\n // notification which jayson does not give any body for\n return callback();\n }\n\n let response;\n try {\n response = JSON.parse(responseText, this.options.reviver);\n } catch(err) {\n return callback(err);\n }\n\n if(callback.length === 3) {\n // if callback length is 3, we split callback arguments on error and response\n\n // is batch response?\n if(Array.isArray(response)) {\n\n // neccesary to split strictly on validity according to spec here\n const isError = function(res) {\n return typeof res.error !== 'undefined';\n };\n\n const isNotError = function (res) {\n return !isError(res);\n };\n\n return callback(null, response.filter(isError), response.filter(isNotError));\n \n } else {\n\n // split regardless of validity\n return callback(null, response.error, response.result);\n \n }\n \n }\n\n callback(null, response);\n};\n","import rng from './rng.js';\nimport stringify from './stringify.js';\n\nfunction v4(options, buf, offset) {\n options = options || {};\n var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (var i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return stringify(rnds);\n}\n\nexport default v4;","// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nvar getRandomValues;\nvar rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation. Also,\n // find the complete implementation of crypto (msCrypto) on IE11.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nvar byteToHex = [];\n\nfor (var i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).substr(1));\n}\n\nfunction stringify(arr) {\n var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;","'use strict';\n\nconst uuid = require('uuid').v4;\n\n/**\n * Generates a JSON-RPC 1.0 or 2.0 request\n * @param {String} method Name of method to call\n * @param {Array|Object} params Array of parameters passed to the method as specified, or an object of parameter names and corresponding value\n * @param {String|Number|null} [id] Request ID can be a string, number, null for explicit notification or left out for automatic generation\n * @param {Object} [options]\n * @param {Number} [options.version=2] JSON-RPC version to use (1 or 2)\n * @param {Boolean} [options.notificationIdNull=false] When true, version 2 requests will set id to null instead of omitting it\n * @param {Function} [options.generator] Passed the request, and the options object and is expected to return a request ID\n * @throws {TypeError} If any of the parameters are invalid\n * @return {Object} A JSON-RPC 1.0 or 2.0 request\n * @memberOf Utils\n */\nconst generateRequest = function(method, params, id, options) {\n if(typeof method !== 'string') {\n throw new TypeError(method + ' must be a string');\n }\n\n options = options || {};\n\n // check valid version provided\n const version = typeof options.version === 'number' ? options.version : 2;\n if (version !== 1 && version !== 2) {\n throw new TypeError(version + ' must be 1 or 2');\n }\n\n const request = {\n method: method\n };\n\n if(version === 2) {\n request.jsonrpc = '2.0';\n }\n\n if(params) {\n // params given, but invalid?\n if(typeof params !== 'object' && !Array.isArray(params)) {\n throw new TypeError(params + ' must be an object, array or omitted');\n }\n request.params = params;\n }\n\n // if id was left out, generate one (null means explicit notification)\n if(typeof(id) === 'undefined') {\n const generator = typeof options.generator === 'function' ? options.generator : function() { return uuid(); };\n request.id = generator(request, options);\n } else if (version === 2 && id === null) {\n // we have a version 2 notification\n if (options.notificationIdNull) {\n request.id = null; // id will not be set at all unless option provided\n }\n } else {\n request.id = id;\n }\n\n return request;\n};\n\nmodule.exports = generateRequest;\n","import { Buffer } from 'buffer';\nimport { EventEmitter } from 'eventemitter3';\n\n// node_modules/esbuild-plugin-polyfill-node/polyfills/buffer.js\nvar WebSocketBrowserImpl = class extends EventEmitter {\n socket;\n /** Instantiate a WebSocket class\n * @constructor\n * @param {String} address - url to a websocket server\n * @param {(Object)} options - websocket options\n * @param {(String|Array)} protocols - a list of protocols\n * @return {WebSocketBrowserImpl} - returns a WebSocket instance\n */\n constructor(address, options, protocols) {\n super();\n this.socket = new window.WebSocket(address, protocols);\n this.socket.onopen = () => this.emit(\"open\");\n this.socket.onmessage = (event) => this.emit(\"message\", event.data);\n this.socket.onerror = (error) => this.emit(\"error\", error);\n this.socket.onclose = (event) => {\n this.emit(\"close\", event.code, event.reason);\n };\n }\n /**\n * Sends data through a websocket connection\n * @method\n * @param {(String|Object)} data - data to be sent via websocket\n * @param {Object} optionsOrCallback - ws options\n * @param {Function} callback - a callback called once the data is sent\n * @return {Undefined}\n */\n send(data, optionsOrCallback, callback) {\n const cb = callback || optionsOrCallback;\n try {\n this.socket.send(data);\n cb();\n } catch (error) {\n cb(error);\n }\n }\n /**\n * Closes an underlying socket\n * @method\n * @param {Number} code - status code explaining why the connection is being closed\n * @param {String} reason - a description why the connection is closing\n * @return {Undefined}\n * @throws {Error}\n */\n close(code, reason) {\n this.socket.close(code, reason);\n }\n addEventListener(type, listener, options) {\n this.socket.addEventListener(type, listener, options);\n }\n};\nfunction WebSocket(address, options) {\n return new WebSocketBrowserImpl(address, options);\n}\n\n// src/lib/utils.ts\nvar DefaultDataPack = class {\n encode(value) {\n return JSON.stringify(value);\n }\n decode(value) {\n return JSON.parse(value);\n }\n};\n\n// src/lib/client.ts\nvar CommonClient = class extends EventEmitter {\n address;\n rpc_id;\n queue;\n options;\n autoconnect;\n ready;\n reconnect;\n reconnect_timer_id;\n reconnect_interval;\n max_reconnects;\n rest_options;\n current_reconnects;\n generate_request_id;\n socket;\n webSocketFactory;\n dataPack;\n /**\n * Instantiate a Client class.\n * @constructor\n * @param {webSocketFactory} webSocketFactory - factory method for WebSocket\n * @param {String} address - url to a websocket server\n * @param {Object} options - ws options object with reconnect parameters\n * @param {Function} generate_request_id - custom generation request Id\n * @param {DataPack} dataPack - data pack contains encoder and decoder\n * @return {CommonClient}\n */\n constructor(webSocketFactory, address = \"ws://localhost:8080\", {\n autoconnect = true,\n reconnect = true,\n reconnect_interval = 1e3,\n max_reconnects = 5,\n ...rest_options\n } = {}, generate_request_id, dataPack) {\n super();\n this.webSocketFactory = webSocketFactory;\n this.queue = {};\n this.rpc_id = 0;\n this.address = address;\n this.autoconnect = autoconnect;\n this.ready = false;\n this.reconnect = reconnect;\n this.reconnect_timer_id = void 0;\n this.reconnect_interval = reconnect_interval;\n this.max_reconnects = max_reconnects;\n this.rest_options = rest_options;\n this.current_reconnects = 0;\n this.generate_request_id = generate_request_id || (() => ++this.rpc_id);\n if (!dataPack) this.dataPack = new DefaultDataPack();\n else this.dataPack = dataPack;\n if (this.autoconnect)\n this._connect(this.address, {\n autoconnect: this.autoconnect,\n reconnect: this.reconnect,\n reconnect_interval: this.reconnect_interval,\n max_reconnects: this.max_reconnects,\n ...this.rest_options\n });\n }\n /**\n * Connects to a defined server if not connected already.\n * @method\n * @return {Undefined}\n */\n connect() {\n if (this.socket) return;\n this._connect(this.address, {\n autoconnect: this.autoconnect,\n reconnect: this.reconnect,\n reconnect_interval: this.reconnect_interval,\n max_reconnects: this.max_reconnects,\n ...this.rest_options\n });\n }\n /**\n * Calls a registered RPC method on server.\n * @method\n * @param {String} method - RPC method name\n * @param {Object|Array} params - optional method parameters\n * @param {Number} timeout - RPC reply timeout value\n * @param {Object} ws_opts - options passed to ws\n * @return {Promise}\n */\n call(method, params, timeout, ws_opts) {\n if (!ws_opts && \"object\" === typeof timeout) {\n ws_opts = timeout;\n timeout = null;\n }\n return new Promise((resolve, reject) => {\n if (!this.ready) return reject(new Error(\"socket not ready\"));\n const rpc_id = this.generate_request_id(method, params);\n const message = {\n jsonrpc: \"2.0\",\n method,\n params: params || void 0,\n id: rpc_id\n };\n this.socket.send(this.dataPack.encode(message), ws_opts, (error) => {\n if (error) return reject(error);\n this.queue[rpc_id] = { promise: [resolve, reject] };\n if (timeout) {\n this.queue[rpc_id].timeout = setTimeout(() => {\n delete this.queue[rpc_id];\n reject(new Error(\"reply timeout\"));\n }, timeout);\n }\n });\n });\n }\n /**\n * Logins with the other side of the connection.\n * @method\n * @param {Object} params - Login credentials object\n * @return {Promise}\n */\n async login(params) {\n const resp = await this.call(\"rpc.login\", params);\n if (!resp) throw new Error(\"authentication failed\");\n return resp;\n }\n /**\n * Fetches a list of client's methods registered on server.\n * @method\n * @return {Array}\n */\n async listMethods() {\n return await this.call(\"__listMethods\");\n }\n /**\n * Sends a JSON-RPC 2.0 notification to server.\n * @method\n * @param {String} method - RPC method name\n * @param {Object} params - optional method parameters\n * @return {Promise}\n */\n notify(method, params) {\n return new Promise((resolve, reject) => {\n if (!this.ready) return reject(new Error(\"socket not ready\"));\n const message = {\n jsonrpc: \"2.0\",\n method,\n params\n };\n this.socket.send(this.dataPack.encode(message), (error) => {\n if (error) return reject(error);\n resolve();\n });\n });\n }\n /**\n * Subscribes for a defined event.\n * @method\n * @param {String|Array} event - event name\n * @return {Undefined}\n * @throws {Error}\n */\n async subscribe(event) {\n if (typeof event === \"string\") event = [event];\n const result = await this.call(\"rpc.on\", event);\n if (typeof event === \"string\" && result[event] !== \"ok\")\n throw new Error(\n \"Failed subscribing to an event '\" + event + \"' with: \" + result[event]\n );\n return result;\n }\n /**\n * Unsubscribes from a defined event.\n * @method\n * @param {String|Array} event - event name\n * @return {Undefined}\n * @throws {Error}\n */\n async unsubscribe(event) {\n if (typeof event === \"string\") event = [event];\n const result = await this.call(\"rpc.off\", event);\n if (typeof event === \"string\" && result[event] !== \"ok\")\n throw new Error(\"Failed unsubscribing from an event with: \" + result);\n return result;\n }\n /**\n * Closes a WebSocket connection gracefully.\n * @method\n * @param {Number} code - socket close code\n * @param {String} data - optional data to be sent before closing\n * @return {Undefined}\n */\n close(code, data) {\n this.socket.close(code || 1e3, data);\n }\n /**\n * Enable / disable automatic reconnection.\n * @method\n * @param {Boolean} reconnect - enable / disable reconnection\n * @return {Undefined}\n */\n setAutoReconnect(reconnect) {\n this.reconnect = reconnect;\n }\n /**\n * Set the interval between reconnection attempts.\n * @method\n * @param {Number} interval - reconnection interval in milliseconds\n * @return {Undefined}\n */\n setReconnectInterval(interval) {\n this.reconnect_interval = interval;\n }\n /**\n * Set the maximum number of reconnection attempts.\n * @method\n * @param {Number} max_reconnects - maximum reconnection attempts\n * @return {Undefined}\n */\n setMaxReconnects(max_reconnects) {\n this.max_reconnects = max_reconnects;\n }\n /**\n * Connection/Message handler.\n * @method\n * @private\n * @param {String} address - WebSocket API address\n * @param {Object} options - ws options object\n * @return {Undefined}\n */\n _connect(address, options) {\n clearTimeout(this.reconnect_timer_id);\n this.socket = this.webSocketFactory(address, options);\n this.socket.addEventListener(\"open\", () => {\n this.ready = true;\n this.emit(\"open\");\n this.current_reconnects = 0;\n });\n this.socket.addEventListener(\"message\", ({ data: message }) => {\n if (message instanceof ArrayBuffer)\n message = Buffer.from(message).toString();\n try {\n message = this.dataPack.decode(message);\n } catch (error) {\n return;\n }\n if (message.notification && this.listeners(message.notification).length) {\n if (!Object.keys(message.params).length)\n return this.emit(message.notification);\n const args = [message.notification];\n if (message.params.constructor === Object) args.push(message.params);\n else\n for (let i = 0; i < message.params.length; i++)\n args.push(message.params[i]);\n return Promise.resolve().then(() => {\n this.emit.apply(this, args);\n });\n }\n if (!this.queue[message.id]) {\n if (message.method) {\n return Promise.resolve().then(() => {\n this.emit(message.method, message?.params);\n });\n }\n return;\n }\n if (\"error\" in message === \"result\" in message)\n this.queue[message.id].promise[1](\n new Error(\n 'Server response malformed. Response must include either \"result\" or \"error\", but not both.'\n )\n );\n if (this.queue[message.id].timeout)\n clearTimeout(this.queue[message.id].timeout);\n if (message.error) this.queue[message.id].promise[1](message.error);\n else this.queue[message.id].promise[0](message.result);\n delete this.queue[message.id];\n });\n this.socket.addEventListener(\"error\", (error) => this.emit(\"error\", error));\n this.socket.addEventListener(\"close\", ({ code, reason }) => {\n if (this.ready)\n setTimeout(() => this.emit(\"close\", code, reason), 0);\n this.ready = false;\n this.socket = void 0;\n if (code === 1e3) return;\n this.current_reconnects++;\n if (this.reconnect && (this.max_reconnects > this.current_reconnects || this.max_reconnects === 0))\n this.reconnect_timer_id = setTimeout(\n () => this._connect(address, options),\n this.reconnect_interval\n );\n });\n }\n};\n\n// src/index.browser.ts\nvar Client = class extends CommonClient {\n constructor(address = \"ws://localhost:8080\", {\n autoconnect = true,\n reconnect = true,\n reconnect_interval = 1e3,\n max_reconnects = 5\n } = {}, generate_request_id) {\n super(\n WebSocket,\n address,\n {\n autoconnect,\n reconnect,\n reconnect_interval,\n max_reconnects\n },\n generate_request_id\n );\n }\n};\n\nexport { Client, CommonClient, DefaultDataPack, WebSocket };\n//# sourceMappingURL=out.js.map\n//# sourceMappingURL=index.browser.mjs.map","export { Buffer } from \"buffer\";\n","/**\n * WebSocket implements a browser-side WebSocket specification.\n * @module Client\n */\n\n\"use strict\"\n\nimport { EventEmitter } from \"eventemitter3\"\n\nimport {\n BrowserWebSocketType,\n NodeWebSocketType,\n IWSClientAdditionalOptions,\n} from \"./client.types.js\"\n\nclass WebSocketBrowserImpl extends EventEmitter\n{\n socket: BrowserWebSocketType\n\n /** Instantiate a WebSocket class\n * @constructor\n * @param {String} address - url to a websocket server\n * @param {(Object)} options - websocket options\n * @param {(String|Array)} protocols - a list of protocols\n * @return {WebSocketBrowserImpl} - returns a WebSocket instance\n */\n constructor(address: string, options: {}, protocols?: string | string[])\n {\n super()\n\n this.socket = new window.WebSocket(address, protocols)\n\n this.socket.onopen = () => this.emit(\"open\")\n this.socket.onmessage = (event) => this.emit(\"message\", event.data)\n this.socket.onerror = (error) => this.emit(\"error\", error)\n this.socket.onclose = (event) =>\n {\n this.emit(\"close\", event.code, event.reason)\n }\n }\n\n /**\n * Sends data through a websocket connection\n * @method\n * @param {(String|Object)} data - data to be sent via websocket\n * @param {Object} optionsOrCallback - ws options\n * @param {Function} callback - a callback called once the data is sent\n * @return {Undefined}\n */\n send(\n data: Parameters[0],\n optionsOrCallback: (\n error?: Error\n ) => void | Parameters[1],\n callback?: () => void\n )\n {\n const cb = callback || optionsOrCallback\n\n try\n {\n this.socket.send(data)\n cb()\n }\n catch (error)\n {\n cb(error)\n }\n }\n\n /**\n * Closes an underlying socket\n * @method\n * @param {Number} code - status code explaining why the connection is being closed\n * @param {String} reason - a description why the connection is closing\n * @return {Undefined}\n * @throws {Error}\n */\n close(code?: number, reason?: string)\n {\n this.socket.close(code, reason)\n }\n\n addEventListener(\n type: K,\n listener: (ev: WebSocketEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ): void\n {\n this.socket.addEventListener(type, listener, options)\n }\n}\n\n/**\n * factory method for common WebSocket instance\n * @method\n * @param {String} address - url to a websocket server\n * @param {(Object)} options - websocket options\n * @return {Undefined}\n */\nexport function WebSocket(\n address: string,\n options: IWSClientAdditionalOptions\n)\n{\n return new WebSocketBrowserImpl(address, options)\n}\n","/**\n * \"Client\" wraps \"ws\" or a browser-implemented \"WebSocket\" library\n * according to the environment providing JSON RPC 2.0 support on top.\n * @module Client\n */\n\n\"use strict\"\n\nimport NodeWebSocket from \"ws\"\nimport { EventEmitter } from \"eventemitter3\"\nimport {\n ICommonWebSocket,\n IWSClientAdditionalOptions,\n NodeWebSocketType,\n ICommonWebSocketFactory,\n} from \"./client/client.types.js\"\n\nimport { DataPack, DefaultDataPack } from \"./utils.js\"\n\ninterface IQueueElement {\n promise: [\n Parameters[0]>[0],\n Parameters[0]>[1]\n ];\n timeout?: ReturnType;\n}\n\nexport interface IQueue {\n [x: number]: IQueueElement;\n}\n\nexport interface IWSRequestParams {\n [x: string]: any;\n [x: number]: any;\n}\n\nexport class CommonClient extends EventEmitter\n{\n private address: string\n private rpc_id: number\n private queue: IQueue\n private options: IWSClientAdditionalOptions & NodeWebSocket.ClientOptions\n private autoconnect: boolean\n private ready: boolean\n private reconnect: boolean\n private reconnect_timer_id: NodeJS.Timeout\n private reconnect_interval: number\n private max_reconnects: number\n private rest_options: IWSClientAdditionalOptions &\n NodeWebSocket.ClientOptions\n private current_reconnects: number\n private generate_request_id: (\n method: string,\n params: object | Array\n ) => number\n private socket: ICommonWebSocket\n private webSocketFactory: ICommonWebSocketFactory\n private dataPack: DataPack\n\n /**\n * Instantiate a Client class.\n * @constructor\n * @param {webSocketFactory} webSocketFactory - factory method for WebSocket\n * @param {String} address - url to a websocket server\n * @param {Object} options - ws options object with reconnect parameters\n * @param {Function} generate_request_id - custom generation request Id\n * @param {DataPack} dataPack - data pack contains encoder and decoder\n * @return {CommonClient}\n */\n constructor(\n webSocketFactory: ICommonWebSocketFactory,\n address = \"ws://localhost:8080\",\n {\n autoconnect = true,\n reconnect = true,\n reconnect_interval = 1000,\n max_reconnects = 5,\n ...rest_options\n } = {},\n generate_request_id?: (\n method: string,\n params: object | Array\n ) => number,\n dataPack?: DataPack\n )\n {\n super()\n\n this.webSocketFactory = webSocketFactory\n\n this.queue = {}\n this.rpc_id = 0\n\n this.address = address\n this.autoconnect = autoconnect\n this.ready = false\n this.reconnect = reconnect\n this.reconnect_timer_id = undefined\n this.reconnect_interval = reconnect_interval\n this.max_reconnects = max_reconnects\n this.rest_options = rest_options\n this.current_reconnects = 0\n this.generate_request_id = generate_request_id || (() => ++this.rpc_id)\n\n if (!dataPack) this.dataPack = new DefaultDataPack()\n else this.dataPack = dataPack\n\n if (this.autoconnect)\n this._connect(this.address, {\n autoconnect: this.autoconnect,\n reconnect: this.reconnect,\n reconnect_interval: this.reconnect_interval,\n max_reconnects: this.max_reconnects,\n ...this.rest_options,\n })\n }\n\n /**\n * Connects to a defined server if not connected already.\n * @method\n * @return {Undefined}\n */\n connect()\n {\n if (this.socket) return\n\n this._connect(this.address, {\n autoconnect: this.autoconnect,\n reconnect: this.reconnect,\n reconnect_interval: this.reconnect_interval,\n max_reconnects: this.max_reconnects,\n ...this.rest_options,\n })\n }\n\n /**\n * Calls a registered RPC method on server.\n * @method\n * @param {String} method - RPC method name\n * @param {Object|Array} params - optional method parameters\n * @param {Number} timeout - RPC reply timeout value\n * @param {Object} ws_opts - options passed to ws\n * @return {Promise}\n */\n call(\n method: string,\n params?: IWSRequestParams,\n timeout?: number,\n ws_opts?: Parameters[1]\n )\n {\n if (!ws_opts && \"object\" === typeof timeout)\n {\n ws_opts = timeout\n timeout = null\n }\n\n return new Promise((resolve, reject) =>\n {\n if (!this.ready) return reject(new Error(\"socket not ready\"))\n\n const rpc_id = this.generate_request_id(method, params)\n\n const message = {\n jsonrpc: \"2.0\",\n method: method,\n params: params || undefined,\n id: rpc_id,\n }\n\n this.socket.send(this.dataPack.encode(message), ws_opts, (error) =>\n {\n if (error) return reject(error)\n\n this.queue[rpc_id] = { promise: [resolve, reject] }\n\n if (timeout)\n {\n this.queue[rpc_id].timeout = setTimeout(() =>\n {\n delete this.queue[rpc_id]\n reject(new Error(\"reply timeout\"))\n }, timeout)\n }\n })\n })\n }\n\n /**\n * Logins with the other side of the connection.\n * @method\n * @param {Object} params - Login credentials object\n * @return {Promise}\n */\n async login(params: IWSRequestParams)\n {\n const resp = await this.call(\"rpc.login\", params)\n\n if (!resp) throw new Error(\"authentication failed\")\n\n return resp\n }\n\n /**\n * Fetches a list of client's methods registered on server.\n * @method\n * @return {Array}\n */\n async listMethods()\n {\n return await this.call(\"__listMethods\")\n }\n\n /**\n * Sends a JSON-RPC 2.0 notification to server.\n * @method\n * @param {String} method - RPC method name\n * @param {Object} params - optional method parameters\n * @return {Promise}\n */\n notify(method: string, params?: IWSRequestParams)\n {\n return new Promise((resolve, reject) =>\n {\n if (!this.ready) return reject(new Error(\"socket not ready\"))\n\n const message = {\n jsonrpc: \"2.0\",\n method: method,\n params,\n }\n\n this.socket.send(this.dataPack.encode(message), (error) =>\n {\n if (error) return reject(error)\n\n resolve()\n })\n })\n }\n\n /**\n * Subscribes for a defined event.\n * @method\n * @param {String|Array} event - event name\n * @return {Undefined}\n * @throws {Error}\n */\n async subscribe(event: string | Array)\n {\n if (typeof event === \"string\") event = [event]\n\n const result = await this.call(\"rpc.on\", event)\n\n if (typeof event === \"string\" && result[event] !== \"ok\")\n throw new Error(\n \"Failed subscribing to an event '\" + event + \"' with: \" + result[event]\n )\n\n return result\n }\n\n /**\n * Unsubscribes from a defined event.\n * @method\n * @param {String|Array} event - event name\n * @return {Undefined}\n * @throws {Error}\n */\n async unsubscribe(event: string | Array)\n {\n if (typeof event === \"string\") event = [event]\n\n const result = await this.call(\"rpc.off\", event)\n\n if (typeof event === \"string\" && result[event] !== \"ok\")\n throw new Error(\"Failed unsubscribing from an event with: \" + result)\n\n return result\n }\n\n /**\n * Closes a WebSocket connection gracefully.\n * @method\n * @param {Number} code - socket close code\n * @param {String} data - optional data to be sent before closing\n * @return {Undefined}\n */\n close(code?: number, data?: string)\n {\n this.socket.close(code || 1000, data)\n }\n\n /**\n * Enable / disable automatic reconnection.\n * @method\n * @param {Boolean} reconnect - enable / disable reconnection\n * @return {Undefined}\n */\n setAutoReconnect(reconnect: boolean)\n {\n this.reconnect = reconnect\n }\n\n /**\n * Set the interval between reconnection attempts.\n * @method\n * @param {Number} interval - reconnection interval in milliseconds\n * @return {Undefined}\n */\n setReconnectInterval(interval: number)\n {\n this.reconnect_interval = interval\n }\n\n /**\n * Set the maximum number of reconnection attempts.\n * @method\n * @param {Number} max_reconnects - maximum reconnection attempts\n * @return {Undefined}\n */\n setMaxReconnects(max_reconnects: number)\n {\n this.max_reconnects = max_reconnects\n }\n\n /**\n * Connection/Message handler.\n * @method\n * @private\n * @param {String} address - WebSocket API address\n * @param {Object} options - ws options object\n * @return {Undefined}\n */\n private _connect(\n address: string,\n options: IWSClientAdditionalOptions & NodeWebSocket.ClientOptions\n )\n {\n clearTimeout(this.reconnect_timer_id)\n this.socket = this.webSocketFactory(address, options)\n\n this.socket.addEventListener(\"open\", () =>\n {\n this.ready = true\n this.emit(\"open\")\n this.current_reconnects = 0\n })\n\n this.socket.addEventListener(\"message\", ({ data: message }) =>\n {\n if (message instanceof ArrayBuffer)\n message = Buffer.from(message).toString()\n\n try\n {\n message = this.dataPack.decode(message)\n }\n catch (error)\n {\n return\n }\n\n // check if any listeners are attached and forward event\n if (message.notification && this.listeners(message.notification).length)\n {\n if (!Object.keys(message.params).length)\n return this.emit(message.notification)\n\n const args = [message.notification]\n\n if (message.params.constructor === Object) args.push(message.params)\n // using for-loop instead of unshift/spread because performance is better\n else\n for (let i = 0; i < message.params.length; i++)\n args.push(message.params[i])\n\n // run as microtask so that pending queue messages are resolved first\n // eslint-disable-next-line prefer-spread\n return Promise.resolve().then(() =>\n {\n // eslint-disable-next-line prefer-spread\n this.emit.apply(this, args)\n })\n }\n\n if (!this.queue[message.id])\n {\n // general JSON RPC 2.0 events\n if (message.method)\n {\n // run as microtask so that pending queue messages are resolved first\n return Promise.resolve().then(() =>\n {\n this.emit(message.method, message?.params)\n })\n }\n\n return\n }\n\n // reject early since server's response is invalid\n if (\"error\" in message === \"result\" in message)\n this.queue[message.id].promise[1](\n new Error(\n \"Server response malformed. Response must include either \\\"result\\\"\" +\n \" or \\\"error\\\", but not both.\"\n )\n )\n\n if (this.queue[message.id].timeout)\n clearTimeout(this.queue[message.id].timeout)\n\n if (message.error) this.queue[message.id].promise[1](message.error)\n else this.queue[message.id].promise[0](message.result)\n\n delete this.queue[message.id]\n })\n\n this.socket.addEventListener(\"error\", (error) => this.emit(\"error\", error))\n\n this.socket.addEventListener(\"close\", ({ code, reason }) =>\n {\n if (this.ready)\n // Delay close event until internal state is updated\n setTimeout(() => this.emit(\"close\", code, reason), 0)\n\n this.ready = false\n this.socket = undefined\n\n if (code === 1000) return\n\n this.current_reconnects++\n\n if (\n this.reconnect &&\n (this.max_reconnects > this.current_reconnects ||\n this.max_reconnects === 0)\n )\n this.reconnect_timer_id = setTimeout(\n () => this._connect(address, options),\n this.reconnect_interval\n )\n })\n }\n}\n","\"use strict\"\n\nexport interface DataPack<\n T,\n R extends string | ArrayBufferLike | Blob | ArrayBufferView\n> {\n encode(value: T): R;\n decode(value: R): T;\n}\n\nexport class DefaultDataPack implements DataPack\n{\n encode(value: Object): string\n {\n return JSON.stringify(value)\n }\n\n decode(value: string): Object\n {\n return JSON.parse(value)\n }\n}\n","\"use strict\"\n\nimport { WebSocket } from \"./lib/client/websocket.browser.js\"\nimport { CommonClient } from \"./lib/client.js\"\nimport { IWSClientAdditionalOptions } from \"./lib/client/client.types.js\"\n\nexport class Client extends CommonClient\n{\n constructor(\n address = \"ws://localhost:8080\",\n {\n autoconnect = true,\n reconnect = true,\n reconnect_interval = 1000,\n max_reconnects = 5,\n }: IWSClientAdditionalOptions = {},\n generate_request_id?: (\n method: string,\n params: object | Array\n ) => number\n )\n {\n super(\n WebSocket,\n address,\n {\n autoconnect,\n reconnect,\n reconnect_interval,\n max_reconnects,\n },\n generate_request_id\n )\n }\n}\n\nexport * from \"./lib/client.js\"\nexport * from \"./lib/client/websocket.browser.js\"\nexport * from \"./lib/client/client.types.js\"\nexport * from \"./lib/utils.js\"\n","'use strict';\n\nvar has = Object.prototype.hasOwnProperty\n , prefix = '~';\n\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @private\n */\nfunction Events() {}\n\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n Events.prototype = Object.create(null);\n\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new Events().__proto__) prefix = false;\n}\n\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @private\n */\nfunction EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n\n/**\n * Add a listener for a given event.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} once Specify if the listener is a one-time listener.\n * @returns {EventEmitter}\n * @private\n */\nfunction addListener(emitter, event, fn, context, once) {\n if (typeof fn !== 'function') {\n throw new TypeError('The listener must be a function');\n }\n\n var listener = new EE(fn, context || emitter, once)\n , evt = prefix ? prefix + event : event;\n\n if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;\n else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);\n else emitter._events[evt] = [emitter._events[evt], listener];\n\n return emitter;\n}\n\n/**\n * Clear event by name.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} evt The Event name.\n * @private\n */\nfunction clearEvent(emitter, evt) {\n if (--emitter._eventsCount === 0) emitter._events = new Events();\n else delete emitter._events[evt];\n}\n\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @public\n */\nfunction EventEmitter() {\n this._events = new Events();\n this._eventsCount = 0;\n}\n\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @public\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n var names = []\n , events\n , name;\n\n if (this._eventsCount === 0) return names;\n\n for (name in (events = this._events)) {\n if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);\n }\n\n if (Object.getOwnPropertySymbols) {\n return names.concat(Object.getOwnPropertySymbols(events));\n }\n\n return names;\n};\n\n/**\n * Return the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Array} The registered listeners.\n * @public\n */\nEventEmitter.prototype.listeners = function listeners(event) {\n var evt = prefix ? prefix + event : event\n , handlers = this._events[evt];\n\n if (!handlers) return [];\n if (handlers.fn) return [handlers.fn];\n\n for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {\n ee[i] = handlers[i].fn;\n }\n\n return ee;\n};\n\n/**\n * Return the number of listeners listening to a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Number} The number of listeners.\n * @public\n */\nEventEmitter.prototype.listenerCount = function listenerCount(event) {\n var evt = prefix ? prefix + event : event\n , listeners = this._events[evt];\n\n if (!listeners) return 0;\n if (listeners.fn) return 1;\n return listeners.length;\n};\n\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return false;\n\n var listeners = this._events[evt]\n , len = arguments.length\n , args\n , i;\n\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n switch (len) {\n case 1: return listeners.fn.call(listeners.context), true;\n case 2: return listeners.fn.call(listeners.context, a1), true;\n case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n\n for (i = 1, args = new Array(len -1); i < len; i++) {\n args[i - 1] = arguments[i];\n }\n\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length\n , j;\n\n for (i = 0; i < length; i++) {\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n switch (len) {\n case 1: listeners[i].fn.call(listeners[i].context); break;\n case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;\n default:\n if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {\n args[j - 1] = arguments[j];\n }\n\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n\n return true;\n};\n\n/**\n * Add a listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n return addListener(this, event, fn, context, false);\n};\n\n/**\n * Add a one-time listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n return addListener(this, event, fn, context, true);\n};\n\n/**\n * Remove the listeners of a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {*} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return this;\n if (!fn) {\n clearEvent(this, evt);\n return this;\n }\n\n var listeners = this._events[evt];\n\n if (listeners.fn) {\n if (\n listeners.fn === fn &&\n (!once || listeners.once) &&\n (!context || listeners.context === context)\n ) {\n clearEvent(this, evt);\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (\n listeners[i].fn !== fn ||\n (once && !listeners[i].once) ||\n (context && listeners[i].context !== context)\n ) {\n events.push(listeners[i]);\n }\n }\n\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else clearEvent(this, evt);\n }\n\n return this;\n};\n\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {(String|Symbol)} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n\n if (event) {\n evt = prefix ? prefix + event : event;\n if (this._events[evt]) clearEvent(this, evt);\n } else {\n this._events = new Events();\n this._eventsCount = 0;\n }\n\n return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\nEventEmitter.EventEmitter = EventEmitter;\n\n//\n// Expose the module.\n//\nif ('undefined' !== typeof module) {\n module.exports = EventEmitter;\n}\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.shake256 = exports.shake128 = exports.keccak_512 = exports.keccak_384 = exports.keccak_256 = exports.keccak_224 = exports.sha3_512 = exports.sha3_384 = exports.sha3_256 = exports.sha3_224 = exports.Keccak = void 0;\nexports.keccakP = keccakP;\n/**\n * SHA3 (keccak) hash function, based on a new \"Sponge function\" design.\n * Different from older hashes, the internal state is bigger than output size.\n *\n * Check out [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf),\n * [Website](https://keccak.team/keccak.html),\n * [the differences between SHA-3 and Keccak](https://crypto.stackexchange.com/questions/15727/what-are-the-key-differences-between-the-draft-sha-3-standard-and-the-keccak-sub).\n *\n * Check out `sha3-addons` module for cSHAKE, k12, and others.\n * @module\n */\nconst _assert_js_1 = require(\"./_assert.js\");\nconst _u64_js_1 = require(\"./_u64.js\");\nconst utils_js_1 = require(\"./utils.js\");\n// Various per round constants calculations\nconst SHA3_PI = [];\nconst SHA3_ROTL = [];\nconst _SHA3_IOTA = [];\nconst _0n = /* @__PURE__ */ BigInt(0);\nconst _1n = /* @__PURE__ */ BigInt(1);\nconst _2n = /* @__PURE__ */ BigInt(2);\nconst _7n = /* @__PURE__ */ BigInt(7);\nconst _256n = /* @__PURE__ */ BigInt(256);\nconst _0x71n = /* @__PURE__ */ BigInt(0x71);\nfor (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {\n // Pi\n [x, y] = [y, (2 * x + 3 * y) % 5];\n SHA3_PI.push(2 * (5 * y + x));\n // Rotational\n SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);\n // Iota\n let t = _0n;\n for (let j = 0; j < 7; j++) {\n R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;\n if (R & _2n)\n t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n);\n }\n _SHA3_IOTA.push(t);\n}\nconst [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ (0, _u64_js_1.split)(_SHA3_IOTA, true);\n// Left rotation (without 0, 32, 64)\nconst rotlH = (h, l, s) => (s > 32 ? (0, _u64_js_1.rotlBH)(h, l, s) : (0, _u64_js_1.rotlSH)(h, l, s));\nconst rotlL = (h, l, s) => (s > 32 ? (0, _u64_js_1.rotlBL)(h, l, s) : (0, _u64_js_1.rotlSL)(h, l, s));\n/** `keccakf1600` internal function, additionally allows to adjust round count. */\nfunction keccakP(s, rounds = 24) {\n const B = new Uint32Array(5 * 2);\n // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)\n for (let round = 24 - rounds; round < 24; round++) {\n // Theta θ\n for (let x = 0; x < 10; x++)\n B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];\n for (let x = 0; x < 10; x += 2) {\n const idx1 = (x + 8) % 10;\n const idx0 = (x + 2) % 10;\n const B0 = B[idx0];\n const B1 = B[idx0 + 1];\n const Th = rotlH(B0, B1, 1) ^ B[idx1];\n const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];\n for (let y = 0; y < 50; y += 10) {\n s[x + y] ^= Th;\n s[x + y + 1] ^= Tl;\n }\n }\n // Rho (ρ) and Pi (π)\n let curH = s[2];\n let curL = s[3];\n for (let t = 0; t < 24; t++) {\n const shift = SHA3_ROTL[t];\n const Th = rotlH(curH, curL, shift);\n const Tl = rotlL(curH, curL, shift);\n const PI = SHA3_PI[t];\n curH = s[PI];\n curL = s[PI + 1];\n s[PI] = Th;\n s[PI + 1] = Tl;\n }\n // Chi (χ)\n for (let y = 0; y < 50; y += 10) {\n for (let x = 0; x < 10; x++)\n B[x] = s[y + x];\n for (let x = 0; x < 10; x++)\n s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];\n }\n // Iota (ι)\n s[0] ^= SHA3_IOTA_H[round];\n s[1] ^= SHA3_IOTA_L[round];\n }\n B.fill(0);\n}\n/** Keccak sponge function. */\nclass Keccak extends utils_js_1.Hash {\n // NOTE: we accept arguments in bytes instead of bits here.\n constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {\n super();\n this.blockLen = blockLen;\n this.suffix = suffix;\n this.outputLen = outputLen;\n this.enableXOF = enableXOF;\n this.rounds = rounds;\n this.pos = 0;\n this.posOut = 0;\n this.finished = false;\n this.destroyed = false;\n // Can be passed from user as dkLen\n (0, _assert_js_1.anumber)(outputLen);\n // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes\n // 0 < blockLen < 200\n if (0 >= this.blockLen || this.blockLen >= 200)\n throw new Error('Sha3 supports only keccak-f1600 function');\n this.state = new Uint8Array(200);\n this.state32 = (0, utils_js_1.u32)(this.state);\n }\n keccak() {\n if (!utils_js_1.isLE)\n (0, utils_js_1.byteSwap32)(this.state32);\n keccakP(this.state32, this.rounds);\n if (!utils_js_1.isLE)\n (0, utils_js_1.byteSwap32)(this.state32);\n this.posOut = 0;\n this.pos = 0;\n }\n update(data) {\n (0, _assert_js_1.aexists)(this);\n const { blockLen, state } = this;\n data = (0, utils_js_1.toBytes)(data);\n const len = data.length;\n for (let pos = 0; pos < len;) {\n const take = Math.min(blockLen - this.pos, len - pos);\n for (let i = 0; i < take; i++)\n state[this.pos++] ^= data[pos++];\n if (this.pos === blockLen)\n this.keccak();\n }\n return this;\n }\n finish() {\n if (this.finished)\n return;\n this.finished = true;\n const { state, suffix, pos, blockLen } = this;\n // Do the padding\n state[pos] ^= suffix;\n if ((suffix & 0x80) !== 0 && pos === blockLen - 1)\n this.keccak();\n state[blockLen - 1] ^= 0x80;\n this.keccak();\n }\n writeInto(out) {\n (0, _assert_js_1.aexists)(this, false);\n (0, _assert_js_1.abytes)(out);\n this.finish();\n const bufferOut = this.state;\n const { blockLen } = this;\n for (let pos = 0, len = out.length; pos < len;) {\n if (this.posOut >= blockLen)\n this.keccak();\n const take = Math.min(blockLen - this.posOut, len - pos);\n out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);\n this.posOut += take;\n pos += take;\n }\n return out;\n }\n xofInto(out) {\n // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF\n if (!this.enableXOF)\n throw new Error('XOF is not possible for this instance');\n return this.writeInto(out);\n }\n xof(bytes) {\n (0, _assert_js_1.anumber)(bytes);\n return this.xofInto(new Uint8Array(bytes));\n }\n digestInto(out) {\n (0, _assert_js_1.aoutput)(out, this);\n if (this.finished)\n throw new Error('digest() was already called');\n this.writeInto(out);\n this.destroy();\n return out;\n }\n digest() {\n return this.digestInto(new Uint8Array(this.outputLen));\n }\n destroy() {\n this.destroyed = true;\n this.state.fill(0);\n }\n _cloneInto(to) {\n const { blockLen, suffix, outputLen, rounds, enableXOF } = this;\n to || (to = new Keccak(blockLen, suffix, outputLen, enableXOF, rounds));\n to.state32.set(this.state32);\n to.pos = this.pos;\n to.posOut = this.posOut;\n to.finished = this.finished;\n to.rounds = rounds;\n // Suffix can change in cSHAKE\n to.suffix = suffix;\n to.outputLen = outputLen;\n to.enableXOF = enableXOF;\n to.destroyed = this.destroyed;\n return to;\n }\n}\nexports.Keccak = Keccak;\nconst gen = (suffix, blockLen, outputLen) => (0, utils_js_1.wrapConstructor)(() => new Keccak(blockLen, suffix, outputLen));\n/** SHA3-224 hash function. */\nexports.sha3_224 = gen(0x06, 144, 224 / 8);\n/** SHA3-256 hash function. Different from keccak-256. */\nexports.sha3_256 = gen(0x06, 136, 256 / 8);\n/** SHA3-384 hash function. */\nexports.sha3_384 = gen(0x06, 104, 384 / 8);\n/** SHA3-512 hash function. */\nexports.sha3_512 = gen(0x06, 72, 512 / 8);\n/** keccak-224 hash function. */\nexports.keccak_224 = gen(0x01, 144, 224 / 8);\n/** keccak-256 hash function. Different from SHA3-256. */\nexports.keccak_256 = gen(0x01, 136, 256 / 8);\n/** keccak-384 hash function. */\nexports.keccak_384 = gen(0x01, 104, 384 / 8);\n/** keccak-512 hash function. */\nexports.keccak_512 = gen(0x01, 72, 512 / 8);\nconst genShake = (suffix, blockLen, outputLen) => (0, utils_js_1.wrapXOFConstructorWithOpts)((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true));\n/** SHAKE128 XOF with 128-bit security. */\nexports.shake128 = genShake(0x1f, 168, 128 / 8);\n/** SHAKE256 XOF with 256-bit security. */\nexports.shake256 = genShake(0x1f, 136, 256 / 8);\n//# sourceMappingURL=sha3.js.map","/**\n * SHA3 (keccak) hash function, based on a new \"Sponge function\" design.\n * Different from older hashes, the internal state is bigger than output size.\n *\n * Check out [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf),\n * [Website](https://keccak.team/keccak.html),\n * [the differences between SHA-3 and Keccak](https://crypto.stackexchange.com/questions/15727/what-are-the-key-differences-between-the-draft-sha-3-standard-and-the-keccak-sub).\n *\n * Check out `sha3-addons` module for cSHAKE, k12, and others.\n * @module\n */\nimport { abytes, aexists, anumber, aoutput } from './_assert.js';\nimport { rotlBH, rotlBL, rotlSH, rotlSL, split } from './_u64.js';\nimport {\n byteSwap32,\n Hash,\n isLE,\n toBytes,\n u32,\n wrapConstructor,\n wrapXOFConstructorWithOpts,\n type CHash,\n type CHashXO,\n type HashXOF,\n type Input,\n} from './utils.js';\n\n// Various per round constants calculations\nconst SHA3_PI: number[] = [];\nconst SHA3_ROTL: number[] = [];\nconst _SHA3_IOTA: bigint[] = [];\nconst _0n = /* @__PURE__ */ BigInt(0);\nconst _1n = /* @__PURE__ */ BigInt(1);\nconst _2n = /* @__PURE__ */ BigInt(2);\nconst _7n = /* @__PURE__ */ BigInt(7);\nconst _256n = /* @__PURE__ */ BigInt(256);\nconst _0x71n = /* @__PURE__ */ BigInt(0x71);\nfor (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {\n // Pi\n [x, y] = [y, (2 * x + 3 * y) % 5];\n SHA3_PI.push(2 * (5 * y + x));\n // Rotational\n SHA3_ROTL.push((((round + 1) * (round + 2)) / 2) % 64);\n // Iota\n let t = _0n;\n for (let j = 0; j < 7; j++) {\n R = ((R << _1n) ^ ((R >> _7n) * _0x71n)) % _256n;\n if (R & _2n) t ^= _1n << ((_1n << /* @__PURE__ */ BigInt(j)) - _1n);\n }\n _SHA3_IOTA.push(t);\n}\nconst [SHA3_IOTA_H, SHA3_IOTA_L] = /* @__PURE__ */ split(_SHA3_IOTA, true);\n\n// Left rotation (without 0, 32, 64)\nconst rotlH = (h: number, l: number, s: number) => (s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s));\nconst rotlL = (h: number, l: number, s: number) => (s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s));\n\n/** `keccakf1600` internal function, additionally allows to adjust round count. */\nexport function keccakP(s: Uint32Array, rounds: number = 24): void {\n const B = new Uint32Array(5 * 2);\n // NOTE: all indices are x2 since we store state as u32 instead of u64 (bigints to slow in js)\n for (let round = 24 - rounds; round < 24; round++) {\n // Theta θ\n for (let x = 0; x < 10; x++) B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];\n for (let x = 0; x < 10; x += 2) {\n const idx1 = (x + 8) % 10;\n const idx0 = (x + 2) % 10;\n const B0 = B[idx0];\n const B1 = B[idx0 + 1];\n const Th = rotlH(B0, B1, 1) ^ B[idx1];\n const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];\n for (let y = 0; y < 50; y += 10) {\n s[x + y] ^= Th;\n s[x + y + 1] ^= Tl;\n }\n }\n // Rho (ρ) and Pi (π)\n let curH = s[2];\n let curL = s[3];\n for (let t = 0; t < 24; t++) {\n const shift = SHA3_ROTL[t];\n const Th = rotlH(curH, curL, shift);\n const Tl = rotlL(curH, curL, shift);\n const PI = SHA3_PI[t];\n curH = s[PI];\n curL = s[PI + 1];\n s[PI] = Th;\n s[PI + 1] = Tl;\n }\n // Chi (χ)\n for (let y = 0; y < 50; y += 10) {\n for (let x = 0; x < 10; x++) B[x] = s[y + x];\n for (let x = 0; x < 10; x++) s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];\n }\n // Iota (ι)\n s[0] ^= SHA3_IOTA_H[round];\n s[1] ^= SHA3_IOTA_L[round];\n }\n B.fill(0);\n}\n\n/** Keccak sponge function. */\nexport class Keccak extends Hash implements HashXOF {\n protected state: Uint8Array;\n protected pos = 0;\n protected posOut = 0;\n protected finished = false;\n protected state32: Uint32Array;\n protected destroyed = false;\n // NOTE: we accept arguments in bytes instead of bits here.\n constructor(\n public blockLen: number,\n public suffix: number,\n public outputLen: number,\n protected enableXOF = false,\n protected rounds: number = 24\n ) {\n super();\n // Can be passed from user as dkLen\n anumber(outputLen);\n // 1600 = 5x5 matrix of 64bit. 1600 bits === 200 bytes\n // 0 < blockLen < 200\n if (0 >= this.blockLen || this.blockLen >= 200)\n throw new Error('Sha3 supports only keccak-f1600 function');\n this.state = new Uint8Array(200);\n this.state32 = u32(this.state);\n }\n protected keccak(): void {\n if (!isLE) byteSwap32(this.state32);\n keccakP(this.state32, this.rounds);\n if (!isLE) byteSwap32(this.state32);\n this.posOut = 0;\n this.pos = 0;\n }\n update(data: Input): this {\n aexists(this);\n const { blockLen, state } = this;\n data = toBytes(data);\n const len = data.length;\n for (let pos = 0; pos < len; ) {\n const take = Math.min(blockLen - this.pos, len - pos);\n for (let i = 0; i < take; i++) state[this.pos++] ^= data[pos++];\n if (this.pos === blockLen) this.keccak();\n }\n return this;\n }\n protected finish(): void {\n if (this.finished) return;\n this.finished = true;\n const { state, suffix, pos, blockLen } = this;\n // Do the padding\n state[pos] ^= suffix;\n if ((suffix & 0x80) !== 0 && pos === blockLen - 1) this.keccak();\n state[blockLen - 1] ^= 0x80;\n this.keccak();\n }\n protected writeInto(out: Uint8Array): Uint8Array {\n aexists(this, false);\n abytes(out);\n this.finish();\n const bufferOut = this.state;\n const { blockLen } = this;\n for (let pos = 0, len = out.length; pos < len; ) {\n if (this.posOut >= blockLen) this.keccak();\n const take = Math.min(blockLen - this.posOut, len - pos);\n out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);\n this.posOut += take;\n pos += take;\n }\n return out;\n }\n xofInto(out: Uint8Array): Uint8Array {\n // Sha3/Keccak usage with XOF is probably mistake, only SHAKE instances can do XOF\n if (!this.enableXOF) throw new Error('XOF is not possible for this instance');\n return this.writeInto(out);\n }\n xof(bytes: number): Uint8Array {\n anumber(bytes);\n return this.xofInto(new Uint8Array(bytes));\n }\n digestInto(out: Uint8Array): Uint8Array {\n aoutput(out, this);\n if (this.finished) throw new Error('digest() was already called');\n this.writeInto(out);\n this.destroy();\n return out;\n }\n digest(): Uint8Array {\n return this.digestInto(new Uint8Array(this.outputLen));\n }\n destroy(): void {\n this.destroyed = true;\n this.state.fill(0);\n }\n _cloneInto(to?: Keccak): Keccak {\n const { blockLen, suffix, outputLen, rounds, enableXOF } = this;\n to ||= new Keccak(blockLen, suffix, outputLen, enableXOF, rounds);\n to.state32.set(this.state32);\n to.pos = this.pos;\n to.posOut = this.posOut;\n to.finished = this.finished;\n to.rounds = rounds;\n // Suffix can change in cSHAKE\n to.suffix = suffix;\n to.outputLen = outputLen;\n to.enableXOF = enableXOF;\n to.destroyed = this.destroyed;\n return to;\n }\n}\n\nconst gen = (suffix: number, blockLen: number, outputLen: number) =>\n wrapConstructor(() => new Keccak(blockLen, suffix, outputLen));\n\n/** SHA3-224 hash function. */\nexport const sha3_224: CHash = /* @__PURE__ */ gen(0x06, 144, 224 / 8);\n/** SHA3-256 hash function. Different from keccak-256. */\nexport const sha3_256: CHash = /* @__PURE__ */ gen(0x06, 136, 256 / 8);\n/** SHA3-384 hash function. */\nexport const sha3_384: CHash = /* @__PURE__ */ gen(0x06, 104, 384 / 8);\n/** SHA3-512 hash function. */\nexport const sha3_512: CHash = /* @__PURE__ */ gen(0x06, 72, 512 / 8);\n\n/** keccak-224 hash function. */\nexport const keccak_224: CHash = /* @__PURE__ */ gen(0x01, 144, 224 / 8);\n/** keccak-256 hash function. Different from SHA3-256. */\nexport const keccak_256: CHash = /* @__PURE__ */ gen(0x01, 136, 256 / 8);\n/** keccak-384 hash function. */\nexport const keccak_384: CHash = /* @__PURE__ */ gen(0x01, 104, 384 / 8);\n/** keccak-512 hash function. */\nexport const keccak_512: CHash = /* @__PURE__ */ gen(0x01, 72, 512 / 8);\n\nexport type ShakeOpts = { dkLen?: number };\n\nconst genShake = (suffix: number, blockLen: number, outputLen: number) =>\n wrapXOFConstructorWithOpts, ShakeOpts>(\n (opts: ShakeOpts = {}) =>\n new Keccak(blockLen, suffix, opts.dkLen === undefined ? outputLen : opts.dkLen, true)\n );\n\n/** SHAKE128 XOF with 128-bit security. */\nexport const shake128: CHashXO = /* @__PURE__ */ genShake(0x1f, 168, 128 / 8);\n/** SHAKE256 XOF with 256-bit security. */\nexport const shake256: CHashXO = /* @__PURE__ */ genShake(0x1f, 136, 256 / 8);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.encodeToCurve = exports.hashToCurve = exports.schnorr = exports.secp256k1 = void 0;\n/**\n * NIST secp256k1. See [pdf](https://www.secg.org/sec2-v2.pdf).\n *\n * Seems to be rigid (not backdoored)\n * [as per discussion](https://bitcointalk.org/index.php?topic=289795.msg3183975#msg3183975).\n *\n * secp256k1 belongs to Koblitz curves: it has efficiently computable endomorphism.\n * Endomorphism uses 2x less RAM, speeds up precomputation by 2x and ECDH / key recovery by 20%.\n * For precomputed wNAF it trades off 1/2 init time & 1/3 ram for 20% perf hit.\n * [See explanation](https://gist.github.com/paulmillr/eb670806793e84df628a7c434a873066).\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nconst sha256_1 = require(\"@noble/hashes/sha256\");\nconst utils_1 = require(\"@noble/hashes/utils\");\nconst _shortw_utils_js_1 = require(\"./_shortw_utils.js\");\nconst hash_to_curve_js_1 = require(\"./abstract/hash-to-curve.js\");\nconst modular_js_1 = require(\"./abstract/modular.js\");\nconst utils_js_1 = require(\"./abstract/utils.js\");\nconst weierstrass_js_1 = require(\"./abstract/weierstrass.js\");\nconst secp256k1P = BigInt('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f');\nconst secp256k1N = BigInt('0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141');\nconst _1n = BigInt(1);\nconst _2n = BigInt(2);\nconst divNearest = (a, b) => (a + b / _2n) / b;\n/**\n * √n = n^((p+1)/4) for fields p = 3 mod 4. We unwrap the loop and multiply bit-by-bit.\n * (P+1n/4n).toString(2) would produce bits [223x 1, 0, 22x 1, 4x 0, 11, 00]\n */\nfunction sqrtMod(y) {\n const P = secp256k1P;\n // prettier-ignore\n const _3n = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);\n // prettier-ignore\n const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88);\n const b2 = (y * y * y) % P; // x^3, 11\n const b3 = (b2 * b2 * y) % P; // x^7\n const b6 = ((0, modular_js_1.pow2)(b3, _3n, P) * b3) % P;\n const b9 = ((0, modular_js_1.pow2)(b6, _3n, P) * b3) % P;\n const b11 = ((0, modular_js_1.pow2)(b9, _2n, P) * b2) % P;\n const b22 = ((0, modular_js_1.pow2)(b11, _11n, P) * b11) % P;\n const b44 = ((0, modular_js_1.pow2)(b22, _22n, P) * b22) % P;\n const b88 = ((0, modular_js_1.pow2)(b44, _44n, P) * b44) % P;\n const b176 = ((0, modular_js_1.pow2)(b88, _88n, P) * b88) % P;\n const b220 = ((0, modular_js_1.pow2)(b176, _44n, P) * b44) % P;\n const b223 = ((0, modular_js_1.pow2)(b220, _3n, P) * b3) % P;\n const t1 = ((0, modular_js_1.pow2)(b223, _23n, P) * b22) % P;\n const t2 = ((0, modular_js_1.pow2)(t1, _6n, P) * b2) % P;\n const root = (0, modular_js_1.pow2)(t2, _2n, P);\n if (!Fpk1.eql(Fpk1.sqr(root), y))\n throw new Error('Cannot find square root');\n return root;\n}\nconst Fpk1 = (0, modular_js_1.Field)(secp256k1P, undefined, undefined, { sqrt: sqrtMod });\n/**\n * secp256k1 short weierstrass curve and ECDSA signatures over it.\n *\n * @example\n * import { secp256k1 } from '@noble/curves/secp256k1';\n *\n * const priv = secp256k1.utils.randomPrivateKey();\n * const pub = secp256k1.getPublicKey(priv);\n * const msg = new Uint8Array(32).fill(1); // message hash (not message) in ecdsa\n * const sig = secp256k1.sign(msg, priv); // `{prehash: true}` option is available\n * const isValid = secp256k1.verify(sig, msg, pub) === true;\n */\nexports.secp256k1 = (0, _shortw_utils_js_1.createCurve)({\n a: BigInt(0), // equation params: a, b\n b: BigInt(7),\n Fp: Fpk1, // Field's prime: 2n**256n - 2n**32n - 2n**9n - 2n**8n - 2n**7n - 2n**6n - 2n**4n - 1n\n n: secp256k1N, // Curve order, total count of valid points in the field\n // Base point (x, y) aka generator point\n Gx: BigInt('55066263022277343669578718895168534326250603453777594175500187360389116729240'),\n Gy: BigInt('32670510020758816978083085130507043184471273380659243275938904335757337482424'),\n h: BigInt(1), // Cofactor\n lowS: true, // Allow only low-S signatures by default in sign() and verify()\n endo: {\n // Endomorphism, see above\n beta: BigInt('0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee'),\n splitScalar: (k) => {\n const n = secp256k1N;\n const a1 = BigInt('0x3086d221a7d46bcde86c90e49284eb15');\n const b1 = -_1n * BigInt('0xe4437ed6010e88286f547fa90abfe4c3');\n const a2 = BigInt('0x114ca50f7a8e2f3f657c1108d9d44cfd8');\n const b2 = a1;\n const POW_2_128 = BigInt('0x100000000000000000000000000000000'); // (2n**128n).toString(16)\n const c1 = divNearest(b2 * k, n);\n const c2 = divNearest(-b1 * k, n);\n let k1 = (0, modular_js_1.mod)(k - c1 * a1 - c2 * a2, n);\n let k2 = (0, modular_js_1.mod)(-c1 * b1 - c2 * b2, n);\n const k1neg = k1 > POW_2_128;\n const k2neg = k2 > POW_2_128;\n if (k1neg)\n k1 = n - k1;\n if (k2neg)\n k2 = n - k2;\n if (k1 > POW_2_128 || k2 > POW_2_128) {\n throw new Error('splitScalar: Endomorphism failed, k=' + k);\n }\n return { k1neg, k1, k2neg, k2 };\n },\n },\n}, sha256_1.sha256);\n// Schnorr signatures are superior to ECDSA from above. Below is Schnorr-specific BIP0340 code.\n// https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki\nconst _0n = BigInt(0);\n/** An object mapping tags to their tagged hash prefix of [SHA256(tag) | SHA256(tag)] */\nconst TAGGED_HASH_PREFIXES = {};\nfunction taggedHash(tag, ...messages) {\n let tagP = TAGGED_HASH_PREFIXES[tag];\n if (tagP === undefined) {\n const tagH = (0, sha256_1.sha256)(Uint8Array.from(tag, (c) => c.charCodeAt(0)));\n tagP = (0, utils_js_1.concatBytes)(tagH, tagH);\n TAGGED_HASH_PREFIXES[tag] = tagP;\n }\n return (0, sha256_1.sha256)((0, utils_js_1.concatBytes)(tagP, ...messages));\n}\n// ECDSA compact points are 33-byte. Schnorr is 32: we strip first byte 0x02 or 0x03\nconst pointToBytes = (point) => point.toRawBytes(true).slice(1);\nconst numTo32b = (n) => (0, utils_js_1.numberToBytesBE)(n, 32);\nconst modP = (x) => (0, modular_js_1.mod)(x, secp256k1P);\nconst modN = (x) => (0, modular_js_1.mod)(x, secp256k1N);\nconst Point = exports.secp256k1.ProjectivePoint;\nconst GmulAdd = (Q, a, b) => Point.BASE.multiplyAndAddUnsafe(Q, a, b);\n// Calculate point, scalar and bytes\nfunction schnorrGetExtPubKey(priv) {\n let d_ = exports.secp256k1.utils.normPrivateKeyToScalar(priv); // same method executed in fromPrivateKey\n let p = Point.fromPrivateKey(d_); // P = d'⋅G; 0 < d' < n check is done inside\n const scalar = p.hasEvenY() ? d_ : modN(-d_);\n return { scalar: scalar, bytes: pointToBytes(p) };\n}\n/**\n * lift_x from BIP340. Convert 32-byte x coordinate to elliptic curve point.\n * @returns valid point checked for being on-curve\n */\nfunction lift_x(x) {\n (0, utils_js_1.aInRange)('x', x, _1n, secp256k1P); // Fail if x ≥ p.\n const xx = modP(x * x);\n const c = modP(xx * x + BigInt(7)); // Let c = x³ + 7 mod p.\n let y = sqrtMod(c); // Let y = c^(p+1)/4 mod p.\n if (y % _2n !== _0n)\n y = modP(-y); // Return the unique point P such that x(P) = x and\n const p = new Point(x, y, _1n); // y(P) = y if y mod 2 = 0 or y(P) = p-y otherwise.\n p.assertValidity();\n return p;\n}\nconst num = utils_js_1.bytesToNumberBE;\n/**\n * Create tagged hash, convert it to bigint, reduce modulo-n.\n */\nfunction challenge(...args) {\n return modN(num(taggedHash('BIP0340/challenge', ...args)));\n}\n/**\n * Schnorr public key is just `x` coordinate of Point as per BIP340.\n */\nfunction schnorrGetPublicKey(privateKey) {\n return schnorrGetExtPubKey(privateKey).bytes; // d'=int(sk). Fail if d'=0 or d'≥n. Ret bytes(d'⋅G)\n}\n/**\n * Creates Schnorr signature as per BIP340. Verifies itself before returning anything.\n * auxRand is optional and is not the sole source of k generation: bad CSPRNG won't be dangerous.\n */\nfunction schnorrSign(message, privateKey, auxRand = (0, utils_1.randomBytes)(32)) {\n const m = (0, utils_js_1.ensureBytes)('message', message);\n const { bytes: px, scalar: d } = schnorrGetExtPubKey(privateKey); // checks for isWithinCurveOrder\n const a = (0, utils_js_1.ensureBytes)('auxRand', auxRand, 32); // Auxiliary random data a: a 32-byte array\n const t = numTo32b(d ^ num(taggedHash('BIP0340/aux', a))); // Let t be the byte-wise xor of bytes(d) and hash/aux(a)\n const rand = taggedHash('BIP0340/nonce', t, px, m); // Let rand = hash/nonce(t || bytes(P) || m)\n const k_ = modN(num(rand)); // Let k' = int(rand) mod n\n if (k_ === _0n)\n throw new Error('sign failed: k is zero'); // Fail if k' = 0.\n const { bytes: rx, scalar: k } = schnorrGetExtPubKey(k_); // Let R = k'⋅G.\n const e = challenge(rx, px, m); // Let e = int(hash/challenge(bytes(R) || bytes(P) || m)) mod n.\n const sig = new Uint8Array(64); // Let sig = bytes(R) || bytes((k + ed) mod n).\n sig.set(rx, 0);\n sig.set(numTo32b(modN(k + e * d)), 32);\n // If Verify(bytes(P), m, sig) (see below) returns failure, abort\n if (!schnorrVerify(sig, m, px))\n throw new Error('sign: Invalid signature produced');\n return sig;\n}\n/**\n * Verifies Schnorr signature.\n * Will swallow errors & return false except for initial type validation of arguments.\n */\nfunction schnorrVerify(signature, message, publicKey) {\n const sig = (0, utils_js_1.ensureBytes)('signature', signature, 64);\n const m = (0, utils_js_1.ensureBytes)('message', message);\n const pub = (0, utils_js_1.ensureBytes)('publicKey', publicKey, 32);\n try {\n const P = lift_x(num(pub)); // P = lift_x(int(pk)); fail if that fails\n const r = num(sig.subarray(0, 32)); // Let r = int(sig[0:32]); fail if r ≥ p.\n if (!(0, utils_js_1.inRange)(r, _1n, secp256k1P))\n return false;\n const s = num(sig.subarray(32, 64)); // Let s = int(sig[32:64]); fail if s ≥ n.\n if (!(0, utils_js_1.inRange)(s, _1n, secp256k1N))\n return false;\n const e = challenge(numTo32b(r), pointToBytes(P), m); // int(challenge(bytes(r)||bytes(P)||m))%n\n const R = GmulAdd(P, s, modN(-e)); // R = s⋅G - e⋅P\n if (!R || !R.hasEvenY() || R.toAffine().x !== r)\n return false; // -eP == (n-e)P\n return true; // Fail if is_infinite(R) / not has_even_y(R) / x(R) ≠ r.\n }\n catch (error) {\n return false;\n }\n}\n/**\n * Schnorr signatures over secp256k1.\n * https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki\n * @example\n * import { schnorr } from '@noble/curves/secp256k1';\n * const priv = schnorr.utils.randomPrivateKey();\n * const pub = schnorr.getPublicKey(priv);\n * const msg = new TextEncoder().encode('hello');\n * const sig = schnorr.sign(msg, priv);\n * const isValid = schnorr.verify(sig, msg, pub);\n */\nexports.schnorr = (() => ({\n getPublicKey: schnorrGetPublicKey,\n sign: schnorrSign,\n verify: schnorrVerify,\n utils: {\n randomPrivateKey: exports.secp256k1.utils.randomPrivateKey,\n lift_x,\n pointToBytes,\n numberToBytesBE: utils_js_1.numberToBytesBE,\n bytesToNumberBE: utils_js_1.bytesToNumberBE,\n taggedHash,\n mod: modular_js_1.mod,\n },\n}))();\nconst isoMap = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.isogenyMap)(Fpk1, [\n // xNum\n [\n '0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7',\n '0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581',\n '0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262',\n '0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c',\n ],\n // xDen\n [\n '0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b',\n '0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14',\n '0x0000000000000000000000000000000000000000000000000000000000000001', // LAST 1\n ],\n // yNum\n [\n '0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c',\n '0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3',\n '0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931',\n '0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84',\n ],\n // yDen\n [\n '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b',\n '0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573',\n '0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f',\n '0x0000000000000000000000000000000000000000000000000000000000000001', // LAST 1\n ],\n].map((i) => i.map((j) => BigInt(j)))))();\nconst mapSWU = /* @__PURE__ */ (() => (0, weierstrass_js_1.mapToCurveSimpleSWU)(Fpk1, {\n A: BigInt('0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533'),\n B: BigInt('1771'),\n Z: Fpk1.create(BigInt('-11')),\n}))();\nconst htf = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.createHasher)(exports.secp256k1.ProjectivePoint, (scalars) => {\n const { x, y } = mapSWU(Fpk1.create(scalars[0]));\n return isoMap(x, y);\n}, {\n DST: 'secp256k1_XMD:SHA-256_SSWU_RO_',\n encodeDST: 'secp256k1_XMD:SHA-256_SSWU_NU_',\n p: Fpk1.ORDER,\n m: 1,\n k: 128,\n expand: 'xmd',\n hash: sha256_1.sha256,\n}))();\n/** secp256k1 hash-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */\nexports.hashToCurve = (() => htf.hashToCurve)();\n/** secp256k1 encode-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */\nexports.encodeToCurve = (() => htf.encodeToCurve)();\n//# sourceMappingURL=secp256k1.js.map","/**\n * NIST secp256k1. See [pdf](https://www.secg.org/sec2-v2.pdf).\n *\n * Seems to be rigid (not backdoored)\n * [as per discussion](https://bitcointalk.org/index.php?topic=289795.msg3183975#msg3183975).\n *\n * secp256k1 belongs to Koblitz curves: it has efficiently computable endomorphism.\n * Endomorphism uses 2x less RAM, speeds up precomputation by 2x and ECDH / key recovery by 20%.\n * For precomputed wNAF it trades off 1/2 init time & 1/3 ram for 20% perf hit.\n * [See explanation](https://gist.github.com/paulmillr/eb670806793e84df628a7c434a873066).\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nimport { sha256 } from '@noble/hashes/sha256';\nimport { randomBytes } from '@noble/hashes/utils';\nimport { createCurve, type CurveFnWithCreate } from './_shortw_utils.js';\nimport { createHasher, type HTFMethod, isogenyMap } from './abstract/hash-to-curve.js';\nimport { Field, mod, pow2 } from './abstract/modular.js';\nimport type { Hex, PrivKey } from './abstract/utils.js';\nimport {\n aInRange,\n bytesToNumberBE,\n concatBytes,\n ensureBytes,\n inRange,\n numberToBytesBE,\n} from './abstract/utils.js';\nimport { mapToCurveSimpleSWU, type ProjPointType as PointType } from './abstract/weierstrass.js';\n\nconst secp256k1P = BigInt('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f');\nconst secp256k1N = BigInt('0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141');\nconst _1n = BigInt(1);\nconst _2n = BigInt(2);\nconst divNearest = (a: bigint, b: bigint) => (a + b / _2n) / b;\n\n/**\n * √n = n^((p+1)/4) for fields p = 3 mod 4. We unwrap the loop and multiply bit-by-bit.\n * (P+1n/4n).toString(2) would produce bits [223x 1, 0, 22x 1, 4x 0, 11, 00]\n */\nfunction sqrtMod(y: bigint): bigint {\n const P = secp256k1P;\n // prettier-ignore\n const _3n = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);\n // prettier-ignore\n const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88);\n const b2 = (y * y * y) % P; // x^3, 11\n const b3 = (b2 * b2 * y) % P; // x^7\n const b6 = (pow2(b3, _3n, P) * b3) % P;\n const b9 = (pow2(b6, _3n, P) * b3) % P;\n const b11 = (pow2(b9, _2n, P) * b2) % P;\n const b22 = (pow2(b11, _11n, P) * b11) % P;\n const b44 = (pow2(b22, _22n, P) * b22) % P;\n const b88 = (pow2(b44, _44n, P) * b44) % P;\n const b176 = (pow2(b88, _88n, P) * b88) % P;\n const b220 = (pow2(b176, _44n, P) * b44) % P;\n const b223 = (pow2(b220, _3n, P) * b3) % P;\n const t1 = (pow2(b223, _23n, P) * b22) % P;\n const t2 = (pow2(t1, _6n, P) * b2) % P;\n const root = pow2(t2, _2n, P);\n if (!Fpk1.eql(Fpk1.sqr(root), y)) throw new Error('Cannot find square root');\n return root;\n}\n\nconst Fpk1 = Field(secp256k1P, undefined, undefined, { sqrt: sqrtMod });\n\n/**\n * secp256k1 short weierstrass curve and ECDSA signatures over it.\n *\n * @example\n * import { secp256k1 } from '@noble/curves/secp256k1';\n *\n * const priv = secp256k1.utils.randomPrivateKey();\n * const pub = secp256k1.getPublicKey(priv);\n * const msg = new Uint8Array(32).fill(1); // message hash (not message) in ecdsa\n * const sig = secp256k1.sign(msg, priv); // `{prehash: true}` option is available\n * const isValid = secp256k1.verify(sig, msg, pub) === true;\n */\nexport const secp256k1: CurveFnWithCreate = createCurve(\n {\n a: BigInt(0), // equation params: a, b\n b: BigInt(7),\n Fp: Fpk1, // Field's prime: 2n**256n - 2n**32n - 2n**9n - 2n**8n - 2n**7n - 2n**6n - 2n**4n - 1n\n n: secp256k1N, // Curve order, total count of valid points in the field\n // Base point (x, y) aka generator point\n Gx: BigInt('55066263022277343669578718895168534326250603453777594175500187360389116729240'),\n Gy: BigInt('32670510020758816978083085130507043184471273380659243275938904335757337482424'),\n h: BigInt(1), // Cofactor\n lowS: true, // Allow only low-S signatures by default in sign() and verify()\n endo: {\n // Endomorphism, see above\n beta: BigInt('0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee'),\n splitScalar: (k: bigint) => {\n const n = secp256k1N;\n const a1 = BigInt('0x3086d221a7d46bcde86c90e49284eb15');\n const b1 = -_1n * BigInt('0xe4437ed6010e88286f547fa90abfe4c3');\n const a2 = BigInt('0x114ca50f7a8e2f3f657c1108d9d44cfd8');\n const b2 = a1;\n const POW_2_128 = BigInt('0x100000000000000000000000000000000'); // (2n**128n).toString(16)\n\n const c1 = divNearest(b2 * k, n);\n const c2 = divNearest(-b1 * k, n);\n let k1 = mod(k - c1 * a1 - c2 * a2, n);\n let k2 = mod(-c1 * b1 - c2 * b2, n);\n const k1neg = k1 > POW_2_128;\n const k2neg = k2 > POW_2_128;\n if (k1neg) k1 = n - k1;\n if (k2neg) k2 = n - k2;\n if (k1 > POW_2_128 || k2 > POW_2_128) {\n throw new Error('splitScalar: Endomorphism failed, k=' + k);\n }\n return { k1neg, k1, k2neg, k2 };\n },\n },\n },\n sha256\n);\n\n// Schnorr signatures are superior to ECDSA from above. Below is Schnorr-specific BIP0340 code.\n// https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki\nconst _0n = BigInt(0);\n/** An object mapping tags to their tagged hash prefix of [SHA256(tag) | SHA256(tag)] */\nconst TAGGED_HASH_PREFIXES: { [tag: string]: Uint8Array } = {};\nfunction taggedHash(tag: string, ...messages: Uint8Array[]): Uint8Array {\n let tagP = TAGGED_HASH_PREFIXES[tag];\n if (tagP === undefined) {\n const tagH = sha256(Uint8Array.from(tag, (c) => c.charCodeAt(0)));\n tagP = concatBytes(tagH, tagH);\n TAGGED_HASH_PREFIXES[tag] = tagP;\n }\n return sha256(concatBytes(tagP, ...messages));\n}\n\n// ECDSA compact points are 33-byte. Schnorr is 32: we strip first byte 0x02 or 0x03\nconst pointToBytes = (point: PointType) => point.toRawBytes(true).slice(1);\nconst numTo32b = (n: bigint) => numberToBytesBE(n, 32);\nconst modP = (x: bigint) => mod(x, secp256k1P);\nconst modN = (x: bigint) => mod(x, secp256k1N);\nconst Point = secp256k1.ProjectivePoint;\nconst GmulAdd = (Q: PointType, a: bigint, b: bigint) =>\n Point.BASE.multiplyAndAddUnsafe(Q, a, b);\n\n// Calculate point, scalar and bytes\nfunction schnorrGetExtPubKey(priv: PrivKey) {\n let d_ = secp256k1.utils.normPrivateKeyToScalar(priv); // same method executed in fromPrivateKey\n let p = Point.fromPrivateKey(d_); // P = d'⋅G; 0 < d' < n check is done inside\n const scalar = p.hasEvenY() ? d_ : modN(-d_);\n return { scalar: scalar, bytes: pointToBytes(p) };\n}\n/**\n * lift_x from BIP340. Convert 32-byte x coordinate to elliptic curve point.\n * @returns valid point checked for being on-curve\n */\nfunction lift_x(x: bigint): PointType {\n aInRange('x', x, _1n, secp256k1P); // Fail if x ≥ p.\n const xx = modP(x * x);\n const c = modP(xx * x + BigInt(7)); // Let c = x³ + 7 mod p.\n let y = sqrtMod(c); // Let y = c^(p+1)/4 mod p.\n if (y % _2n !== _0n) y = modP(-y); // Return the unique point P such that x(P) = x and\n const p = new Point(x, y, _1n); // y(P) = y if y mod 2 = 0 or y(P) = p-y otherwise.\n p.assertValidity();\n return p;\n}\nconst num = bytesToNumberBE;\n/**\n * Create tagged hash, convert it to bigint, reduce modulo-n.\n */\nfunction challenge(...args: Uint8Array[]): bigint {\n return modN(num(taggedHash('BIP0340/challenge', ...args)));\n}\n\n/**\n * Schnorr public key is just `x` coordinate of Point as per BIP340.\n */\nfunction schnorrGetPublicKey(privateKey: Hex): Uint8Array {\n return schnorrGetExtPubKey(privateKey).bytes; // d'=int(sk). Fail if d'=0 or d'≥n. Ret bytes(d'⋅G)\n}\n\n/**\n * Creates Schnorr signature as per BIP340. Verifies itself before returning anything.\n * auxRand is optional and is not the sole source of k generation: bad CSPRNG won't be dangerous.\n */\nfunction schnorrSign(\n message: Hex,\n privateKey: PrivKey,\n auxRand: Hex = randomBytes(32)\n): Uint8Array {\n const m = ensureBytes('message', message);\n const { bytes: px, scalar: d } = schnorrGetExtPubKey(privateKey); // checks for isWithinCurveOrder\n const a = ensureBytes('auxRand', auxRand, 32); // Auxiliary random data a: a 32-byte array\n const t = numTo32b(d ^ num(taggedHash('BIP0340/aux', a))); // Let t be the byte-wise xor of bytes(d) and hash/aux(a)\n const rand = taggedHash('BIP0340/nonce', t, px, m); // Let rand = hash/nonce(t || bytes(P) || m)\n const k_ = modN(num(rand)); // Let k' = int(rand) mod n\n if (k_ === _0n) throw new Error('sign failed: k is zero'); // Fail if k' = 0.\n const { bytes: rx, scalar: k } = schnorrGetExtPubKey(k_); // Let R = k'⋅G.\n const e = challenge(rx, px, m); // Let e = int(hash/challenge(bytes(R) || bytes(P) || m)) mod n.\n const sig = new Uint8Array(64); // Let sig = bytes(R) || bytes((k + ed) mod n).\n sig.set(rx, 0);\n sig.set(numTo32b(modN(k + e * d)), 32);\n // If Verify(bytes(P), m, sig) (see below) returns failure, abort\n if (!schnorrVerify(sig, m, px)) throw new Error('sign: Invalid signature produced');\n return sig;\n}\n\n/**\n * Verifies Schnorr signature.\n * Will swallow errors & return false except for initial type validation of arguments.\n */\nfunction schnorrVerify(signature: Hex, message: Hex, publicKey: Hex): boolean {\n const sig = ensureBytes('signature', signature, 64);\n const m = ensureBytes('message', message);\n const pub = ensureBytes('publicKey', publicKey, 32);\n try {\n const P = lift_x(num(pub)); // P = lift_x(int(pk)); fail if that fails\n const r = num(sig.subarray(0, 32)); // Let r = int(sig[0:32]); fail if r ≥ p.\n if (!inRange(r, _1n, secp256k1P)) return false;\n const s = num(sig.subarray(32, 64)); // Let s = int(sig[32:64]); fail if s ≥ n.\n if (!inRange(s, _1n, secp256k1N)) return false;\n const e = challenge(numTo32b(r), pointToBytes(P), m); // int(challenge(bytes(r)||bytes(P)||m))%n\n const R = GmulAdd(P, s, modN(-e)); // R = s⋅G - e⋅P\n if (!R || !R.hasEvenY() || R.toAffine().x !== r) return false; // -eP == (n-e)P\n return true; // Fail if is_infinite(R) / not has_even_y(R) / x(R) ≠ r.\n } catch (error) {\n return false;\n }\n}\n\nexport type SecpSchnorr = {\n getPublicKey: typeof schnorrGetPublicKey;\n sign: typeof schnorrSign;\n verify: typeof schnorrVerify;\n utils: {\n randomPrivateKey: () => Uint8Array;\n lift_x: typeof lift_x;\n pointToBytes: (point: PointType) => Uint8Array;\n numberToBytesBE: typeof numberToBytesBE;\n bytesToNumberBE: typeof bytesToNumberBE;\n taggedHash: typeof taggedHash;\n mod: typeof mod;\n };\n};\n/**\n * Schnorr signatures over secp256k1.\n * https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki\n * @example\n * import { schnorr } from '@noble/curves/secp256k1';\n * const priv = schnorr.utils.randomPrivateKey();\n * const pub = schnorr.getPublicKey(priv);\n * const msg = new TextEncoder().encode('hello');\n * const sig = schnorr.sign(msg, priv);\n * const isValid = schnorr.verify(sig, msg, pub);\n */\nexport const schnorr: SecpSchnorr = /* @__PURE__ */ (() => ({\n getPublicKey: schnorrGetPublicKey,\n sign: schnorrSign,\n verify: schnorrVerify,\n utils: {\n randomPrivateKey: secp256k1.utils.randomPrivateKey,\n lift_x,\n pointToBytes,\n numberToBytesBE,\n bytesToNumberBE,\n taggedHash,\n mod,\n },\n}))();\n\nconst isoMap = /* @__PURE__ */ (() =>\n isogenyMap(\n Fpk1,\n [\n // xNum\n [\n '0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7',\n '0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581',\n '0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262',\n '0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c',\n ],\n // xDen\n [\n '0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b',\n '0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14',\n '0x0000000000000000000000000000000000000000000000000000000000000001', // LAST 1\n ],\n // yNum\n [\n '0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c',\n '0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3',\n '0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931',\n '0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84',\n ],\n // yDen\n [\n '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b',\n '0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573',\n '0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f',\n '0x0000000000000000000000000000000000000000000000000000000000000001', // LAST 1\n ],\n ].map((i) => i.map((j) => BigInt(j))) as [bigint[], bigint[], bigint[], bigint[]]\n ))();\nconst mapSWU = /* @__PURE__ */ (() =>\n mapToCurveSimpleSWU(Fpk1, {\n A: BigInt('0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533'),\n B: BigInt('1771'),\n Z: Fpk1.create(BigInt('-11')),\n }))();\nconst htf = /* @__PURE__ */ (() =>\n createHasher(\n secp256k1.ProjectivePoint,\n (scalars: bigint[]) => {\n const { x, y } = mapSWU(Fpk1.create(scalars[0]));\n return isoMap(x, y);\n },\n {\n DST: 'secp256k1_XMD:SHA-256_SSWU_RO_',\n encodeDST: 'secp256k1_XMD:SHA-256_SSWU_NU_',\n p: Fpk1.ORDER,\n m: 1,\n k: 128,\n expand: 'xmd',\n hash: sha256,\n }\n ))();\n\n/** secp256k1 hash-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */\nexport const hashToCurve: HTFMethod = /* @__PURE__ */ (() => htf.hashToCurve)();\n\n/** secp256k1 encode-to-curve from [RFC 9380](https://www.rfc-editor.org/rfc/rfc9380). */\nexport const encodeToCurve: HTFMethod = /* @__PURE__ */ (() => htf.encodeToCurve)();\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getHash = getHash;\nexports.createCurve = createCurve;\n/**\n * Utilities for short weierstrass curves, combined with noble-hashes.\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nconst hmac_1 = require(\"@noble/hashes/hmac\");\nconst utils_1 = require(\"@noble/hashes/utils\");\nconst weierstrass_js_1 = require(\"./abstract/weierstrass.js\");\n/** connects noble-curves to noble-hashes */\nfunction getHash(hash) {\n return {\n hash,\n hmac: (key, ...msgs) => (0, hmac_1.hmac)(hash, key, (0, utils_1.concatBytes)(...msgs)),\n randomBytes: utils_1.randomBytes,\n };\n}\nfunction createCurve(curveDef, defHash) {\n const create = (hash) => (0, weierstrass_js_1.weierstrass)({ ...curveDef, ...getHash(hash) });\n return { ...create(defHash), create };\n}\n//# sourceMappingURL=_shortw_utils.js.map","/**\n * Utilities for short weierstrass curves, combined with noble-hashes.\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nimport { hmac } from '@noble/hashes/hmac';\nimport { concatBytes, randomBytes } from '@noble/hashes/utils';\nimport type { CHash } from './abstract/utils.js';\nimport { type CurveFn, type CurveType, weierstrass } from './abstract/weierstrass.js';\n\n/** connects noble-curves to noble-hashes */\nexport function getHash(hash: CHash): {\n hash: CHash;\n hmac: (key: Uint8Array, ...msgs: Uint8Array[]) => Uint8Array;\n randomBytes: typeof randomBytes;\n} {\n return {\n hash,\n hmac: (key: Uint8Array, ...msgs: Uint8Array[]) => hmac(hash, key, concatBytes(...msgs)),\n randomBytes,\n };\n}\n/** Same API as @noble/hashes, with ability to create curve with custom hash */\nexport type CurveDef = Readonly>;\nexport type CurveFnWithCreate = CurveFn & { create: (hash: CHash) => CurveFn };\n\nexport function createCurve(curveDef: CurveDef, defHash: CHash): CurveFnWithCreate {\n const create = (hash: CHash): CurveFn => weierstrass({ ...curveDef, ...getHash(hash) });\n return { ...create(defHash), create };\n}\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.hmac = exports.HMAC = void 0;\n/**\n * HMAC: RFC2104 message authentication code.\n * @module\n */\nconst _assert_js_1 = require(\"./_assert.js\");\nconst utils_js_1 = require(\"./utils.js\");\nclass HMAC extends utils_js_1.Hash {\n constructor(hash, _key) {\n super();\n this.finished = false;\n this.destroyed = false;\n (0, _assert_js_1.ahash)(hash);\n const key = (0, utils_js_1.toBytes)(_key);\n this.iHash = hash.create();\n if (typeof this.iHash.update !== 'function')\n throw new Error('Expected instance of class which extends utils.Hash');\n this.blockLen = this.iHash.blockLen;\n this.outputLen = this.iHash.outputLen;\n const blockLen = this.blockLen;\n const pad = new Uint8Array(blockLen);\n // blockLen can be bigger than outputLen\n pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);\n for (let i = 0; i < pad.length; i++)\n pad[i] ^= 0x36;\n this.iHash.update(pad);\n // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone\n this.oHash = hash.create();\n // Undo internal XOR && apply outer XOR\n for (let i = 0; i < pad.length; i++)\n pad[i] ^= 0x36 ^ 0x5c;\n this.oHash.update(pad);\n pad.fill(0);\n }\n update(buf) {\n (0, _assert_js_1.aexists)(this);\n this.iHash.update(buf);\n return this;\n }\n digestInto(out) {\n (0, _assert_js_1.aexists)(this);\n (0, _assert_js_1.abytes)(out, this.outputLen);\n this.finished = true;\n this.iHash.digestInto(out);\n this.oHash.update(out);\n this.oHash.digestInto(out);\n this.destroy();\n }\n digest() {\n const out = new Uint8Array(this.oHash.outputLen);\n this.digestInto(out);\n return out;\n }\n _cloneInto(to) {\n // Create new instance without calling constructor since key already in state and we don't know it.\n to || (to = Object.create(Object.getPrototypeOf(this), {}));\n const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;\n to = to;\n to.finished = finished;\n to.destroyed = destroyed;\n to.blockLen = blockLen;\n to.outputLen = outputLen;\n to.oHash = oHash._cloneInto(to.oHash);\n to.iHash = iHash._cloneInto(to.iHash);\n return to;\n }\n destroy() {\n this.destroyed = true;\n this.oHash.destroy();\n this.iHash.destroy();\n }\n}\nexports.HMAC = HMAC;\n/**\n * HMAC: RFC2104 message authentication code.\n * @param hash - function that would be used e.g. sha256\n * @param key - message key\n * @param message - message data\n * @example\n * import { hmac } from '@noble/hashes/hmac';\n * import { sha256 } from '@noble/hashes/sha2';\n * const mac1 = hmac(sha256, 'key', 'message');\n */\nconst hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();\nexports.hmac = hmac;\nexports.hmac.create = (hash, key) => new HMAC(hash, key);\n//# sourceMappingURL=hmac.js.map","/**\n * HMAC: RFC2104 message authentication code.\n * @module\n */\nimport { abytes, aexists, ahash } from './_assert.js';\nimport { Hash, toBytes, type CHash, type Input } from './utils.js';\n\nexport class HMAC> extends Hash> {\n oHash: T;\n iHash: T;\n blockLen: number;\n outputLen: number;\n private finished = false;\n private destroyed = false;\n\n constructor(hash: CHash, _key: Input) {\n super();\n ahash(hash);\n const key = toBytes(_key);\n this.iHash = hash.create() as T;\n if (typeof this.iHash.update !== 'function')\n throw new Error('Expected instance of class which extends utils.Hash');\n this.blockLen = this.iHash.blockLen;\n this.outputLen = this.iHash.outputLen;\n const blockLen = this.blockLen;\n const pad = new Uint8Array(blockLen);\n // blockLen can be bigger than outputLen\n pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);\n for (let i = 0; i < pad.length; i++) pad[i] ^= 0x36;\n this.iHash.update(pad);\n // By doing update (processing of first block) of outer hash here we can re-use it between multiple calls via clone\n this.oHash = hash.create() as T;\n // Undo internal XOR && apply outer XOR\n for (let i = 0; i < pad.length; i++) pad[i] ^= 0x36 ^ 0x5c;\n this.oHash.update(pad);\n pad.fill(0);\n }\n update(buf: Input): this {\n aexists(this);\n this.iHash.update(buf);\n return this;\n }\n digestInto(out: Uint8Array): void {\n aexists(this);\n abytes(out, this.outputLen);\n this.finished = true;\n this.iHash.digestInto(out);\n this.oHash.update(out);\n this.oHash.digestInto(out);\n this.destroy();\n }\n digest(): Uint8Array {\n const out = new Uint8Array(this.oHash.outputLen);\n this.digestInto(out);\n return out;\n }\n _cloneInto(to?: HMAC): HMAC {\n // Create new instance without calling constructor since key already in state and we don't know it.\n to ||= Object.create(Object.getPrototypeOf(this), {});\n const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;\n to = to as this;\n to.finished = finished;\n to.destroyed = destroyed;\n to.blockLen = blockLen;\n to.outputLen = outputLen;\n to.oHash = oHash._cloneInto(to.oHash);\n to.iHash = iHash._cloneInto(to.iHash);\n return to;\n }\n destroy(): void {\n this.destroyed = true;\n this.oHash.destroy();\n this.iHash.destroy();\n }\n}\n\n/**\n * HMAC: RFC2104 message authentication code.\n * @param hash - function that would be used e.g. sha256\n * @param key - message key\n * @param message - message data\n * @example\n * import { hmac } from '@noble/hashes/hmac';\n * import { sha256 } from '@noble/hashes/sha2';\n * const mac1 = hmac(sha256, 'key', 'message');\n */\nexport const hmac: {\n (hash: CHash, key: Input, message: Input): Uint8Array;\n create(hash: CHash, key: Input): HMAC;\n} = (hash: CHash, key: Input, message: Input): Uint8Array =>\n new HMAC(hash, key).update(message).digest();\nhmac.create = (hash: CHash, key: Input) => new HMAC(hash, key);\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.DER = exports.DERErr = void 0;\nexports.weierstrassPoints = weierstrassPoints;\nexports.weierstrass = weierstrass;\nexports.SWUFpSqrtRatio = SWUFpSqrtRatio;\nexports.mapToCurveSimpleSWU = mapToCurveSimpleSWU;\n/**\n * Short Weierstrass curve methods. The formula is: y² = x³ + ax + b.\n *\n * ### Design rationale for types\n *\n * * Interaction between classes from different curves should fail:\n * `k256.Point.BASE.add(p256.Point.BASE)`\n * * For this purpose we want to use `instanceof` operator, which is fast and works during runtime\n * * Different calls of `curve()` would return different classes -\n * `curve(params) !== curve(params)`: if somebody decided to monkey-patch their curve,\n * it won't affect others\n *\n * TypeScript can't infer types for classes created inside a function. Classes is one instance\n * of nominative types in TypeScript and interfaces only check for shape, so it's hard to create\n * unique type for every function call.\n *\n * We can use generic types via some param, like curve opts, but that would:\n * 1. Enable interaction between `curve(params)` and `curve(params)` (curves of same params)\n * which is hard to debug.\n * 2. Params can be generic and we can't enforce them to be constant value:\n * if somebody creates curve from non-constant params,\n * it would be allowed to interact with other curves with non-constant params\n *\n * @todo https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#unique-symbol\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nconst curve_js_1 = require(\"./curve.js\");\nconst modular_js_1 = require(\"./modular.js\");\nconst ut = require(\"./utils.js\");\nconst utils_js_1 = require(\"./utils.js\");\nfunction validateSigVerOpts(opts) {\n if (opts.lowS !== undefined)\n (0, utils_js_1.abool)('lowS', opts.lowS);\n if (opts.prehash !== undefined)\n (0, utils_js_1.abool)('prehash', opts.prehash);\n}\nfunction validatePointOpts(curve) {\n const opts = (0, curve_js_1.validateBasic)(curve);\n ut.validateObject(opts, {\n a: 'field',\n b: 'field',\n }, {\n allowedPrivateKeyLengths: 'array',\n wrapPrivateKey: 'boolean',\n isTorsionFree: 'function',\n clearCofactor: 'function',\n allowInfinityPoint: 'boolean',\n fromBytes: 'function',\n toBytes: 'function',\n });\n const { endo, Fp, a } = opts;\n if (endo) {\n if (!Fp.eql(a, Fp.ZERO)) {\n throw new Error('invalid endomorphism, can only be defined for Koblitz curves that have a=0');\n }\n if (typeof endo !== 'object' ||\n typeof endo.beta !== 'bigint' ||\n typeof endo.splitScalar !== 'function') {\n throw new Error('invalid endomorphism, expected beta: bigint and splitScalar: function');\n }\n }\n return Object.freeze({ ...opts });\n}\nconst { bytesToNumberBE: b2n, hexToBytes: h2b } = ut;\nclass DERErr extends Error {\n constructor(m = '') {\n super(m);\n }\n}\nexports.DERErr = DERErr;\n/**\n * ASN.1 DER encoding utilities. ASN is very complex & fragile. Format:\n *\n * [0x30 (SEQUENCE), bytelength, 0x02 (INTEGER), intLength, R, 0x02 (INTEGER), intLength, S]\n *\n * Docs: https://letsencrypt.org/docs/a-warm-welcome-to-asn1-and-der/, https://luca.ntop.org/Teaching/Appunti/asn1.html\n */\nexports.DER = {\n // asn.1 DER encoding utils\n Err: DERErr,\n // Basic building block is TLV (Tag-Length-Value)\n _tlv: {\n encode: (tag, data) => {\n const { Err: E } = exports.DER;\n if (tag < 0 || tag > 256)\n throw new E('tlv.encode: wrong tag');\n if (data.length & 1)\n throw new E('tlv.encode: unpadded data');\n const dataLen = data.length / 2;\n const len = ut.numberToHexUnpadded(dataLen);\n if ((len.length / 2) & 128)\n throw new E('tlv.encode: long form length too big');\n // length of length with long form flag\n const lenLen = dataLen > 127 ? ut.numberToHexUnpadded((len.length / 2) | 128) : '';\n const t = ut.numberToHexUnpadded(tag);\n return t + lenLen + len + data;\n },\n // v - value, l - left bytes (unparsed)\n decode(tag, data) {\n const { Err: E } = exports.DER;\n let pos = 0;\n if (tag < 0 || tag > 256)\n throw new E('tlv.encode: wrong tag');\n if (data.length < 2 || data[pos++] !== tag)\n throw new E('tlv.decode: wrong tlv');\n const first = data[pos++];\n const isLong = !!(first & 128); // First bit of first length byte is flag for short/long form\n let length = 0;\n if (!isLong)\n length = first;\n else {\n // Long form: [longFlag(1bit), lengthLength(7bit), length (BE)]\n const lenLen = first & 127;\n if (!lenLen)\n throw new E('tlv.decode(long): indefinite length not supported');\n if (lenLen > 4)\n throw new E('tlv.decode(long): byte length is too big'); // this will overflow u32 in js\n const lengthBytes = data.subarray(pos, pos + lenLen);\n if (lengthBytes.length !== lenLen)\n throw new E('tlv.decode: length bytes not complete');\n if (lengthBytes[0] === 0)\n throw new E('tlv.decode(long): zero leftmost byte');\n for (const b of lengthBytes)\n length = (length << 8) | b;\n pos += lenLen;\n if (length < 128)\n throw new E('tlv.decode(long): not minimal encoding');\n }\n const v = data.subarray(pos, pos + length);\n if (v.length !== length)\n throw new E('tlv.decode: wrong value length');\n return { v, l: data.subarray(pos + length) };\n },\n },\n // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,\n // since we always use positive integers here. It must always be empty:\n // - add zero byte if exists\n // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)\n _int: {\n encode(num) {\n const { Err: E } = exports.DER;\n if (num < _0n)\n throw new E('integer: negative integers are not allowed');\n let hex = ut.numberToHexUnpadded(num);\n // Pad with zero byte if negative flag is present\n if (Number.parseInt(hex[0], 16) & 0b1000)\n hex = '00' + hex;\n if (hex.length & 1)\n throw new E('unexpected DER parsing assertion: unpadded hex');\n return hex;\n },\n decode(data) {\n const { Err: E } = exports.DER;\n if (data[0] & 128)\n throw new E('invalid signature integer: negative');\n if (data[0] === 0x00 && !(data[1] & 128))\n throw new E('invalid signature integer: unnecessary leading zero');\n return b2n(data);\n },\n },\n toSig(hex) {\n // parse DER signature\n const { Err: E, _int: int, _tlv: tlv } = exports.DER;\n const data = typeof hex === 'string' ? h2b(hex) : hex;\n ut.abytes(data);\n const { v: seqBytes, l: seqLeftBytes } = tlv.decode(0x30, data);\n if (seqLeftBytes.length)\n throw new E('invalid signature: left bytes after parsing');\n const { v: rBytes, l: rLeftBytes } = tlv.decode(0x02, seqBytes);\n const { v: sBytes, l: sLeftBytes } = tlv.decode(0x02, rLeftBytes);\n if (sLeftBytes.length)\n throw new E('invalid signature: left bytes after parsing');\n return { r: int.decode(rBytes), s: int.decode(sBytes) };\n },\n hexFromSig(sig) {\n const { _tlv: tlv, _int: int } = exports.DER;\n const rs = tlv.encode(0x02, int.encode(sig.r));\n const ss = tlv.encode(0x02, int.encode(sig.s));\n const seq = rs + ss;\n return tlv.encode(0x30, seq);\n },\n};\n// Be friendly to bad ECMAScript parsers by not using bigint literals\n// prettier-ignore\nconst _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3), _4n = BigInt(4);\nfunction weierstrassPoints(opts) {\n const CURVE = validatePointOpts(opts);\n const { Fp } = CURVE; // All curves has same field / group length as for now, but they can differ\n const Fn = (0, modular_js_1.Field)(CURVE.n, CURVE.nBitLength);\n const toBytes = CURVE.toBytes ||\n ((_c, point, _isCompressed) => {\n const a = point.toAffine();\n return ut.concatBytes(Uint8Array.from([0x04]), Fp.toBytes(a.x), Fp.toBytes(a.y));\n });\n const fromBytes = CURVE.fromBytes ||\n ((bytes) => {\n // const head = bytes[0];\n const tail = bytes.subarray(1);\n // if (head !== 0x04) throw new Error('Only non-compressed encoding is supported');\n const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES));\n const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));\n return { x, y };\n });\n /**\n * y² = x³ + ax + b: Short weierstrass curve formula\n * @returns y²\n */\n function weierstrassEquation(x) {\n const { a, b } = CURVE;\n const x2 = Fp.sqr(x); // x * x\n const x3 = Fp.mul(x2, x); // x2 * x\n return Fp.add(Fp.add(x3, Fp.mul(x, a)), b); // x3 + a * x + b\n }\n // Validate whether the passed curve params are valid.\n // We check if curve equation works for generator point.\n // `assertValidity()` won't work: `isTorsionFree()` is not available at this point in bls12-381.\n // ProjectivePoint class has not been initialized yet.\n if (!Fp.eql(Fp.sqr(CURVE.Gy), weierstrassEquation(CURVE.Gx)))\n throw new Error('bad generator point: equation left != right');\n // Valid group elements reside in range 1..n-1\n function isWithinCurveOrder(num) {\n return ut.inRange(num, _1n, CURVE.n);\n }\n // Validates if priv key is valid and converts it to bigint.\n // Supports options allowedPrivateKeyLengths and wrapPrivateKey.\n function normPrivateKeyToScalar(key) {\n const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n: N } = CURVE;\n if (lengths && typeof key !== 'bigint') {\n if (ut.isBytes(key))\n key = ut.bytesToHex(key);\n // Normalize to hex string, pad. E.g. P521 would norm 130-132 char hex to 132-char bytes\n if (typeof key !== 'string' || !lengths.includes(key.length))\n throw new Error('invalid private key');\n key = key.padStart(nByteLength * 2, '0');\n }\n let num;\n try {\n num =\n typeof key === 'bigint'\n ? key\n : ut.bytesToNumberBE((0, utils_js_1.ensureBytes)('private key', key, nByteLength));\n }\n catch (error) {\n throw new Error('invalid private key, expected hex or ' + nByteLength + ' bytes, got ' + typeof key);\n }\n if (wrapPrivateKey)\n num = (0, modular_js_1.mod)(num, N); // disabled by default, enabled for BLS\n ut.aInRange('private key', num, _1n, N); // num in range [1..N-1]\n return num;\n }\n function assertPrjPoint(other) {\n if (!(other instanceof Point))\n throw new Error('ProjectivePoint expected');\n }\n // Memoized toAffine / validity check. They are heavy. Points are immutable.\n // Converts Projective point to affine (x, y) coordinates.\n // Can accept precomputed Z^-1 - for example, from invertBatch.\n // (x, y, z) ∋ (x=x/z, y=y/z)\n const toAffineMemo = (0, utils_js_1.memoized)((p, iz) => {\n const { px: x, py: y, pz: z } = p;\n // Fast-path for normalized points\n if (Fp.eql(z, Fp.ONE))\n return { x, y };\n const is0 = p.is0();\n // If invZ was 0, we return zero point. However we still want to execute\n // all operations, so we replace invZ with a random number, 1.\n if (iz == null)\n iz = is0 ? Fp.ONE : Fp.inv(z);\n const ax = Fp.mul(x, iz);\n const ay = Fp.mul(y, iz);\n const zz = Fp.mul(z, iz);\n if (is0)\n return { x: Fp.ZERO, y: Fp.ZERO };\n if (!Fp.eql(zz, Fp.ONE))\n throw new Error('invZ was invalid');\n return { x: ax, y: ay };\n });\n // NOTE: on exception this will crash 'cached' and no value will be set.\n // Otherwise true will be return\n const assertValidMemo = (0, utils_js_1.memoized)((p) => {\n if (p.is0()) {\n // (0, 1, 0) aka ZERO is invalid in most contexts.\n // In BLS, ZERO can be serialized, so we allow it.\n // (0, 0, 0) is invalid representation of ZERO.\n if (CURVE.allowInfinityPoint && !Fp.is0(p.py))\n return;\n throw new Error('bad point: ZERO');\n }\n // Some 3rd-party test vectors require different wording between here & `fromCompressedHex`\n const { x, y } = p.toAffine();\n // Check if x, y are valid field elements\n if (!Fp.isValid(x) || !Fp.isValid(y))\n throw new Error('bad point: x or y not FE');\n const left = Fp.sqr(y); // y²\n const right = weierstrassEquation(x); // x³ + ax + b\n if (!Fp.eql(left, right))\n throw new Error('bad point: equation left != right');\n if (!p.isTorsionFree())\n throw new Error('bad point: not in prime-order subgroup');\n return true;\n });\n /**\n * Projective Point works in 3d / projective (homogeneous) coordinates: (x, y, z) ∋ (x=x/z, y=y/z)\n * Default Point works in 2d / affine coordinates: (x, y)\n * We're doing calculations in projective, because its operations don't require costly inversion.\n */\n class Point {\n constructor(px, py, pz) {\n this.px = px;\n this.py = py;\n this.pz = pz;\n if (px == null || !Fp.isValid(px))\n throw new Error('x required');\n if (py == null || !Fp.isValid(py))\n throw new Error('y required');\n if (pz == null || !Fp.isValid(pz))\n throw new Error('z required');\n Object.freeze(this);\n }\n // Does not validate if the point is on-curve.\n // Use fromHex instead, or call assertValidity() later.\n static fromAffine(p) {\n const { x, y } = p || {};\n if (!p || !Fp.isValid(x) || !Fp.isValid(y))\n throw new Error('invalid affine point');\n if (p instanceof Point)\n throw new Error('projective point not allowed');\n const is0 = (i) => Fp.eql(i, Fp.ZERO);\n // fromAffine(x:0, y:0) would produce (x:0, y:0, z:1), but we need (x:0, y:1, z:0)\n if (is0(x) && is0(y))\n return Point.ZERO;\n return new Point(x, y, Fp.ONE);\n }\n get x() {\n return this.toAffine().x;\n }\n get y() {\n return this.toAffine().y;\n }\n /**\n * Takes a bunch of Projective Points but executes only one\n * inversion on all of them. Inversion is very slow operation,\n * so this improves performance massively.\n * Optimization: converts a list of projective points to a list of identical points with Z=1.\n */\n static normalizeZ(points) {\n const toInv = Fp.invertBatch(points.map((p) => p.pz));\n return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine);\n }\n /**\n * Converts hash string or Uint8Array to Point.\n * @param hex short/long ECDSA hex\n */\n static fromHex(hex) {\n const P = Point.fromAffine(fromBytes((0, utils_js_1.ensureBytes)('pointHex', hex)));\n P.assertValidity();\n return P;\n }\n // Multiplies generator point by privateKey.\n static fromPrivateKey(privateKey) {\n return Point.BASE.multiply(normPrivateKeyToScalar(privateKey));\n }\n // Multiscalar Multiplication\n static msm(points, scalars) {\n return (0, curve_js_1.pippenger)(Point, Fn, points, scalars);\n }\n // \"Private method\", don't use it directly\n _setWindowSize(windowSize) {\n wnaf.setWindowSize(this, windowSize);\n }\n // A point on curve is valid if it conforms to equation.\n assertValidity() {\n assertValidMemo(this);\n }\n hasEvenY() {\n const { y } = this.toAffine();\n if (Fp.isOdd)\n return !Fp.isOdd(y);\n throw new Error(\"Field doesn't support isOdd\");\n }\n /**\n * Compare one point to another.\n */\n equals(other) {\n assertPrjPoint(other);\n const { px: X1, py: Y1, pz: Z1 } = this;\n const { px: X2, py: Y2, pz: Z2 } = other;\n const U1 = Fp.eql(Fp.mul(X1, Z2), Fp.mul(X2, Z1));\n const U2 = Fp.eql(Fp.mul(Y1, Z2), Fp.mul(Y2, Z1));\n return U1 && U2;\n }\n /**\n * Flips point to one corresponding to (x, -y) in Affine coordinates.\n */\n negate() {\n return new Point(this.px, Fp.neg(this.py), this.pz);\n }\n // Renes-Costello-Batina exception-free doubling formula.\n // There is 30% faster Jacobian formula, but it is not complete.\n // https://eprint.iacr.org/2015/1060, algorithm 3\n // Cost: 8M + 3S + 3*a + 2*b3 + 15add.\n double() {\n const { a, b } = CURVE;\n const b3 = Fp.mul(b, _3n);\n const { px: X1, py: Y1, pz: Z1 } = this;\n let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore\n let t0 = Fp.mul(X1, X1); // step 1\n let t1 = Fp.mul(Y1, Y1);\n let t2 = Fp.mul(Z1, Z1);\n let t3 = Fp.mul(X1, Y1);\n t3 = Fp.add(t3, t3); // step 5\n Z3 = Fp.mul(X1, Z1);\n Z3 = Fp.add(Z3, Z3);\n X3 = Fp.mul(a, Z3);\n Y3 = Fp.mul(b3, t2);\n Y3 = Fp.add(X3, Y3); // step 10\n X3 = Fp.sub(t1, Y3);\n Y3 = Fp.add(t1, Y3);\n Y3 = Fp.mul(X3, Y3);\n X3 = Fp.mul(t3, X3);\n Z3 = Fp.mul(b3, Z3); // step 15\n t2 = Fp.mul(a, t2);\n t3 = Fp.sub(t0, t2);\n t3 = Fp.mul(a, t3);\n t3 = Fp.add(t3, Z3);\n Z3 = Fp.add(t0, t0); // step 20\n t0 = Fp.add(Z3, t0);\n t0 = Fp.add(t0, t2);\n t0 = Fp.mul(t0, t3);\n Y3 = Fp.add(Y3, t0);\n t2 = Fp.mul(Y1, Z1); // step 25\n t2 = Fp.add(t2, t2);\n t0 = Fp.mul(t2, t3);\n X3 = Fp.sub(X3, t0);\n Z3 = Fp.mul(t2, t1);\n Z3 = Fp.add(Z3, Z3); // step 30\n Z3 = Fp.add(Z3, Z3);\n return new Point(X3, Y3, Z3);\n }\n // Renes-Costello-Batina exception-free addition formula.\n // There is 30% faster Jacobian formula, but it is not complete.\n // https://eprint.iacr.org/2015/1060, algorithm 1\n // Cost: 12M + 0S + 3*a + 3*b3 + 23add.\n add(other) {\n assertPrjPoint(other);\n const { px: X1, py: Y1, pz: Z1 } = this;\n const { px: X2, py: Y2, pz: Z2 } = other;\n let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore\n const a = CURVE.a;\n const b3 = Fp.mul(CURVE.b, _3n);\n let t0 = Fp.mul(X1, X2); // step 1\n let t1 = Fp.mul(Y1, Y2);\n let t2 = Fp.mul(Z1, Z2);\n let t3 = Fp.add(X1, Y1);\n let t4 = Fp.add(X2, Y2); // step 5\n t3 = Fp.mul(t3, t4);\n t4 = Fp.add(t0, t1);\n t3 = Fp.sub(t3, t4);\n t4 = Fp.add(X1, Z1);\n let t5 = Fp.add(X2, Z2); // step 10\n t4 = Fp.mul(t4, t5);\n t5 = Fp.add(t0, t2);\n t4 = Fp.sub(t4, t5);\n t5 = Fp.add(Y1, Z1);\n X3 = Fp.add(Y2, Z2); // step 15\n t5 = Fp.mul(t5, X3);\n X3 = Fp.add(t1, t2);\n t5 = Fp.sub(t5, X3);\n Z3 = Fp.mul(a, t4);\n X3 = Fp.mul(b3, t2); // step 20\n Z3 = Fp.add(X3, Z3);\n X3 = Fp.sub(t1, Z3);\n Z3 = Fp.add(t1, Z3);\n Y3 = Fp.mul(X3, Z3);\n t1 = Fp.add(t0, t0); // step 25\n t1 = Fp.add(t1, t0);\n t2 = Fp.mul(a, t2);\n t4 = Fp.mul(b3, t4);\n t1 = Fp.add(t1, t2);\n t2 = Fp.sub(t0, t2); // step 30\n t2 = Fp.mul(a, t2);\n t4 = Fp.add(t4, t2);\n t0 = Fp.mul(t1, t4);\n Y3 = Fp.add(Y3, t0);\n t0 = Fp.mul(t5, t4); // step 35\n X3 = Fp.mul(t3, X3);\n X3 = Fp.sub(X3, t0);\n t0 = Fp.mul(t3, t1);\n Z3 = Fp.mul(t5, Z3);\n Z3 = Fp.add(Z3, t0); // step 40\n return new Point(X3, Y3, Z3);\n }\n subtract(other) {\n return this.add(other.negate());\n }\n is0() {\n return this.equals(Point.ZERO);\n }\n wNAF(n) {\n return wnaf.wNAFCached(this, n, Point.normalizeZ);\n }\n /**\n * Non-constant-time multiplication. Uses double-and-add algorithm.\n * It's faster, but should only be used when you don't care about\n * an exposed private key e.g. sig verification, which works over *public* keys.\n */\n multiplyUnsafe(sc) {\n const { endo, n: N } = CURVE;\n ut.aInRange('scalar', sc, _0n, N);\n const I = Point.ZERO;\n if (sc === _0n)\n return I;\n if (this.is0() || sc === _1n)\n return this;\n // Case a: no endomorphism. Case b: has precomputes.\n if (!endo || wnaf.hasPrecomputes(this))\n return wnaf.wNAFCachedUnsafe(this, sc, Point.normalizeZ);\n // Case c: endomorphism\n let { k1neg, k1, k2neg, k2 } = endo.splitScalar(sc);\n let k1p = I;\n let k2p = I;\n let d = this;\n while (k1 > _0n || k2 > _0n) {\n if (k1 & _1n)\n k1p = k1p.add(d);\n if (k2 & _1n)\n k2p = k2p.add(d);\n d = d.double();\n k1 >>= _1n;\n k2 >>= _1n;\n }\n if (k1neg)\n k1p = k1p.negate();\n if (k2neg)\n k2p = k2p.negate();\n k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz);\n return k1p.add(k2p);\n }\n /**\n * Constant time multiplication.\n * Uses wNAF method. Windowed method may be 10% faster,\n * but takes 2x longer to generate and consumes 2x memory.\n * Uses precomputes when available.\n * Uses endomorphism for Koblitz curves.\n * @param scalar by which the point would be multiplied\n * @returns New point\n */\n multiply(scalar) {\n const { endo, n: N } = CURVE;\n ut.aInRange('scalar', scalar, _1n, N);\n let point, fake; // Fake point is used to const-time mult\n if (endo) {\n const { k1neg, k1, k2neg, k2 } = endo.splitScalar(scalar);\n let { p: k1p, f: f1p } = this.wNAF(k1);\n let { p: k2p, f: f2p } = this.wNAF(k2);\n k1p = wnaf.constTimeNegate(k1neg, k1p);\n k2p = wnaf.constTimeNegate(k2neg, k2p);\n k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz);\n point = k1p.add(k2p);\n fake = f1p.add(f2p);\n }\n else {\n const { p, f } = this.wNAF(scalar);\n point = p;\n fake = f;\n }\n // Normalize `z` for both points, but return only real one\n return Point.normalizeZ([point, fake])[0];\n }\n /**\n * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.\n * Not using Strauss-Shamir trick: precomputation tables are faster.\n * The trick could be useful if both P and Q are not G (not in our case).\n * @returns non-zero affine point\n */\n multiplyAndAddUnsafe(Q, a, b) {\n const G = Point.BASE; // No Strauss-Shamir trick: we have 10% faster G precomputes\n const mul = (P, a // Select faster multiply() method\n ) => (a === _0n || a === _1n || !P.equals(G) ? P.multiplyUnsafe(a) : P.multiply(a));\n const sum = mul(this, a).add(mul(Q, b));\n return sum.is0() ? undefined : sum;\n }\n // Converts Projective point to affine (x, y) coordinates.\n // Can accept precomputed Z^-1 - for example, from invertBatch.\n // (x, y, z) ∋ (x=x/z, y=y/z)\n toAffine(iz) {\n return toAffineMemo(this, iz);\n }\n isTorsionFree() {\n const { h: cofactor, isTorsionFree } = CURVE;\n if (cofactor === _1n)\n return true; // No subgroups, always torsion-free\n if (isTorsionFree)\n return isTorsionFree(Point, this);\n throw new Error('isTorsionFree() has not been declared for the elliptic curve');\n }\n clearCofactor() {\n const { h: cofactor, clearCofactor } = CURVE;\n if (cofactor === _1n)\n return this; // Fast-path\n if (clearCofactor)\n return clearCofactor(Point, this);\n return this.multiplyUnsafe(CURVE.h);\n }\n toRawBytes(isCompressed = true) {\n (0, utils_js_1.abool)('isCompressed', isCompressed);\n this.assertValidity();\n return toBytes(Point, this, isCompressed);\n }\n toHex(isCompressed = true) {\n (0, utils_js_1.abool)('isCompressed', isCompressed);\n return ut.bytesToHex(this.toRawBytes(isCompressed));\n }\n }\n Point.BASE = new Point(CURVE.Gx, CURVE.Gy, Fp.ONE);\n Point.ZERO = new Point(Fp.ZERO, Fp.ONE, Fp.ZERO);\n const _bits = CURVE.nBitLength;\n const wnaf = (0, curve_js_1.wNAF)(Point, CURVE.endo ? Math.ceil(_bits / 2) : _bits);\n // Validate if generator point is on curve\n return {\n CURVE,\n ProjectivePoint: Point,\n normPrivateKeyToScalar,\n weierstrassEquation,\n isWithinCurveOrder,\n };\n}\nfunction validateOpts(curve) {\n const opts = (0, curve_js_1.validateBasic)(curve);\n ut.validateObject(opts, {\n hash: 'hash',\n hmac: 'function',\n randomBytes: 'function',\n }, {\n bits2int: 'function',\n bits2int_modN: 'function',\n lowS: 'boolean',\n });\n return Object.freeze({ lowS: true, ...opts });\n}\n/**\n * Creates short weierstrass curve and ECDSA signature methods for it.\n * @example\n * import { Field } from '@noble/curves/abstract/modular';\n * // Before that, define BigInt-s: a, b, p, n, Gx, Gy\n * const curve = weierstrass({ a, b, Fp: Field(p), n, Gx, Gy, h: 1n })\n */\nfunction weierstrass(curveDef) {\n const CURVE = validateOpts(curveDef);\n const { Fp, n: CURVE_ORDER } = CURVE;\n const compressedLen = Fp.BYTES + 1; // e.g. 33 for 32\n const uncompressedLen = 2 * Fp.BYTES + 1; // e.g. 65 for 32\n function modN(a) {\n return (0, modular_js_1.mod)(a, CURVE_ORDER);\n }\n function invN(a) {\n return (0, modular_js_1.invert)(a, CURVE_ORDER);\n }\n const { ProjectivePoint: Point, normPrivateKeyToScalar, weierstrassEquation, isWithinCurveOrder, } = weierstrassPoints({\n ...CURVE,\n toBytes(_c, point, isCompressed) {\n const a = point.toAffine();\n const x = Fp.toBytes(a.x);\n const cat = ut.concatBytes;\n (0, utils_js_1.abool)('isCompressed', isCompressed);\n if (isCompressed) {\n return cat(Uint8Array.from([point.hasEvenY() ? 0x02 : 0x03]), x);\n }\n else {\n return cat(Uint8Array.from([0x04]), x, Fp.toBytes(a.y));\n }\n },\n fromBytes(bytes) {\n const len = bytes.length;\n const head = bytes[0];\n const tail = bytes.subarray(1);\n // this.assertValidity() is done inside of fromHex\n if (len === compressedLen && (head === 0x02 || head === 0x03)) {\n const x = ut.bytesToNumberBE(tail);\n if (!ut.inRange(x, _1n, Fp.ORDER))\n throw new Error('Point is not on curve');\n const y2 = weierstrassEquation(x); // y² = x³ + ax + b\n let y;\n try {\n y = Fp.sqrt(y2); // y = y² ^ (p+1)/4\n }\n catch (sqrtError) {\n const suffix = sqrtError instanceof Error ? ': ' + sqrtError.message : '';\n throw new Error('Point is not on curve' + suffix);\n }\n const isYOdd = (y & _1n) === _1n;\n // ECDSA\n const isHeadOdd = (head & 1) === 1;\n if (isHeadOdd !== isYOdd)\n y = Fp.neg(y);\n return { x, y };\n }\n else if (len === uncompressedLen && head === 0x04) {\n const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES));\n const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));\n return { x, y };\n }\n else {\n const cl = compressedLen;\n const ul = uncompressedLen;\n throw new Error('invalid Point, expected length of ' + cl + ', or uncompressed ' + ul + ', got ' + len);\n }\n },\n });\n const numToNByteStr = (num) => ut.bytesToHex(ut.numberToBytesBE(num, CURVE.nByteLength));\n function isBiggerThanHalfOrder(number) {\n const HALF = CURVE_ORDER >> _1n;\n return number > HALF;\n }\n function normalizeS(s) {\n return isBiggerThanHalfOrder(s) ? modN(-s) : s;\n }\n // slice bytes num\n const slcNum = (b, from, to) => ut.bytesToNumberBE(b.slice(from, to));\n /**\n * ECDSA signature with its (r, s) properties. Supports DER & compact representations.\n */\n class Signature {\n constructor(r, s, recovery) {\n this.r = r;\n this.s = s;\n this.recovery = recovery;\n this.assertValidity();\n }\n // pair (bytes of r, bytes of s)\n static fromCompact(hex) {\n const l = CURVE.nByteLength;\n hex = (0, utils_js_1.ensureBytes)('compactSignature', hex, l * 2);\n return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l));\n }\n // DER encoded ECDSA signature\n // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script\n static fromDER(hex) {\n const { r, s } = exports.DER.toSig((0, utils_js_1.ensureBytes)('DER', hex));\n return new Signature(r, s);\n }\n assertValidity() {\n ut.aInRange('r', this.r, _1n, CURVE_ORDER); // r in [1..N]\n ut.aInRange('s', this.s, _1n, CURVE_ORDER); // s in [1..N]\n }\n addRecoveryBit(recovery) {\n return new Signature(this.r, this.s, recovery);\n }\n recoverPublicKey(msgHash) {\n const { r, s, recovery: rec } = this;\n const h = bits2int_modN((0, utils_js_1.ensureBytes)('msgHash', msgHash)); // Truncate hash\n if (rec == null || ![0, 1, 2, 3].includes(rec))\n throw new Error('recovery id invalid');\n const radj = rec === 2 || rec === 3 ? r + CURVE.n : r;\n if (radj >= Fp.ORDER)\n throw new Error('recovery id 2 or 3 invalid');\n const prefix = (rec & 1) === 0 ? '02' : '03';\n const R = Point.fromHex(prefix + numToNByteStr(radj));\n const ir = invN(radj); // r^-1\n const u1 = modN(-h * ir); // -hr^-1\n const u2 = modN(s * ir); // sr^-1\n const Q = Point.BASE.multiplyAndAddUnsafe(R, u1, u2); // (sr^-1)R-(hr^-1)G = -(hr^-1)G + (sr^-1)\n if (!Q)\n throw new Error('point at infinify'); // unsafe is fine: no priv data leaked\n Q.assertValidity();\n return Q;\n }\n // Signatures should be low-s, to prevent malleability.\n hasHighS() {\n return isBiggerThanHalfOrder(this.s);\n }\n normalizeS() {\n return this.hasHighS() ? new Signature(this.r, modN(-this.s), this.recovery) : this;\n }\n // DER-encoded\n toDERRawBytes() {\n return ut.hexToBytes(this.toDERHex());\n }\n toDERHex() {\n return exports.DER.hexFromSig({ r: this.r, s: this.s });\n }\n // padded bytes of r, then padded bytes of s\n toCompactRawBytes() {\n return ut.hexToBytes(this.toCompactHex());\n }\n toCompactHex() {\n return numToNByteStr(this.r) + numToNByteStr(this.s);\n }\n }\n const utils = {\n isValidPrivateKey(privateKey) {\n try {\n normPrivateKeyToScalar(privateKey);\n return true;\n }\n catch (error) {\n return false;\n }\n },\n normPrivateKeyToScalar: normPrivateKeyToScalar,\n /**\n * Produces cryptographically secure private key from random of size\n * (groupLen + ceil(groupLen / 2)) with modulo bias being negligible.\n */\n randomPrivateKey: () => {\n const length = (0, modular_js_1.getMinHashLength)(CURVE.n);\n return (0, modular_js_1.mapHashToField)(CURVE.randomBytes(length), CURVE.n);\n },\n /**\n * Creates precompute table for an arbitrary EC point. Makes point \"cached\".\n * Allows to massively speed-up `point.multiply(scalar)`.\n * @returns cached point\n * @example\n * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey));\n * fast.multiply(privKey); // much faster ECDH now\n */\n precompute(windowSize = 8, point = Point.BASE) {\n point._setWindowSize(windowSize);\n point.multiply(BigInt(3)); // 3 is arbitrary, just need any number here\n return point;\n },\n };\n /**\n * Computes public key for a private key. Checks for validity of the private key.\n * @param privateKey private key\n * @param isCompressed whether to return compact (default), or full key\n * @returns Public key, full when isCompressed=false; short when isCompressed=true\n */\n function getPublicKey(privateKey, isCompressed = true) {\n return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed);\n }\n /**\n * Quick and dirty check for item being public key. Does not validate hex, or being on-curve.\n */\n function isProbPub(item) {\n const arr = ut.isBytes(item);\n const str = typeof item === 'string';\n const len = (arr || str) && item.length;\n if (arr)\n return len === compressedLen || len === uncompressedLen;\n if (str)\n return len === 2 * compressedLen || len === 2 * uncompressedLen;\n if (item instanceof Point)\n return true;\n return false;\n }\n /**\n * ECDH (Elliptic Curve Diffie Hellman).\n * Computes shared public key from private key and public key.\n * Checks: 1) private key validity 2) shared key is on-curve.\n * Does NOT hash the result.\n * @param privateA private key\n * @param publicB different public key\n * @param isCompressed whether to return compact (default), or full key\n * @returns shared public key\n */\n function getSharedSecret(privateA, publicB, isCompressed = true) {\n if (isProbPub(privateA))\n throw new Error('first arg must be private key');\n if (!isProbPub(publicB))\n throw new Error('second arg must be public key');\n const b = Point.fromHex(publicB); // check for being on-curve\n return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);\n }\n // RFC6979: ensure ECDSA msg is X bytes and < N. RFC suggests optional truncating via bits2octets.\n // FIPS 186-4 4.6 suggests the leftmost min(nBitLen, outLen) bits, which matches bits2int.\n // bits2int can produce res>N, we can do mod(res, N) since the bitLen is the same.\n // int2octets can't be used; pads small msgs with 0: unacceptatble for trunc as per RFC vectors\n const bits2int = CURVE.bits2int ||\n function (bytes) {\n // Our custom check \"just in case\"\n if (bytes.length > 8192)\n throw new Error('input is too large');\n // For curves with nBitLength % 8 !== 0: bits2octets(bits2octets(m)) !== bits2octets(m)\n // for some cases, since bytes.length * 8 is not actual bitLength.\n const num = ut.bytesToNumberBE(bytes); // check for == u8 done here\n const delta = bytes.length * 8 - CURVE.nBitLength; // truncate to nBitLength leftmost bits\n return delta > 0 ? num >> BigInt(delta) : num;\n };\n const bits2int_modN = CURVE.bits2int_modN ||\n function (bytes) {\n return modN(bits2int(bytes)); // can't use bytesToNumberBE here\n };\n // NOTE: pads output with zero as per spec\n const ORDER_MASK = ut.bitMask(CURVE.nBitLength);\n /**\n * Converts to bytes. Checks if num in `[0..ORDER_MASK-1]` e.g.: `[0..2^256-1]`.\n */\n function int2octets(num) {\n ut.aInRange('num < 2^' + CURVE.nBitLength, num, _0n, ORDER_MASK);\n // works with order, can have different size than numToField!\n return ut.numberToBytesBE(num, CURVE.nByteLength);\n }\n // Steps A, D of RFC6979 3.2\n // Creates RFC6979 seed; converts msg/privKey to numbers.\n // Used only in sign, not in verify.\n // NOTE: we cannot assume here that msgHash has same amount of bytes as curve order,\n // this will be invalid at least for P521. Also it can be bigger for P224 + SHA256\n function prepSig(msgHash, privateKey, opts = defaultSigOpts) {\n if (['recovered', 'canonical'].some((k) => k in opts))\n throw new Error('sign() legacy options not supported');\n const { hash, randomBytes } = CURVE;\n let { lowS, prehash, extraEntropy: ent } = opts; // generates low-s sigs by default\n if (lowS == null)\n lowS = true; // RFC6979 3.2: we skip step A, because we already provide hash\n msgHash = (0, utils_js_1.ensureBytes)('msgHash', msgHash);\n validateSigVerOpts(opts);\n if (prehash)\n msgHash = (0, utils_js_1.ensureBytes)('prehashed msgHash', hash(msgHash));\n // We can't later call bits2octets, since nested bits2int is broken for curves\n // with nBitLength % 8 !== 0. Because of that, we unwrap it here as int2octets call.\n // const bits2octets = (bits) => int2octets(bits2int_modN(bits))\n const h1int = bits2int_modN(msgHash);\n const d = normPrivateKeyToScalar(privateKey); // validate private key, convert to bigint\n const seedArgs = [int2octets(d), int2octets(h1int)];\n // extraEntropy. RFC6979 3.6: additional k' (optional).\n if (ent != null && ent !== false) {\n // K = HMAC_K(V || 0x00 || int2octets(x) || bits2octets(h1) || k')\n const e = ent === true ? randomBytes(Fp.BYTES) : ent; // generate random bytes OR pass as-is\n seedArgs.push((0, utils_js_1.ensureBytes)('extraEntropy', e)); // check for being bytes\n }\n const seed = ut.concatBytes(...seedArgs); // Step D of RFC6979 3.2\n const m = h1int; // NOTE: no need to call bits2int second time here, it is inside truncateHash!\n // Converts signature params into point w r/s, checks result for validity.\n function k2sig(kBytes) {\n // RFC 6979 Section 3.2, step 3: k = bits2int(T)\n const k = bits2int(kBytes); // Cannot use fields methods, since it is group element\n if (!isWithinCurveOrder(k))\n return; // Important: all mod() calls here must be done over N\n const ik = invN(k); // k^-1 mod n\n const q = Point.BASE.multiply(k).toAffine(); // q = Gk\n const r = modN(q.x); // r = q.x mod n\n if (r === _0n)\n return;\n // Can use scalar blinding b^-1(bm + bdr) where b ∈ [1,q−1] according to\n // https://tches.iacr.org/index.php/TCHES/article/view/7337/6509. We've decided against it:\n // a) dependency on CSPRNG b) 15% slowdown c) doesn't really help since bigints are not CT\n const s = modN(ik * modN(m + r * d)); // Not using blinding here\n if (s === _0n)\n return;\n let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n); // recovery bit (2 or 3, when q.x > n)\n let normS = s;\n if (lowS && isBiggerThanHalfOrder(s)) {\n normS = normalizeS(s); // if lowS was passed, ensure s is always\n recovery ^= 1; // // in the bottom half of N\n }\n return new Signature(r, normS, recovery); // use normS, not s\n }\n return { seed, k2sig };\n }\n const defaultSigOpts = { lowS: CURVE.lowS, prehash: false };\n const defaultVerOpts = { lowS: CURVE.lowS, prehash: false };\n /**\n * Signs message hash with a private key.\n * ```\n * sign(m, d, k) where\n * (x, y) = G × k\n * r = x mod n\n * s = (m + dr)/k mod n\n * ```\n * @param msgHash NOT message. msg needs to be hashed to `msgHash`, or use `prehash`.\n * @param privKey private key\n * @param opts lowS for non-malleable sigs. extraEntropy for mixing randomness into k. prehash will hash first arg.\n * @returns signature with recovery param\n */\n function sign(msgHash, privKey, opts = defaultSigOpts) {\n const { seed, k2sig } = prepSig(msgHash, privKey, opts); // Steps A, D of RFC6979 3.2.\n const C = CURVE;\n const drbg = ut.createHmacDrbg(C.hash.outputLen, C.nByteLength, C.hmac);\n return drbg(seed, k2sig); // Steps B, C, D, E, F, G\n }\n // Enable precomputes. Slows down first publicKey computation by 20ms.\n Point.BASE._setWindowSize(8);\n // utils.precompute(8, ProjectivePoint.BASE)\n /**\n * Verifies a signature against message hash and public key.\n * Rejects lowS signatures by default: to override,\n * specify option `{lowS: false}`. Implements section 4.1.4 from https://www.secg.org/sec1-v2.pdf:\n *\n * ```\n * verify(r, s, h, P) where\n * U1 = hs^-1 mod n\n * U2 = rs^-1 mod n\n * R = U1⋅G - U2⋅P\n * mod(R.x, n) == r\n * ```\n */\n function verify(signature, msgHash, publicKey, opts = defaultVerOpts) {\n const sg = signature;\n msgHash = (0, utils_js_1.ensureBytes)('msgHash', msgHash);\n publicKey = (0, utils_js_1.ensureBytes)('publicKey', publicKey);\n const { lowS, prehash, format } = opts;\n // Verify opts, deduce signature format\n validateSigVerOpts(opts);\n if ('strict' in opts)\n throw new Error('options.strict was renamed to lowS');\n if (format !== undefined && format !== 'compact' && format !== 'der')\n throw new Error('format must be compact or der');\n const isHex = typeof sg === 'string' || ut.isBytes(sg);\n const isObj = !isHex &&\n !format &&\n typeof sg === 'object' &&\n sg !== null &&\n typeof sg.r === 'bigint' &&\n typeof sg.s === 'bigint';\n if (!isHex && !isObj)\n throw new Error('invalid signature, expected Uint8Array, hex string or Signature instance');\n let _sig = undefined;\n let P;\n try {\n if (isObj)\n _sig = new Signature(sg.r, sg.s);\n if (isHex) {\n // Signature can be represented in 2 ways: compact (2*nByteLength) & DER (variable-length).\n // Since DER can also be 2*nByteLength bytes, we check for it first.\n try {\n if (format !== 'compact')\n _sig = Signature.fromDER(sg);\n }\n catch (derError) {\n if (!(derError instanceof exports.DER.Err))\n throw derError;\n }\n if (!_sig && format !== 'der')\n _sig = Signature.fromCompact(sg);\n }\n P = Point.fromHex(publicKey);\n }\n catch (error) {\n return false;\n }\n if (!_sig)\n return false;\n if (lowS && _sig.hasHighS())\n return false;\n if (prehash)\n msgHash = CURVE.hash(msgHash);\n const { r, s } = _sig;\n const h = bits2int_modN(msgHash); // Cannot use fields methods, since it is group element\n const is = invN(s); // s^-1\n const u1 = modN(h * is); // u1 = hs^-1 mod n\n const u2 = modN(r * is); // u2 = rs^-1 mod n\n const R = Point.BASE.multiplyAndAddUnsafe(P, u1, u2)?.toAffine(); // R = u1⋅G + u2⋅P\n if (!R)\n return false;\n const v = modN(R.x);\n return v === r;\n }\n return {\n CURVE,\n getPublicKey,\n getSharedSecret,\n sign,\n verify,\n ProjectivePoint: Point,\n Signature,\n utils,\n };\n}\n/**\n * Implementation of the Shallue and van de Woestijne method for any weierstrass curve.\n * TODO: check if there is a way to merge this with uvRatio in Edwards; move to modular.\n * b = True and y = sqrt(u / v) if (u / v) is square in F, and\n * b = False and y = sqrt(Z * (u / v)) otherwise.\n * @param Fp\n * @param Z\n * @returns\n */\nfunction SWUFpSqrtRatio(Fp, Z) {\n // Generic implementation\n const q = Fp.ORDER;\n let l = _0n;\n for (let o = q - _1n; o % _2n === _0n; o /= _2n)\n l += _1n;\n const c1 = l; // 1. c1, the largest integer such that 2^c1 divides q - 1.\n // We need 2n ** c1 and 2n ** (c1-1). We can't use **; but we can use <<.\n // 2n ** c1 == 2n << (c1-1)\n const _2n_pow_c1_1 = _2n << (c1 - _1n - _1n);\n const _2n_pow_c1 = _2n_pow_c1_1 * _2n;\n const c2 = (q - _1n) / _2n_pow_c1; // 2. c2 = (q - 1) / (2^c1) # Integer arithmetic\n const c3 = (c2 - _1n) / _2n; // 3. c3 = (c2 - 1) / 2 # Integer arithmetic\n const c4 = _2n_pow_c1 - _1n; // 4. c4 = 2^c1 - 1 # Integer arithmetic\n const c5 = _2n_pow_c1_1; // 5. c5 = 2^(c1 - 1) # Integer arithmetic\n const c6 = Fp.pow(Z, c2); // 6. c6 = Z^c2\n const c7 = Fp.pow(Z, (c2 + _1n) / _2n); // 7. c7 = Z^((c2 + 1) / 2)\n let sqrtRatio = (u, v) => {\n let tv1 = c6; // 1. tv1 = c6\n let tv2 = Fp.pow(v, c4); // 2. tv2 = v^c4\n let tv3 = Fp.sqr(tv2); // 3. tv3 = tv2^2\n tv3 = Fp.mul(tv3, v); // 4. tv3 = tv3 * v\n let tv5 = Fp.mul(u, tv3); // 5. tv5 = u * tv3\n tv5 = Fp.pow(tv5, c3); // 6. tv5 = tv5^c3\n tv5 = Fp.mul(tv5, tv2); // 7. tv5 = tv5 * tv2\n tv2 = Fp.mul(tv5, v); // 8. tv2 = tv5 * v\n tv3 = Fp.mul(tv5, u); // 9. tv3 = tv5 * u\n let tv4 = Fp.mul(tv3, tv2); // 10. tv4 = tv3 * tv2\n tv5 = Fp.pow(tv4, c5); // 11. tv5 = tv4^c5\n let isQR = Fp.eql(tv5, Fp.ONE); // 12. isQR = tv5 == 1\n tv2 = Fp.mul(tv3, c7); // 13. tv2 = tv3 * c7\n tv5 = Fp.mul(tv4, tv1); // 14. tv5 = tv4 * tv1\n tv3 = Fp.cmov(tv2, tv3, isQR); // 15. tv3 = CMOV(tv2, tv3, isQR)\n tv4 = Fp.cmov(tv5, tv4, isQR); // 16. tv4 = CMOV(tv5, tv4, isQR)\n // 17. for i in (c1, c1 - 1, ..., 2):\n for (let i = c1; i > _1n; i--) {\n let tv5 = i - _2n; // 18. tv5 = i - 2\n tv5 = _2n << (tv5 - _1n); // 19. tv5 = 2^tv5\n let tvv5 = Fp.pow(tv4, tv5); // 20. tv5 = tv4^tv5\n const e1 = Fp.eql(tvv5, Fp.ONE); // 21. e1 = tv5 == 1\n tv2 = Fp.mul(tv3, tv1); // 22. tv2 = tv3 * tv1\n tv1 = Fp.mul(tv1, tv1); // 23. tv1 = tv1 * tv1\n tvv5 = Fp.mul(tv4, tv1); // 24. tv5 = tv4 * tv1\n tv3 = Fp.cmov(tv2, tv3, e1); // 25. tv3 = CMOV(tv2, tv3, e1)\n tv4 = Fp.cmov(tvv5, tv4, e1); // 26. tv4 = CMOV(tv5, tv4, e1)\n }\n return { isValid: isQR, value: tv3 };\n };\n if (Fp.ORDER % _4n === _3n) {\n // sqrt_ratio_3mod4(u, v)\n const c1 = (Fp.ORDER - _3n) / _4n; // 1. c1 = (q - 3) / 4 # Integer arithmetic\n const c2 = Fp.sqrt(Fp.neg(Z)); // 2. c2 = sqrt(-Z)\n sqrtRatio = (u, v) => {\n let tv1 = Fp.sqr(v); // 1. tv1 = v^2\n const tv2 = Fp.mul(u, v); // 2. tv2 = u * v\n tv1 = Fp.mul(tv1, tv2); // 3. tv1 = tv1 * tv2\n let y1 = Fp.pow(tv1, c1); // 4. y1 = tv1^c1\n y1 = Fp.mul(y1, tv2); // 5. y1 = y1 * tv2\n const y2 = Fp.mul(y1, c2); // 6. y2 = y1 * c2\n const tv3 = Fp.mul(Fp.sqr(y1), v); // 7. tv3 = y1^2; 8. tv3 = tv3 * v\n const isQR = Fp.eql(tv3, u); // 9. isQR = tv3 == u\n let y = Fp.cmov(y2, y1, isQR); // 10. y = CMOV(y2, y1, isQR)\n return { isValid: isQR, value: y }; // 11. return (isQR, y) isQR ? y : y*c2\n };\n }\n // No curves uses that\n // if (Fp.ORDER % _8n === _5n) // sqrt_ratio_5mod8\n return sqrtRatio;\n}\n/**\n * Simplified Shallue-van de Woestijne-Ulas Method\n * https://www.rfc-editor.org/rfc/rfc9380#section-6.6.2\n */\nfunction mapToCurveSimpleSWU(Fp, opts) {\n (0, modular_js_1.validateField)(Fp);\n if (!Fp.isValid(opts.A) || !Fp.isValid(opts.B) || !Fp.isValid(opts.Z))\n throw new Error('mapToCurveSimpleSWU: invalid opts');\n const sqrtRatio = SWUFpSqrtRatio(Fp, opts.Z);\n if (!Fp.isOdd)\n throw new Error('Fp.isOdd is not implemented!');\n // Input: u, an element of F.\n // Output: (x, y), a point on E.\n return (u) => {\n // prettier-ignore\n let tv1, tv2, tv3, tv4, tv5, tv6, x, y;\n tv1 = Fp.sqr(u); // 1. tv1 = u^2\n tv1 = Fp.mul(tv1, opts.Z); // 2. tv1 = Z * tv1\n tv2 = Fp.sqr(tv1); // 3. tv2 = tv1^2\n tv2 = Fp.add(tv2, tv1); // 4. tv2 = tv2 + tv1\n tv3 = Fp.add(tv2, Fp.ONE); // 5. tv3 = tv2 + 1\n tv3 = Fp.mul(tv3, opts.B); // 6. tv3 = B * tv3\n tv4 = Fp.cmov(opts.Z, Fp.neg(tv2), !Fp.eql(tv2, Fp.ZERO)); // 7. tv4 = CMOV(Z, -tv2, tv2 != 0)\n tv4 = Fp.mul(tv4, opts.A); // 8. tv4 = A * tv4\n tv2 = Fp.sqr(tv3); // 9. tv2 = tv3^2\n tv6 = Fp.sqr(tv4); // 10. tv6 = tv4^2\n tv5 = Fp.mul(tv6, opts.A); // 11. tv5 = A * tv6\n tv2 = Fp.add(tv2, tv5); // 12. tv2 = tv2 + tv5\n tv2 = Fp.mul(tv2, tv3); // 13. tv2 = tv2 * tv3\n tv6 = Fp.mul(tv6, tv4); // 14. tv6 = tv6 * tv4\n tv5 = Fp.mul(tv6, opts.B); // 15. tv5 = B * tv6\n tv2 = Fp.add(tv2, tv5); // 16. tv2 = tv2 + tv5\n x = Fp.mul(tv1, tv3); // 17. x = tv1 * tv3\n const { isValid, value } = sqrtRatio(tv2, tv6); // 18. (is_gx1_square, y1) = sqrt_ratio(tv2, tv6)\n y = Fp.mul(tv1, u); // 19. y = tv1 * u -> Z * u^3 * y1\n y = Fp.mul(y, value); // 20. y = y * y1\n x = Fp.cmov(x, tv3, isValid); // 21. x = CMOV(x, tv3, is_gx1_square)\n y = Fp.cmov(y, value, isValid); // 22. y = CMOV(y, y1, is_gx1_square)\n const e1 = Fp.isOdd(u) === Fp.isOdd(y); // 23. e1 = sgn0(u) == sgn0(y)\n y = Fp.cmov(Fp.neg(y), y, e1); // 24. y = CMOV(-y, y, e1)\n x = Fp.div(x, tv4); // 25. x = x / tv4\n return { x, y };\n };\n}\n//# sourceMappingURL=weierstrass.js.map","/**\n * Short Weierstrass curve methods. The formula is: y² = x³ + ax + b.\n *\n * ### Design rationale for types\n *\n * * Interaction between classes from different curves should fail:\n * `k256.Point.BASE.add(p256.Point.BASE)`\n * * For this purpose we want to use `instanceof` operator, which is fast and works during runtime\n * * Different calls of `curve()` would return different classes -\n * `curve(params) !== curve(params)`: if somebody decided to monkey-patch their curve,\n * it won't affect others\n *\n * TypeScript can't infer types for classes created inside a function. Classes is one instance\n * of nominative types in TypeScript and interfaces only check for shape, so it's hard to create\n * unique type for every function call.\n *\n * We can use generic types via some param, like curve opts, but that would:\n * 1. Enable interaction between `curve(params)` and `curve(params)` (curves of same params)\n * which is hard to debug.\n * 2. Params can be generic and we can't enforce them to be constant value:\n * if somebody creates curve from non-constant params,\n * it would be allowed to interact with other curves with non-constant params\n *\n * @todo https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html#unique-symbol\n * @module\n */\n/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */\nimport {\n type AffinePoint,\n type BasicCurve,\n type Group,\n type GroupConstructor,\n pippenger,\n validateBasic,\n wNAF,\n} from './curve.js';\nimport {\n Field,\n type IField,\n getMinHashLength,\n invert,\n mapHashToField,\n mod,\n validateField,\n} from './modular.js';\nimport * as ut from './utils.js';\nimport { type CHash, type Hex, type PrivKey, abool, ensureBytes, memoized } from './utils.js';\n\nexport type { AffinePoint };\ntype HmacFnSync = (key: Uint8Array, ...messages: Uint8Array[]) => Uint8Array;\ntype EndomorphismOpts = {\n beta: bigint;\n splitScalar: (k: bigint) => { k1neg: boolean; k1: bigint; k2neg: boolean; k2: bigint };\n};\nexport type BasicWCurve = BasicCurve & {\n // Params: a, b\n a: T;\n b: T;\n\n // Optional params\n allowedPrivateKeyLengths?: readonly number[]; // for P521\n wrapPrivateKey?: boolean; // bls12-381 requires mod(n) instead of rejecting keys >= n\n endo?: EndomorphismOpts; // Endomorphism options for Koblitz curves\n // When a cofactor != 1, there can be an effective methods to:\n // 1. Determine whether a point is torsion-free\n isTorsionFree?: (c: ProjConstructor, point: ProjPointType) => boolean;\n // 2. Clear torsion component\n clearCofactor?: (c: ProjConstructor, point: ProjPointType) => ProjPointType;\n};\n\ntype Entropy = Hex | boolean;\nexport type SignOpts = { lowS?: boolean; extraEntropy?: Entropy; prehash?: boolean };\nexport type VerOpts = { lowS?: boolean; prehash?: boolean; format?: 'compact' | 'der' | undefined };\n\nfunction validateSigVerOpts(opts: SignOpts | VerOpts) {\n if (opts.lowS !== undefined) abool('lowS', opts.lowS);\n if (opts.prehash !== undefined) abool('prehash', opts.prehash);\n}\n\n// Instance for 3d XYZ points\nexport interface ProjPointType extends Group> {\n readonly px: T;\n readonly py: T;\n readonly pz: T;\n get x(): T;\n get y(): T;\n multiply(scalar: bigint): ProjPointType;\n toAffine(iz?: T): AffinePoint;\n isTorsionFree(): boolean;\n clearCofactor(): ProjPointType;\n assertValidity(): void;\n hasEvenY(): boolean;\n toRawBytes(isCompressed?: boolean): Uint8Array;\n toHex(isCompressed?: boolean): string;\n\n multiplyUnsafe(scalar: bigint): ProjPointType;\n multiplyAndAddUnsafe(Q: ProjPointType, a: bigint, b: bigint): ProjPointType | undefined;\n _setWindowSize(windowSize: number): void;\n}\n// Static methods for 3d XYZ points\nexport interface ProjConstructor extends GroupConstructor> {\n new (x: T, y: T, z: T): ProjPointType;\n fromAffine(p: AffinePoint): ProjPointType;\n fromHex(hex: Hex): ProjPointType;\n fromPrivateKey(privateKey: PrivKey): ProjPointType;\n normalizeZ(points: ProjPointType[]): ProjPointType[];\n msm(points: ProjPointType[], scalars: bigint[]): ProjPointType;\n}\n\nexport type CurvePointsType = BasicWCurve & {\n // Bytes\n fromBytes?: (bytes: Uint8Array) => AffinePoint;\n toBytes?: (c: ProjConstructor, point: ProjPointType, isCompressed: boolean) => Uint8Array;\n};\n\nexport type CurvePointsTypeWithLength = Readonly<\n CurvePointsType & { nByteLength: number; nBitLength: number }\n>;\n\nfunction validatePointOpts(curve: CurvePointsType): CurvePointsTypeWithLength {\n const opts = validateBasic(curve);\n ut.validateObject(\n opts,\n {\n a: 'field',\n b: 'field',\n },\n {\n allowedPrivateKeyLengths: 'array',\n wrapPrivateKey: 'boolean',\n isTorsionFree: 'function',\n clearCofactor: 'function',\n allowInfinityPoint: 'boolean',\n fromBytes: 'function',\n toBytes: 'function',\n }\n );\n const { endo, Fp, a } = opts;\n if (endo) {\n if (!Fp.eql(a, Fp.ZERO)) {\n throw new Error('invalid endomorphism, can only be defined for Koblitz curves that have a=0');\n }\n if (\n typeof endo !== 'object' ||\n typeof endo.beta !== 'bigint' ||\n typeof endo.splitScalar !== 'function'\n ) {\n throw new Error('invalid endomorphism, expected beta: bigint and splitScalar: function');\n }\n }\n return Object.freeze({ ...opts } as const);\n}\n\nexport type CurvePointsRes = {\n CURVE: ReturnType>;\n ProjectivePoint: ProjConstructor;\n normPrivateKeyToScalar: (key: PrivKey) => bigint;\n weierstrassEquation: (x: T) => T;\n isWithinCurveOrder: (num: bigint) => boolean;\n};\n\nconst { bytesToNumberBE: b2n, hexToBytes: h2b } = ut;\n\nexport class DERErr extends Error {\n constructor(m = '') {\n super(m);\n }\n}\nexport type IDER = {\n // asn.1 DER encoding utils\n Err: typeof DERErr;\n // Basic building block is TLV (Tag-Length-Value)\n _tlv: {\n encode: (tag: number, data: string) => string;\n // v - value, l - left bytes (unparsed)\n decode(tag: number, data: Uint8Array): { v: Uint8Array; l: Uint8Array };\n };\n // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,\n // since we always use positive integers here. It must always be empty:\n // - add zero byte if exists\n // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)\n _int: {\n encode(num: bigint): string;\n decode(data: Uint8Array): bigint;\n };\n toSig(hex: string | Uint8Array): { r: bigint; s: bigint };\n hexFromSig(sig: { r: bigint; s: bigint }): string;\n};\n/**\n * ASN.1 DER encoding utilities. ASN is very complex & fragile. Format:\n *\n * [0x30 (SEQUENCE), bytelength, 0x02 (INTEGER), intLength, R, 0x02 (INTEGER), intLength, S]\n *\n * Docs: https://letsencrypt.org/docs/a-warm-welcome-to-asn1-and-der/, https://luca.ntop.org/Teaching/Appunti/asn1.html\n */\nexport const DER: IDER = {\n // asn.1 DER encoding utils\n Err: DERErr,\n // Basic building block is TLV (Tag-Length-Value)\n _tlv: {\n encode: (tag: number, data: string): string => {\n const { Err: E } = DER;\n if (tag < 0 || tag > 256) throw new E('tlv.encode: wrong tag');\n if (data.length & 1) throw new E('tlv.encode: unpadded data');\n const dataLen = data.length / 2;\n const len = ut.numberToHexUnpadded(dataLen);\n if ((len.length / 2) & 0b1000_0000) throw new E('tlv.encode: long form length too big');\n // length of length with long form flag\n const lenLen = dataLen > 127 ? ut.numberToHexUnpadded((len.length / 2) | 0b1000_0000) : '';\n const t = ut.numberToHexUnpadded(tag);\n return t + lenLen + len + data;\n },\n // v - value, l - left bytes (unparsed)\n decode(tag: number, data: Uint8Array): { v: Uint8Array; l: Uint8Array } {\n const { Err: E } = DER;\n let pos = 0;\n if (tag < 0 || tag > 256) throw new E('tlv.encode: wrong tag');\n if (data.length < 2 || data[pos++] !== tag) throw new E('tlv.decode: wrong tlv');\n const first = data[pos++];\n const isLong = !!(first & 0b1000_0000); // First bit of first length byte is flag for short/long form\n let length = 0;\n if (!isLong) length = first;\n else {\n // Long form: [longFlag(1bit), lengthLength(7bit), length (BE)]\n const lenLen = first & 0b0111_1111;\n if (!lenLen) throw new E('tlv.decode(long): indefinite length not supported');\n if (lenLen > 4) throw new E('tlv.decode(long): byte length is too big'); // this will overflow u32 in js\n const lengthBytes = data.subarray(pos, pos + lenLen);\n if (lengthBytes.length !== lenLen) throw new E('tlv.decode: length bytes not complete');\n if (lengthBytes[0] === 0) throw new E('tlv.decode(long): zero leftmost byte');\n for (const b of lengthBytes) length = (length << 8) | b;\n pos += lenLen;\n if (length < 128) throw new E('tlv.decode(long): not minimal encoding');\n }\n const v = data.subarray(pos, pos + length);\n if (v.length !== length) throw new E('tlv.decode: wrong value length');\n return { v, l: data.subarray(pos + length) };\n },\n },\n // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,\n // since we always use positive integers here. It must always be empty:\n // - add zero byte if exists\n // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)\n _int: {\n encode(num: bigint): string {\n const { Err: E } = DER;\n if (num < _0n) throw new E('integer: negative integers are not allowed');\n let hex = ut.numberToHexUnpadded(num);\n // Pad with zero byte if negative flag is present\n if (Number.parseInt(hex[0], 16) & 0b1000) hex = '00' + hex;\n if (hex.length & 1) throw new E('unexpected DER parsing assertion: unpadded hex');\n return hex;\n },\n decode(data: Uint8Array): bigint {\n const { Err: E } = DER;\n if (data[0] & 0b1000_0000) throw new E('invalid signature integer: negative');\n if (data[0] === 0x00 && !(data[1] & 0b1000_0000))\n throw new E('invalid signature integer: unnecessary leading zero');\n return b2n(data);\n },\n },\n toSig(hex: string | Uint8Array): { r: bigint; s: bigint } {\n // parse DER signature\n const { Err: E, _int: int, _tlv: tlv } = DER;\n const data = typeof hex === 'string' ? h2b(hex) : hex;\n ut.abytes(data);\n const { v: seqBytes, l: seqLeftBytes } = tlv.decode(0x30, data);\n if (seqLeftBytes.length) throw new E('invalid signature: left bytes after parsing');\n const { v: rBytes, l: rLeftBytes } = tlv.decode(0x02, seqBytes);\n const { v: sBytes, l: sLeftBytes } = tlv.decode(0x02, rLeftBytes);\n if (sLeftBytes.length) throw new E('invalid signature: left bytes after parsing');\n return { r: int.decode(rBytes), s: int.decode(sBytes) };\n },\n hexFromSig(sig: { r: bigint; s: bigint }): string {\n const { _tlv: tlv, _int: int } = DER;\n const rs = tlv.encode(0x02, int.encode(sig.r));\n const ss = tlv.encode(0x02, int.encode(sig.s));\n const seq = rs + ss;\n return tlv.encode(0x30, seq);\n },\n};\n\n// Be friendly to bad ECMAScript parsers by not using bigint literals\n// prettier-ignore\nconst _0n = BigInt(0), _1n = BigInt(1), _2n = BigInt(2), _3n = BigInt(3), _4n = BigInt(4);\n\nexport function weierstrassPoints(opts: CurvePointsType): CurvePointsRes {\n const CURVE = validatePointOpts(opts);\n const { Fp } = CURVE; // All curves has same field / group length as for now, but they can differ\n const Fn = Field(CURVE.n, CURVE.nBitLength);\n\n const toBytes =\n CURVE.toBytes ||\n ((_c: ProjConstructor, point: ProjPointType, _isCompressed: boolean) => {\n const a = point.toAffine();\n return ut.concatBytes(Uint8Array.from([0x04]), Fp.toBytes(a.x), Fp.toBytes(a.y));\n });\n const fromBytes =\n CURVE.fromBytes ||\n ((bytes: Uint8Array) => {\n // const head = bytes[0];\n const tail = bytes.subarray(1);\n // if (head !== 0x04) throw new Error('Only non-compressed encoding is supported');\n const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES));\n const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));\n return { x, y };\n });\n\n /**\n * y² = x³ + ax + b: Short weierstrass curve formula\n * @returns y²\n */\n function weierstrassEquation(x: T): T {\n const { a, b } = CURVE;\n const x2 = Fp.sqr(x); // x * x\n const x3 = Fp.mul(x2, x); // x2 * x\n return Fp.add(Fp.add(x3, Fp.mul(x, a)), b); // x3 + a * x + b\n }\n // Validate whether the passed curve params are valid.\n // We check if curve equation works for generator point.\n // `assertValidity()` won't work: `isTorsionFree()` is not available at this point in bls12-381.\n // ProjectivePoint class has not been initialized yet.\n if (!Fp.eql(Fp.sqr(CURVE.Gy), weierstrassEquation(CURVE.Gx)))\n throw new Error('bad generator point: equation left != right');\n\n // Valid group elements reside in range 1..n-1\n function isWithinCurveOrder(num: bigint): boolean {\n return ut.inRange(num, _1n, CURVE.n);\n }\n // Validates if priv key is valid and converts it to bigint.\n // Supports options allowedPrivateKeyLengths and wrapPrivateKey.\n function normPrivateKeyToScalar(key: PrivKey): bigint {\n const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n: N } = CURVE;\n if (lengths && typeof key !== 'bigint') {\n if (ut.isBytes(key)) key = ut.bytesToHex(key);\n // Normalize to hex string, pad. E.g. P521 would norm 130-132 char hex to 132-char bytes\n if (typeof key !== 'string' || !lengths.includes(key.length))\n throw new Error('invalid private key');\n key = key.padStart(nByteLength * 2, '0');\n }\n let num: bigint;\n try {\n num =\n typeof key === 'bigint'\n ? key\n : ut.bytesToNumberBE(ensureBytes('private key', key, nByteLength));\n } catch (error) {\n throw new Error(\n 'invalid private key, expected hex or ' + nByteLength + ' bytes, got ' + typeof key\n );\n }\n if (wrapPrivateKey) num = mod(num, N); // disabled by default, enabled for BLS\n ut.aInRange('private key', num, _1n, N); // num in range [1..N-1]\n return num;\n }\n\n function assertPrjPoint(other: unknown) {\n if (!(other instanceof Point)) throw new Error('ProjectivePoint expected');\n }\n\n // Memoized toAffine / validity check. They are heavy. Points are immutable.\n\n // Converts Projective point to affine (x, y) coordinates.\n // Can accept precomputed Z^-1 - for example, from invertBatch.\n // (x, y, z) ∋ (x=x/z, y=y/z)\n const toAffineMemo = memoized((p: Point, iz?: T): AffinePoint => {\n const { px: x, py: y, pz: z } = p;\n // Fast-path for normalized points\n if (Fp.eql(z, Fp.ONE)) return { x, y };\n const is0 = p.is0();\n // If invZ was 0, we return zero point. However we still want to execute\n // all operations, so we replace invZ with a random number, 1.\n if (iz == null) iz = is0 ? Fp.ONE : Fp.inv(z);\n const ax = Fp.mul(x, iz);\n const ay = Fp.mul(y, iz);\n const zz = Fp.mul(z, iz);\n if (is0) return { x: Fp.ZERO, y: Fp.ZERO };\n if (!Fp.eql(zz, Fp.ONE)) throw new Error('invZ was invalid');\n return { x: ax, y: ay };\n });\n // NOTE: on exception this will crash 'cached' and no value will be set.\n // Otherwise true will be return\n const assertValidMemo = memoized((p: Point) => {\n if (p.is0()) {\n // (0, 1, 0) aka ZERO is invalid in most contexts.\n // In BLS, ZERO can be serialized, so we allow it.\n // (0, 0, 0) is invalid representation of ZERO.\n if (CURVE.allowInfinityPoint && !Fp.is0(p.py)) return;\n throw new Error('bad point: ZERO');\n }\n // Some 3rd-party test vectors require different wording between here & `fromCompressedHex`\n const { x, y } = p.toAffine();\n // Check if x, y are valid field elements\n if (!Fp.isValid(x) || !Fp.isValid(y)) throw new Error('bad point: x or y not FE');\n const left = Fp.sqr(y); // y²\n const right = weierstrassEquation(x); // x³ + ax + b\n if (!Fp.eql(left, right)) throw new Error('bad point: equation left != right');\n if (!p.isTorsionFree()) throw new Error('bad point: not in prime-order subgroup');\n return true;\n });\n\n /**\n * Projective Point works in 3d / projective (homogeneous) coordinates: (x, y, z) ∋ (x=x/z, y=y/z)\n * Default Point works in 2d / affine coordinates: (x, y)\n * We're doing calculations in projective, because its operations don't require costly inversion.\n */\n class Point implements ProjPointType {\n static readonly BASE = new Point(CURVE.Gx, CURVE.Gy, Fp.ONE);\n static readonly ZERO = new Point(Fp.ZERO, Fp.ONE, Fp.ZERO);\n\n constructor(\n readonly px: T,\n readonly py: T,\n readonly pz: T\n ) {\n if (px == null || !Fp.isValid(px)) throw new Error('x required');\n if (py == null || !Fp.isValid(py)) throw new Error('y required');\n if (pz == null || !Fp.isValid(pz)) throw new Error('z required');\n Object.freeze(this);\n }\n\n // Does not validate if the point is on-curve.\n // Use fromHex instead, or call assertValidity() later.\n static fromAffine(p: AffinePoint): Point {\n const { x, y } = p || {};\n if (!p || !Fp.isValid(x) || !Fp.isValid(y)) throw new Error('invalid affine point');\n if (p instanceof Point) throw new Error('projective point not allowed');\n const is0 = (i: T) => Fp.eql(i, Fp.ZERO);\n // fromAffine(x:0, y:0) would produce (x:0, y:0, z:1), but we need (x:0, y:1, z:0)\n if (is0(x) && is0(y)) return Point.ZERO;\n return new Point(x, y, Fp.ONE);\n }\n\n get x(): T {\n return this.toAffine().x;\n }\n get y(): T {\n return this.toAffine().y;\n }\n\n /**\n * Takes a bunch of Projective Points but executes only one\n * inversion on all of them. Inversion is very slow operation,\n * so this improves performance massively.\n * Optimization: converts a list of projective points to a list of identical points with Z=1.\n */\n static normalizeZ(points: Point[]): Point[] {\n const toInv = Fp.invertBatch(points.map((p) => p.pz));\n return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine);\n }\n\n /**\n * Converts hash string or Uint8Array to Point.\n * @param hex short/long ECDSA hex\n */\n static fromHex(hex: Hex): Point {\n const P = Point.fromAffine(fromBytes(ensureBytes('pointHex', hex)));\n P.assertValidity();\n return P;\n }\n\n // Multiplies generator point by privateKey.\n static fromPrivateKey(privateKey: PrivKey) {\n return Point.BASE.multiply(normPrivateKeyToScalar(privateKey));\n }\n\n // Multiscalar Multiplication\n static msm(points: Point[], scalars: bigint[]): Point {\n return pippenger(Point, Fn, points, scalars);\n }\n\n // \"Private method\", don't use it directly\n _setWindowSize(windowSize: number) {\n wnaf.setWindowSize(this, windowSize);\n }\n\n // A point on curve is valid if it conforms to equation.\n assertValidity(): void {\n assertValidMemo(this);\n }\n\n hasEvenY(): boolean {\n const { y } = this.toAffine();\n if (Fp.isOdd) return !Fp.isOdd(y);\n throw new Error(\"Field doesn't support isOdd\");\n }\n\n /**\n * Compare one point to another.\n */\n equals(other: Point): boolean {\n assertPrjPoint(other);\n const { px: X1, py: Y1, pz: Z1 } = this;\n const { px: X2, py: Y2, pz: Z2 } = other;\n const U1 = Fp.eql(Fp.mul(X1, Z2), Fp.mul(X2, Z1));\n const U2 = Fp.eql(Fp.mul(Y1, Z2), Fp.mul(Y2, Z1));\n return U1 && U2;\n }\n\n /**\n * Flips point to one corresponding to (x, -y) in Affine coordinates.\n */\n negate(): Point {\n return new Point(this.px, Fp.neg(this.py), this.pz);\n }\n\n // Renes-Costello-Batina exception-free doubling formula.\n // There is 30% faster Jacobian formula, but it is not complete.\n // https://eprint.iacr.org/2015/1060, algorithm 3\n // Cost: 8M + 3S + 3*a + 2*b3 + 15add.\n double() {\n const { a, b } = CURVE;\n const b3 = Fp.mul(b, _3n);\n const { px: X1, py: Y1, pz: Z1 } = this;\n let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore\n let t0 = Fp.mul(X1, X1); // step 1\n let t1 = Fp.mul(Y1, Y1);\n let t2 = Fp.mul(Z1, Z1);\n let t3 = Fp.mul(X1, Y1);\n t3 = Fp.add(t3, t3); // step 5\n Z3 = Fp.mul(X1, Z1);\n Z3 = Fp.add(Z3, Z3);\n X3 = Fp.mul(a, Z3);\n Y3 = Fp.mul(b3, t2);\n Y3 = Fp.add(X3, Y3); // step 10\n X3 = Fp.sub(t1, Y3);\n Y3 = Fp.add(t1, Y3);\n Y3 = Fp.mul(X3, Y3);\n X3 = Fp.mul(t3, X3);\n Z3 = Fp.mul(b3, Z3); // step 15\n t2 = Fp.mul(a, t2);\n t3 = Fp.sub(t0, t2);\n t3 = Fp.mul(a, t3);\n t3 = Fp.add(t3, Z3);\n Z3 = Fp.add(t0, t0); // step 20\n t0 = Fp.add(Z3, t0);\n t0 = Fp.add(t0, t2);\n t0 = Fp.mul(t0, t3);\n Y3 = Fp.add(Y3, t0);\n t2 = Fp.mul(Y1, Z1); // step 25\n t2 = Fp.add(t2, t2);\n t0 = Fp.mul(t2, t3);\n X3 = Fp.sub(X3, t0);\n Z3 = Fp.mul(t2, t1);\n Z3 = Fp.add(Z3, Z3); // step 30\n Z3 = Fp.add(Z3, Z3);\n return new Point(X3, Y3, Z3);\n }\n\n // Renes-Costello-Batina exception-free addition formula.\n // There is 30% faster Jacobian formula, but it is not complete.\n // https://eprint.iacr.org/2015/1060, algorithm 1\n // Cost: 12M + 0S + 3*a + 3*b3 + 23add.\n add(other: Point): Point {\n assertPrjPoint(other);\n const { px: X1, py: Y1, pz: Z1 } = this;\n const { px: X2, py: Y2, pz: Z2 } = other;\n let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO; // prettier-ignore\n const a = CURVE.a;\n const b3 = Fp.mul(CURVE.b, _3n);\n let t0 = Fp.mul(X1, X2); // step 1\n let t1 = Fp.mul(Y1, Y2);\n let t2 = Fp.mul(Z1, Z2);\n let t3 = Fp.add(X1, Y1);\n let t4 = Fp.add(X2, Y2); // step 5\n t3 = Fp.mul(t3, t4);\n t4 = Fp.add(t0, t1);\n t3 = Fp.sub(t3, t4);\n t4 = Fp.add(X1, Z1);\n let t5 = Fp.add(X2, Z2); // step 10\n t4 = Fp.mul(t4, t5);\n t5 = Fp.add(t0, t2);\n t4 = Fp.sub(t4, t5);\n t5 = Fp.add(Y1, Z1);\n X3 = Fp.add(Y2, Z2); // step 15\n t5 = Fp.mul(t5, X3);\n X3 = Fp.add(t1, t2);\n t5 = Fp.sub(t5, X3);\n Z3 = Fp.mul(a, t4);\n X3 = Fp.mul(b3, t2); // step 20\n Z3 = Fp.add(X3, Z3);\n X3 = Fp.sub(t1, Z3);\n Z3 = Fp.add(t1, Z3);\n Y3 = Fp.mul(X3, Z3);\n t1 = Fp.add(t0, t0); // step 25\n t1 = Fp.add(t1, t0);\n t2 = Fp.mul(a, t2);\n t4 = Fp.mul(b3, t4);\n t1 = Fp.add(t1, t2);\n t2 = Fp.sub(t0, t2); // step 30\n t2 = Fp.mul(a, t2);\n t4 = Fp.add(t4, t2);\n t0 = Fp.mul(t1, t4);\n Y3 = Fp.add(Y3, t0);\n t0 = Fp.mul(t5, t4); // step 35\n X3 = Fp.mul(t3, X3);\n X3 = Fp.sub(X3, t0);\n t0 = Fp.mul(t3, t1);\n Z3 = Fp.mul(t5, Z3);\n Z3 = Fp.add(Z3, t0); // step 40\n return new Point(X3, Y3, Z3);\n }\n\n subtract(other: Point) {\n return this.add(other.negate());\n }\n\n is0() {\n return this.equals(Point.ZERO);\n }\n private wNAF(n: bigint): { p: Point; f: Point } {\n return wnaf.wNAFCached(this, n, Point.normalizeZ);\n }\n\n /**\n * Non-constant-time multiplication. Uses double-and-add algorithm.\n * It's faster, but should only be used when you don't care about\n * an exposed private key e.g. sig verification, which works over *public* keys.\n */\n multiplyUnsafe(sc: bigint): Point {\n const { endo, n: N } = CURVE;\n ut.aInRange('scalar', sc, _0n, N);\n const I = Point.ZERO;\n if (sc === _0n) return I;\n if (this.is0() || sc === _1n) return this;\n\n // Case a: no endomorphism. Case b: has precomputes.\n if (!endo || wnaf.hasPrecomputes(this))\n return wnaf.wNAFCachedUnsafe(this, sc, Point.normalizeZ);\n\n // Case c: endomorphism\n let { k1neg, k1, k2neg, k2 } = endo.splitScalar(sc);\n let k1p = I;\n let k2p = I;\n let d: Point = this;\n while (k1 > _0n || k2 > _0n) {\n if (k1 & _1n) k1p = k1p.add(d);\n if (k2 & _1n) k2p = k2p.add(d);\n d = d.double();\n k1 >>= _1n;\n k2 >>= _1n;\n }\n if (k1neg) k1p = k1p.negate();\n if (k2neg) k2p = k2p.negate();\n k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz);\n return k1p.add(k2p);\n }\n\n /**\n * Constant time multiplication.\n * Uses wNAF method. Windowed method may be 10% faster,\n * but takes 2x longer to generate and consumes 2x memory.\n * Uses precomputes when available.\n * Uses endomorphism for Koblitz curves.\n * @param scalar by which the point would be multiplied\n * @returns New point\n */\n multiply(scalar: bigint): Point {\n const { endo, n: N } = CURVE;\n ut.aInRange('scalar', scalar, _1n, N);\n let point: Point, fake: Point; // Fake point is used to const-time mult\n if (endo) {\n const { k1neg, k1, k2neg, k2 } = endo.splitScalar(scalar);\n let { p: k1p, f: f1p } = this.wNAF(k1);\n let { p: k2p, f: f2p } = this.wNAF(k2);\n k1p = wnaf.constTimeNegate(k1neg, k1p);\n k2p = wnaf.constTimeNegate(k2neg, k2p);\n k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz);\n point = k1p.add(k2p);\n fake = f1p.add(f2p);\n } else {\n const { p, f } = this.wNAF(scalar);\n point = p;\n fake = f;\n }\n // Normalize `z` for both points, but return only real one\n return Point.normalizeZ([point, fake])[0];\n }\n\n /**\n * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.\n * Not using Strauss-Shamir trick: precomputation tables are faster.\n * The trick could be useful if both P and Q are not G (not in our case).\n * @returns non-zero affine point\n */\n multiplyAndAddUnsafe(Q: Point, a: bigint, b: bigint): Point | undefined {\n const G = Point.BASE; // No Strauss-Shamir trick: we have 10% faster G precomputes\n const mul = (\n P: Point,\n a: bigint // Select faster multiply() method\n ) => (a === _0n || a === _1n || !P.equals(G) ? P.multiplyUnsafe(a) : P.multiply(a));\n const sum = mul(this, a).add(mul(Q, b));\n return sum.is0() ? undefined : sum;\n }\n\n // Converts Projective point to affine (x, y) coordinates.\n // Can accept precomputed Z^-1 - for example, from invertBatch.\n // (x, y, z) ∋ (x=x/z, y=y/z)\n toAffine(iz?: T): AffinePoint {\n return toAffineMemo(this, iz);\n }\n isTorsionFree(): boolean {\n const { h: cofactor, isTorsionFree } = CURVE;\n if (cofactor === _1n) return true; // No subgroups, always torsion-free\n if (isTorsionFree) return isTorsionFree(Point, this);\n throw new Error('isTorsionFree() has not been declared for the elliptic curve');\n }\n clearCofactor(): Point {\n const { h: cofactor, clearCofactor } = CURVE;\n if (cofactor === _1n) return this; // Fast-path\n if (clearCofactor) return clearCofactor(Point, this) as Point;\n return this.multiplyUnsafe(CURVE.h);\n }\n\n toRawBytes(isCompressed = true): Uint8Array {\n abool('isCompressed', isCompressed);\n this.assertValidity();\n return toBytes(Point, this, isCompressed);\n }\n\n toHex(isCompressed = true): string {\n abool('isCompressed', isCompressed);\n return ut.bytesToHex(this.toRawBytes(isCompressed));\n }\n }\n const _bits = CURVE.nBitLength;\n const wnaf = wNAF(Point, CURVE.endo ? Math.ceil(_bits / 2) : _bits);\n // Validate if generator point is on curve\n return {\n CURVE,\n ProjectivePoint: Point as ProjConstructor,\n normPrivateKeyToScalar,\n weierstrassEquation,\n isWithinCurveOrder,\n };\n}\n\n// Instance\nexport interface SignatureType {\n readonly r: bigint;\n readonly s: bigint;\n readonly recovery?: number;\n assertValidity(): void;\n addRecoveryBit(recovery: number): RecoveredSignatureType;\n hasHighS(): boolean;\n normalizeS(): SignatureType;\n recoverPublicKey(msgHash: Hex): ProjPointType;\n toCompactRawBytes(): Uint8Array;\n toCompactHex(): string;\n // DER-encoded\n toDERRawBytes(isCompressed?: boolean): Uint8Array;\n toDERHex(isCompressed?: boolean): string;\n}\nexport type RecoveredSignatureType = SignatureType & {\n readonly recovery: number;\n};\n// Static methods\nexport type SignatureConstructor = {\n new (r: bigint, s: bigint): SignatureType;\n fromCompact(hex: Hex): SignatureType;\n fromDER(hex: Hex): SignatureType;\n};\ntype SignatureLike = { r: bigint; s: bigint };\n\nexport type PubKey = Hex | ProjPointType;\n\nexport type CurveType = BasicWCurve & {\n hash: CHash; // CHash not FHash because we need outputLen for DRBG\n hmac: HmacFnSync;\n randomBytes: (bytesLength?: number) => Uint8Array;\n lowS?: boolean;\n bits2int?: (bytes: Uint8Array) => bigint;\n bits2int_modN?: (bytes: Uint8Array) => bigint;\n};\n\nfunction validateOpts(\n curve: CurveType\n): Readonly {\n const opts = validateBasic(curve);\n ut.validateObject(\n opts,\n {\n hash: 'hash',\n hmac: 'function',\n randomBytes: 'function',\n },\n {\n bits2int: 'function',\n bits2int_modN: 'function',\n lowS: 'boolean',\n }\n );\n return Object.freeze({ lowS: true, ...opts } as const);\n}\n\nexport type CurveFn = {\n CURVE: ReturnType;\n getPublicKey: (privateKey: PrivKey, isCompressed?: boolean) => Uint8Array;\n getSharedSecret: (privateA: PrivKey, publicB: Hex, isCompressed?: boolean) => Uint8Array;\n sign: (msgHash: Hex, privKey: PrivKey, opts?: SignOpts) => RecoveredSignatureType;\n verify: (signature: Hex | SignatureLike, msgHash: Hex, publicKey: Hex, opts?: VerOpts) => boolean;\n ProjectivePoint: ProjConstructor;\n Signature: SignatureConstructor;\n utils: {\n normPrivateKeyToScalar: (key: PrivKey) => bigint;\n isValidPrivateKey(privateKey: PrivKey): boolean;\n randomPrivateKey: () => Uint8Array;\n precompute: (windowSize?: number, point?: ProjPointType) => ProjPointType;\n };\n};\n\n/**\n * Creates short weierstrass curve and ECDSA signature methods for it.\n * @example\n * import { Field } from '@noble/curves/abstract/modular';\n * // Before that, define BigInt-s: a, b, p, n, Gx, Gy\n * const curve = weierstrass({ a, b, Fp: Field(p), n, Gx, Gy, h: 1n })\n */\nexport function weierstrass(curveDef: CurveType): CurveFn {\n const CURVE = validateOpts(curveDef) as ReturnType;\n const { Fp, n: CURVE_ORDER } = CURVE;\n const compressedLen = Fp.BYTES + 1; // e.g. 33 for 32\n const uncompressedLen = 2 * Fp.BYTES + 1; // e.g. 65 for 32\n\n function modN(a: bigint) {\n return mod(a, CURVE_ORDER);\n }\n function invN(a: bigint) {\n return invert(a, CURVE_ORDER);\n }\n\n const {\n ProjectivePoint: Point,\n normPrivateKeyToScalar,\n weierstrassEquation,\n isWithinCurveOrder,\n } = weierstrassPoints({\n ...CURVE,\n toBytes(_c, point, isCompressed: boolean): Uint8Array {\n const a = point.toAffine();\n const x = Fp.toBytes(a.x);\n const cat = ut.concatBytes;\n abool('isCompressed', isCompressed);\n if (isCompressed) {\n return cat(Uint8Array.from([point.hasEvenY() ? 0x02 : 0x03]), x);\n } else {\n return cat(Uint8Array.from([0x04]), x, Fp.toBytes(a.y));\n }\n },\n fromBytes(bytes: Uint8Array) {\n const len = bytes.length;\n const head = bytes[0];\n const tail = bytes.subarray(1);\n // this.assertValidity() is done inside of fromHex\n if (len === compressedLen && (head === 0x02 || head === 0x03)) {\n const x = ut.bytesToNumberBE(tail);\n if (!ut.inRange(x, _1n, Fp.ORDER)) throw new Error('Point is not on curve');\n const y2 = weierstrassEquation(x); // y² = x³ + ax + b\n let y: bigint;\n try {\n y = Fp.sqrt(y2); // y = y² ^ (p+1)/4\n } catch (sqrtError) {\n const suffix = sqrtError instanceof Error ? ': ' + sqrtError.message : '';\n throw new Error('Point is not on curve' + suffix);\n }\n const isYOdd = (y & _1n) === _1n;\n // ECDSA\n const isHeadOdd = (head & 1) === 1;\n if (isHeadOdd !== isYOdd) y = Fp.neg(y);\n return { x, y };\n } else if (len === uncompressedLen && head === 0x04) {\n const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES));\n const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));\n return { x, y };\n } else {\n const cl = compressedLen;\n const ul = uncompressedLen;\n throw new Error(\n 'invalid Point, expected length of ' + cl + ', or uncompressed ' + ul + ', got ' + len\n );\n }\n },\n });\n const numToNByteStr = (num: bigint): string =>\n ut.bytesToHex(ut.numberToBytesBE(num, CURVE.nByteLength));\n\n function isBiggerThanHalfOrder(number: bigint) {\n const HALF = CURVE_ORDER >> _1n;\n return number > HALF;\n }\n\n function normalizeS(s: bigint) {\n return isBiggerThanHalfOrder(s) ? modN(-s) : s;\n }\n // slice bytes num\n const slcNum = (b: Uint8Array, from: number, to: number) => ut.bytesToNumberBE(b.slice(from, to));\n\n /**\n * ECDSA signature with its (r, s) properties. Supports DER & compact representations.\n */\n class Signature implements SignatureType {\n constructor(\n readonly r: bigint,\n readonly s: bigint,\n readonly recovery?: number\n ) {\n this.assertValidity();\n }\n\n // pair (bytes of r, bytes of s)\n static fromCompact(hex: Hex) {\n const l = CURVE.nByteLength;\n hex = ensureBytes('compactSignature', hex, l * 2);\n return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l));\n }\n\n // DER encoded ECDSA signature\n // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script\n static fromDER(hex: Hex) {\n const { r, s } = DER.toSig(ensureBytes('DER', hex));\n return new Signature(r, s);\n }\n\n assertValidity(): void {\n ut.aInRange('r', this.r, _1n, CURVE_ORDER); // r in [1..N]\n ut.aInRange('s', this.s, _1n, CURVE_ORDER); // s in [1..N]\n }\n\n addRecoveryBit(recovery: number): RecoveredSignature {\n return new Signature(this.r, this.s, recovery) as RecoveredSignature;\n }\n\n recoverPublicKey(msgHash: Hex): typeof Point.BASE {\n const { r, s, recovery: rec } = this;\n const h = bits2int_modN(ensureBytes('msgHash', msgHash)); // Truncate hash\n if (rec == null || ![0, 1, 2, 3].includes(rec)) throw new Error('recovery id invalid');\n const radj = rec === 2 || rec === 3 ? r + CURVE.n : r;\n if (radj >= Fp.ORDER) throw new Error('recovery id 2 or 3 invalid');\n const prefix = (rec & 1) === 0 ? '02' : '03';\n const R = Point.fromHex(prefix + numToNByteStr(radj));\n const ir = invN(radj); // r^-1\n const u1 = modN(-h * ir); // -hr^-1\n const u2 = modN(s * ir); // sr^-1\n const Q = Point.BASE.multiplyAndAddUnsafe(R, u1, u2); // (sr^-1)R-(hr^-1)G = -(hr^-1)G + (sr^-1)\n if (!Q) throw new Error('point at infinify'); // unsafe is fine: no priv data leaked\n Q.assertValidity();\n return Q;\n }\n\n // Signatures should be low-s, to prevent malleability.\n hasHighS(): boolean {\n return isBiggerThanHalfOrder(this.s);\n }\n\n normalizeS() {\n return this.hasHighS() ? new Signature(this.r, modN(-this.s), this.recovery) : this;\n }\n\n // DER-encoded\n toDERRawBytes() {\n return ut.hexToBytes(this.toDERHex());\n }\n toDERHex() {\n return DER.hexFromSig({ r: this.r, s: this.s });\n }\n\n // padded bytes of r, then padded bytes of s\n toCompactRawBytes() {\n return ut.hexToBytes(this.toCompactHex());\n }\n toCompactHex() {\n return numToNByteStr(this.r) + numToNByteStr(this.s);\n }\n }\n type RecoveredSignature = Signature & { recovery: number };\n\n const utils = {\n isValidPrivateKey(privateKey: PrivKey) {\n try {\n normPrivateKeyToScalar(privateKey);\n return true;\n } catch (error) {\n return false;\n }\n },\n normPrivateKeyToScalar: normPrivateKeyToScalar,\n\n /**\n * Produces cryptographically secure private key from random of size\n * (groupLen + ceil(groupLen / 2)) with modulo bias being negligible.\n */\n randomPrivateKey: (): Uint8Array => {\n const length = getMinHashLength(CURVE.n);\n return mapHashToField(CURVE.randomBytes(length), CURVE.n);\n },\n\n /**\n * Creates precompute table for an arbitrary EC point. Makes point \"cached\".\n * Allows to massively speed-up `point.multiply(scalar)`.\n * @returns cached point\n * @example\n * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey));\n * fast.multiply(privKey); // much faster ECDH now\n */\n precompute(windowSize = 8, point = Point.BASE): typeof Point.BASE {\n point._setWindowSize(windowSize);\n point.multiply(BigInt(3)); // 3 is arbitrary, just need any number here\n return point;\n },\n };\n\n /**\n * Computes public key for a private key. Checks for validity of the private key.\n * @param privateKey private key\n * @param isCompressed whether to return compact (default), or full key\n * @returns Public key, full when isCompressed=false; short when isCompressed=true\n */\n function getPublicKey(privateKey: PrivKey, isCompressed = true): Uint8Array {\n return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed);\n }\n\n /**\n * Quick and dirty check for item being public key. Does not validate hex, or being on-curve.\n */\n function isProbPub(item: PrivKey | PubKey): boolean {\n const arr = ut.isBytes(item);\n const str = typeof item === 'string';\n const len = (arr || str) && (item as Hex).length;\n if (arr) return len === compressedLen || len === uncompressedLen;\n if (str) return len === 2 * compressedLen || len === 2 * uncompressedLen;\n if (item instanceof Point) return true;\n return false;\n }\n\n /**\n * ECDH (Elliptic Curve Diffie Hellman).\n * Computes shared public key from private key and public key.\n * Checks: 1) private key validity 2) shared key is on-curve.\n * Does NOT hash the result.\n * @param privateA private key\n * @param publicB different public key\n * @param isCompressed whether to return compact (default), or full key\n * @returns shared public key\n */\n function getSharedSecret(privateA: PrivKey, publicB: Hex, isCompressed = true): Uint8Array {\n if (isProbPub(privateA)) throw new Error('first arg must be private key');\n if (!isProbPub(publicB)) throw new Error('second arg must be public key');\n const b = Point.fromHex(publicB); // check for being on-curve\n return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);\n }\n\n // RFC6979: ensure ECDSA msg is X bytes and < N. RFC suggests optional truncating via bits2octets.\n // FIPS 186-4 4.6 suggests the leftmost min(nBitLen, outLen) bits, which matches bits2int.\n // bits2int can produce res>N, we can do mod(res, N) since the bitLen is the same.\n // int2octets can't be used; pads small msgs with 0: unacceptatble for trunc as per RFC vectors\n const bits2int =\n CURVE.bits2int ||\n function (bytes: Uint8Array): bigint {\n // Our custom check \"just in case\"\n if (bytes.length > 8192) throw new Error('input is too large');\n // For curves with nBitLength % 8 !== 0: bits2octets(bits2octets(m)) !== bits2octets(m)\n // for some cases, since bytes.length * 8 is not actual bitLength.\n const num = ut.bytesToNumberBE(bytes); // check for == u8 done here\n const delta = bytes.length * 8 - CURVE.nBitLength; // truncate to nBitLength leftmost bits\n return delta > 0 ? num >> BigInt(delta) : num;\n };\n const bits2int_modN =\n CURVE.bits2int_modN ||\n function (bytes: Uint8Array): bigint {\n return modN(bits2int(bytes)); // can't use bytesToNumberBE here\n };\n // NOTE: pads output with zero as per spec\n const ORDER_MASK = ut.bitMask(CURVE.nBitLength);\n /**\n * Converts to bytes. Checks if num in `[0..ORDER_MASK-1]` e.g.: `[0..2^256-1]`.\n */\n function int2octets(num: bigint): Uint8Array {\n ut.aInRange('num < 2^' + CURVE.nBitLength, num, _0n, ORDER_MASK);\n // works with order, can have different size than numToField!\n return ut.numberToBytesBE(num, CURVE.nByteLength);\n }\n\n // Steps A, D of RFC6979 3.2\n // Creates RFC6979 seed; converts msg/privKey to numbers.\n // Used only in sign, not in verify.\n // NOTE: we cannot assume here that msgHash has same amount of bytes as curve order,\n // this will be invalid at least for P521. Also it can be bigger for P224 + SHA256\n function prepSig(msgHash: Hex, privateKey: PrivKey, opts = defaultSigOpts) {\n if (['recovered', 'canonical'].some((k) => k in opts))\n throw new Error('sign() legacy options not supported');\n const { hash, randomBytes } = CURVE;\n let { lowS, prehash, extraEntropy: ent } = opts; // generates low-s sigs by default\n if (lowS == null) lowS = true; // RFC6979 3.2: we skip step A, because we already provide hash\n msgHash = ensureBytes('msgHash', msgHash);\n validateSigVerOpts(opts);\n if (prehash) msgHash = ensureBytes('prehashed msgHash', hash(msgHash));\n\n // We can't later call bits2octets, since nested bits2int is broken for curves\n // with nBitLength % 8 !== 0. Because of that, we unwrap it here as int2octets call.\n // const bits2octets = (bits) => int2octets(bits2int_modN(bits))\n const h1int = bits2int_modN(msgHash);\n const d = normPrivateKeyToScalar(privateKey); // validate private key, convert to bigint\n const seedArgs = [int2octets(d), int2octets(h1int)];\n // extraEntropy. RFC6979 3.6: additional k' (optional).\n if (ent != null && ent !== false) {\n // K = HMAC_K(V || 0x00 || int2octets(x) || bits2octets(h1) || k')\n const e = ent === true ? randomBytes(Fp.BYTES) : ent; // generate random bytes OR pass as-is\n seedArgs.push(ensureBytes('extraEntropy', e)); // check for being bytes\n }\n const seed = ut.concatBytes(...seedArgs); // Step D of RFC6979 3.2\n const m = h1int; // NOTE: no need to call bits2int second time here, it is inside truncateHash!\n // Converts signature params into point w r/s, checks result for validity.\n function k2sig(kBytes: Uint8Array): RecoveredSignature | undefined {\n // RFC 6979 Section 3.2, step 3: k = bits2int(T)\n const k = bits2int(kBytes); // Cannot use fields methods, since it is group element\n if (!isWithinCurveOrder(k)) return; // Important: all mod() calls here must be done over N\n const ik = invN(k); // k^-1 mod n\n const q = Point.BASE.multiply(k).toAffine(); // q = Gk\n const r = modN(q.x); // r = q.x mod n\n if (r === _0n) return;\n // Can use scalar blinding b^-1(bm + bdr) where b ∈ [1,q−1] according to\n // https://tches.iacr.org/index.php/TCHES/article/view/7337/6509. We've decided against it:\n // a) dependency on CSPRNG b) 15% slowdown c) doesn't really help since bigints are not CT\n const s = modN(ik * modN(m + r * d)); // Not using blinding here\n if (s === _0n) return;\n let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n); // recovery bit (2 or 3, when q.x > n)\n let normS = s;\n if (lowS && isBiggerThanHalfOrder(s)) {\n normS = normalizeS(s); // if lowS was passed, ensure s is always\n recovery ^= 1; // // in the bottom half of N\n }\n return new Signature(r, normS, recovery) as RecoveredSignature; // use normS, not s\n }\n return { seed, k2sig };\n }\n const defaultSigOpts: SignOpts = { lowS: CURVE.lowS, prehash: false };\n const defaultVerOpts: VerOpts = { lowS: CURVE.lowS, prehash: false };\n\n /**\n * Signs message hash with a private key.\n * ```\n * sign(m, d, k) where\n * (x, y) = G × k\n * r = x mod n\n * s = (m + dr)/k mod n\n * ```\n * @param msgHash NOT message. msg needs to be hashed to `msgHash`, or use `prehash`.\n * @param privKey private key\n * @param opts lowS for non-malleable sigs. extraEntropy for mixing randomness into k. prehash will hash first arg.\n * @returns signature with recovery param\n */\n function sign(msgHash: Hex, privKey: PrivKey, opts = defaultSigOpts): RecoveredSignature {\n const { seed, k2sig } = prepSig(msgHash, privKey, opts); // Steps A, D of RFC6979 3.2.\n const C = CURVE;\n const drbg = ut.createHmacDrbg(C.hash.outputLen, C.nByteLength, C.hmac);\n return drbg(seed, k2sig); // Steps B, C, D, E, F, G\n }\n\n // Enable precomputes. Slows down first publicKey computation by 20ms.\n Point.BASE._setWindowSize(8);\n // utils.precompute(8, ProjectivePoint.BASE)\n\n /**\n * Verifies a signature against message hash and public key.\n * Rejects lowS signatures by default: to override,\n * specify option `{lowS: false}`. Implements section 4.1.4 from https://www.secg.org/sec1-v2.pdf:\n *\n * ```\n * verify(r, s, h, P) where\n * U1 = hs^-1 mod n\n * U2 = rs^-1 mod n\n * R = U1⋅G - U2⋅P\n * mod(R.x, n) == r\n * ```\n */\n function verify(\n signature: Hex | SignatureLike,\n msgHash: Hex,\n publicKey: Hex,\n opts = defaultVerOpts\n ): boolean {\n const sg = signature;\n msgHash = ensureBytes('msgHash', msgHash);\n publicKey = ensureBytes('publicKey', publicKey);\n const { lowS, prehash, format } = opts;\n\n // Verify opts, deduce signature format\n validateSigVerOpts(opts);\n if ('strict' in opts) throw new Error('options.strict was renamed to lowS');\n if (format !== undefined && format !== 'compact' && format !== 'der')\n throw new Error('format must be compact or der');\n const isHex = typeof sg === 'string' || ut.isBytes(sg);\n const isObj =\n !isHex &&\n !format &&\n typeof sg === 'object' &&\n sg !== null &&\n typeof sg.r === 'bigint' &&\n typeof sg.s === 'bigint';\n if (!isHex && !isObj)\n throw new Error('invalid signature, expected Uint8Array, hex string or Signature instance');\n\n let _sig: Signature | undefined = undefined;\n let P: ProjPointType;\n try {\n if (isObj) _sig = new Signature(sg.r, sg.s);\n if (isHex) {\n // Signature can be represented in 2 ways: compact (2*nByteLength) & DER (variable-length).\n // Since DER can also be 2*nByteLength bytes, we check for it first.\n try {\n if (format !== 'compact') _sig = Signature.fromDER(sg);\n } catch (derError) {\n if (!(derError instanceof DER.Err)) throw derError;\n }\n if (!_sig && format !== 'der') _sig = Signature.fromCompact(sg);\n }\n P = Point.fromHex(publicKey);\n } catch (error) {\n return false;\n }\n if (!_sig) return false;\n if (lowS && _sig.hasHighS()) return false;\n if (prehash) msgHash = CURVE.hash(msgHash);\n const { r, s } = _sig;\n const h = bits2int_modN(msgHash); // Cannot use fields methods, since it is group element\n const is = invN(s); // s^-1\n const u1 = modN(h * is); // u1 = hs^-1 mod n\n const u2 = modN(r * is); // u2 = rs^-1 mod n\n const R = Point.BASE.multiplyAndAddUnsafe(P, u1, u2)?.toAffine(); // R = u1⋅G + u2⋅P\n if (!R) return false;\n const v = modN(R.x);\n return v === r;\n }\n return {\n CURVE,\n getPublicKey,\n getSharedSecret,\n sign,\n verify,\n ProjectivePoint: Point,\n Signature,\n utils,\n };\n}\n\n/**\n * Implementation of the Shallue and van de Woestijne method for any weierstrass curve.\n * TODO: check if there is a way to merge this with uvRatio in Edwards; move to modular.\n * b = True and y = sqrt(u / v) if (u / v) is square in F, and\n * b = False and y = sqrt(Z * (u / v)) otherwise.\n * @param Fp\n * @param Z\n * @returns\n */\nexport function SWUFpSqrtRatio(\n Fp: IField,\n Z: T\n): (u: T, v: T) => { isValid: boolean; value: T } {\n // Generic implementation\n const q = Fp.ORDER;\n let l = _0n;\n for (let o = q - _1n; o % _2n === _0n; o /= _2n) l += _1n;\n const c1 = l; // 1. c1, the largest integer such that 2^c1 divides q - 1.\n // We need 2n ** c1 and 2n ** (c1-1). We can't use **; but we can use <<.\n // 2n ** c1 == 2n << (c1-1)\n const _2n_pow_c1_1 = _2n << (c1 - _1n - _1n);\n const _2n_pow_c1 = _2n_pow_c1_1 * _2n;\n const c2 = (q - _1n) / _2n_pow_c1; // 2. c2 = (q - 1) / (2^c1) # Integer arithmetic\n const c3 = (c2 - _1n) / _2n; // 3. c3 = (c2 - 1) / 2 # Integer arithmetic\n const c4 = _2n_pow_c1 - _1n; // 4. c4 = 2^c1 - 1 # Integer arithmetic\n const c5 = _2n_pow_c1_1; // 5. c5 = 2^(c1 - 1) # Integer arithmetic\n const c6 = Fp.pow(Z, c2); // 6. c6 = Z^c2\n const c7 = Fp.pow(Z, (c2 + _1n) / _2n); // 7. c7 = Z^((c2 + 1) / 2)\n let sqrtRatio = (u: T, v: T): { isValid: boolean; value: T } => {\n let tv1 = c6; // 1. tv1 = c6\n let tv2 = Fp.pow(v, c4); // 2. tv2 = v^c4\n let tv3 = Fp.sqr(tv2); // 3. tv3 = tv2^2\n tv3 = Fp.mul(tv3, v); // 4. tv3 = tv3 * v\n let tv5 = Fp.mul(u, tv3); // 5. tv5 = u * tv3\n tv5 = Fp.pow(tv5, c3); // 6. tv5 = tv5^c3\n tv5 = Fp.mul(tv5, tv2); // 7. tv5 = tv5 * tv2\n tv2 = Fp.mul(tv5, v); // 8. tv2 = tv5 * v\n tv3 = Fp.mul(tv5, u); // 9. tv3 = tv5 * u\n let tv4 = Fp.mul(tv3, tv2); // 10. tv4 = tv3 * tv2\n tv5 = Fp.pow(tv4, c5); // 11. tv5 = tv4^c5\n let isQR = Fp.eql(tv5, Fp.ONE); // 12. isQR = tv5 == 1\n tv2 = Fp.mul(tv3, c7); // 13. tv2 = tv3 * c7\n tv5 = Fp.mul(tv4, tv1); // 14. tv5 = tv4 * tv1\n tv3 = Fp.cmov(tv2, tv3, isQR); // 15. tv3 = CMOV(tv2, tv3, isQR)\n tv4 = Fp.cmov(tv5, tv4, isQR); // 16. tv4 = CMOV(tv5, tv4, isQR)\n // 17. for i in (c1, c1 - 1, ..., 2):\n for (let i = c1; i > _1n; i--) {\n let tv5 = i - _2n; // 18. tv5 = i - 2\n tv5 = _2n << (tv5 - _1n); // 19. tv5 = 2^tv5\n let tvv5 = Fp.pow(tv4, tv5); // 20. tv5 = tv4^tv5\n const e1 = Fp.eql(tvv5, Fp.ONE); // 21. e1 = tv5 == 1\n tv2 = Fp.mul(tv3, tv1); // 22. tv2 = tv3 * tv1\n tv1 = Fp.mul(tv1, tv1); // 23. tv1 = tv1 * tv1\n tvv5 = Fp.mul(tv4, tv1); // 24. tv5 = tv4 * tv1\n tv3 = Fp.cmov(tv2, tv3, e1); // 25. tv3 = CMOV(tv2, tv3, e1)\n tv4 = Fp.cmov(tvv5, tv4, e1); // 26. tv4 = CMOV(tv5, tv4, e1)\n }\n return { isValid: isQR, value: tv3 };\n };\n if (Fp.ORDER % _4n === _3n) {\n // sqrt_ratio_3mod4(u, v)\n const c1 = (Fp.ORDER - _3n) / _4n; // 1. c1 = (q - 3) / 4 # Integer arithmetic\n const c2 = Fp.sqrt(Fp.neg(Z)); // 2. c2 = sqrt(-Z)\n sqrtRatio = (u: T, v: T) => {\n let tv1 = Fp.sqr(v); // 1. tv1 = v^2\n const tv2 = Fp.mul(u, v); // 2. tv2 = u * v\n tv1 = Fp.mul(tv1, tv2); // 3. tv1 = tv1 * tv2\n let y1 = Fp.pow(tv1, c1); // 4. y1 = tv1^c1\n y1 = Fp.mul(y1, tv2); // 5. y1 = y1 * tv2\n const y2 = Fp.mul(y1, c2); // 6. y2 = y1 * c2\n const tv3 = Fp.mul(Fp.sqr(y1), v); // 7. tv3 = y1^2; 8. tv3 = tv3 * v\n const isQR = Fp.eql(tv3, u); // 9. isQR = tv3 == u\n let y = Fp.cmov(y2, y1, isQR); // 10. y = CMOV(y2, y1, isQR)\n return { isValid: isQR, value: y }; // 11. return (isQR, y) isQR ? y : y*c2\n };\n }\n // No curves uses that\n // if (Fp.ORDER % _8n === _5n) // sqrt_ratio_5mod8\n return sqrtRatio;\n}\n/**\n * Simplified Shallue-van de Woestijne-Ulas Method\n * https://www.rfc-editor.org/rfc/rfc9380#section-6.6.2\n */\nexport function mapToCurveSimpleSWU(\n Fp: IField,\n opts: {\n A: T;\n B: T;\n Z: T;\n }\n): (u: T) => { x: T; y: T } {\n validateField(Fp);\n if (!Fp.isValid(opts.A) || !Fp.isValid(opts.B) || !Fp.isValid(opts.Z))\n throw new Error('mapToCurveSimpleSWU: invalid opts');\n const sqrtRatio = SWUFpSqrtRatio(Fp, opts.Z);\n if (!Fp.isOdd) throw new Error('Fp.isOdd is not implemented!');\n // Input: u, an element of F.\n // Output: (x, y), a point on E.\n return (u: T): { x: T; y: T } => {\n // prettier-ignore\n let tv1, tv2, tv3, tv4, tv5, tv6, x, y;\n tv1 = Fp.sqr(u); // 1. tv1 = u^2\n tv1 = Fp.mul(tv1, opts.Z); // 2. tv1 = Z * tv1\n tv2 = Fp.sqr(tv1); // 3. tv2 = tv1^2\n tv2 = Fp.add(tv2, tv1); // 4. tv2 = tv2 + tv1\n tv3 = Fp.add(tv2, Fp.ONE); // 5. tv3 = tv2 + 1\n tv3 = Fp.mul(tv3, opts.B); // 6. tv3 = B * tv3\n tv4 = Fp.cmov(opts.Z, Fp.neg(tv2), !Fp.eql(tv2, Fp.ZERO)); // 7. tv4 = CMOV(Z, -tv2, tv2 != 0)\n tv4 = Fp.mul(tv4, opts.A); // 8. tv4 = A * tv4\n tv2 = Fp.sqr(tv3); // 9. tv2 = tv3^2\n tv6 = Fp.sqr(tv4); // 10. tv6 = tv4^2\n tv5 = Fp.mul(tv6, opts.A); // 11. tv5 = A * tv6\n tv2 = Fp.add(tv2, tv5); // 12. tv2 = tv2 + tv5\n tv2 = Fp.mul(tv2, tv3); // 13. tv2 = tv2 * tv3\n tv6 = Fp.mul(tv6, tv4); // 14. tv6 = tv6 * tv4\n tv5 = Fp.mul(tv6, opts.B); // 15. tv5 = B * tv6\n tv2 = Fp.add(tv2, tv5); // 16. tv2 = tv2 + tv5\n x = Fp.mul(tv1, tv3); // 17. x = tv1 * tv3\n const { isValid, value } = sqrtRatio(tv2, tv6); // 18. (is_gx1_square, y1) = sqrt_ratio(tv2, tv6)\n y = Fp.mul(tv1, u); // 19. y = tv1 * u -> Z * u^3 * y1\n y = Fp.mul(y, value); // 20. y = y * y1\n x = Fp.cmov(x, tv3, isValid); // 21. x = CMOV(x, tv3, is_gx1_square)\n y = Fp.cmov(y, value, isValid); // 22. y = CMOV(y, y1, is_gx1_square)\n const e1 = Fp.isOdd!(u) === Fp.isOdd!(y); // 23. e1 = sgn0(u) == sgn0(y)\n y = Fp.cmov(Fp.neg(y), y, e1); // 24. y = CMOV(-y, y, e1)\n x = Fp.div(x, tv4); // 25. x = x / tv4\n return { x, y };\n };\n}\n","/** Name of the feature. */\nexport const SolanaSignAndSendTransaction = 'solana:signAndSendTransaction';\n//# sourceMappingURL=signAndSendTransaction.js.map","import type { IdentifierString } from '@wallet-standard/base';\nimport type {\n SolanaSignTransactionInput,\n SolanaSignTransactionOptions,\n SolanaTransactionCommitment,\n SolanaTransactionVersion,\n} from './signTransaction.js';\n\n/** Name of the feature. */\nexport const SolanaSignAndSendTransaction = 'solana:signAndSendTransaction';\n\n/** TODO: docs */\nexport type SolanaSignAndSendTransactionFeature = {\n /** Name of the feature. */\n readonly [SolanaSignAndSendTransaction]: {\n /** Version of the feature API. */\n readonly version: SolanaSignAndSendTransactionVersion;\n\n /** TODO: docs */\n readonly supportedTransactionVersions: readonly SolanaTransactionVersion[];\n\n /**\n * Sign transactions using the account's secret key and send them to the chain.\n *\n * @param inputs Inputs for signing and sending transactions.\n *\n * @return Outputs of signing and sending transactions.\n */\n readonly signAndSendTransaction: SolanaSignAndSendTransactionMethod;\n };\n};\n\n/** Version of the feature. */\nexport type SolanaSignAndSendTransactionVersion = '1.0.0';\n\n/** TODO: docs */\nexport type SolanaSignAndSendTransactionMethod = (\n ...inputs: readonly SolanaSignAndSendTransactionInput[]\n) => Promise;\n\n/** Input for signing and sending a transaction. */\nexport interface SolanaSignAndSendTransactionInput extends SolanaSignTransactionInput {\n /** Chain to use. */\n readonly chain: IdentifierString;\n\n /** TODO: docs */\n readonly options?: SolanaSignAndSendTransactionOptions;\n}\n\n/** Output of signing and sending a transaction. */\nexport interface SolanaSignAndSendTransactionOutput {\n /** Transaction signature, as raw bytes. */\n readonly signature: Uint8Array;\n}\n\n/** Options for signing and sending a transaction. */\nexport type SolanaSignAndSendTransactionOptions = SolanaSignTransactionOptions & {\n /** Desired commitment level. If provided, confirm the transaction after sending. */\n readonly commitment?: SolanaTransactionCommitment;\n\n /** Disable transaction verification at the RPC. */\n readonly skipPreflight?: boolean;\n\n /** Maximum number of times for the RPC node to retry sending the transaction to the leader. */\n readonly maxRetries?: number;\n};\n","/** Name of the feature. */\nexport const SolanaSignMessage = 'solana:signMessage';\n//# sourceMappingURL=signMessage.js.map","import type { WalletAccount } from '@wallet-standard/base';\n\n/** Name of the feature. */\nexport const SolanaSignMessage = 'solana:signMessage';\n\n/** TODO: docs */\nexport type SolanaSignMessageFeature = {\n /** Name of the feature. */\n readonly [SolanaSignMessage]: {\n /** Version of the feature API. */\n readonly version: SolanaSignMessageVersion;\n\n /** Sign messages (arbitrary bytes) using the account's secret key. */\n readonly signMessage: SolanaSignMessageMethod;\n };\n};\n\n/** Version of the feature. */\nexport type SolanaSignMessageVersion = '1.1.0' | '1.0.0';\n\n/** TODO: docs */\nexport type SolanaSignMessageMethod = (\n ...inputs: readonly SolanaSignMessageInput[]\n) => Promise;\n\n/** Input for signing a message. */\nexport interface SolanaSignMessageInput {\n /** Account to use. */\n readonly account: WalletAccount;\n\n /** Message to sign, as raw bytes. */\n readonly message: Uint8Array;\n}\n\n/** Output of signing a message. */\nexport interface SolanaSignMessageOutput {\n /**\n * Message bytes that were signed.\n * The wallet may prefix or otherwise modify the message before signing it.\n */\n readonly signedMessage: Uint8Array;\n\n /**\n * Message signature produced.\n * If the signature type is provided, the signature must be Ed25519.\n */\n readonly signature: Uint8Array;\n\n /**\n * Optional type of the message signature produced.\n * If not provided, the signature must be Ed25519.\n */\n readonly signatureType?: 'ed25519';\n}\n","/** Name of the feature. */\nexport const SolanaSignTransaction = 'solana:signTransaction';\n//# sourceMappingURL=signTransaction.js.map","import type { IdentifierString, WalletAccount } from '@wallet-standard/base';\n\n/** Name of the feature. */\nexport const SolanaSignTransaction = 'solana:signTransaction';\n\n/** TODO: docs */\nexport type SolanaSignTransactionFeature = {\n /** Name of the feature. */\n readonly [SolanaSignTransaction]: {\n /** Version of the feature API. */\n readonly version: SolanaSignTransactionVersion;\n\n /** TODO: docs */\n readonly supportedTransactionVersions: readonly SolanaTransactionVersion[];\n\n /**\n * Sign transactions using the account's secret key.\n *\n * @param inputs Inputs for signing transactions.\n *\n * @return Outputs of signing transactions.\n */\n readonly signTransaction: SolanaSignTransactionMethod;\n };\n};\n\n/** Version of the feature. */\nexport type SolanaSignTransactionVersion = '1.0.0';\n\n/** TODO: docs */\nexport type SolanaTransactionVersion = 'legacy' | 0;\n\n/** TODO: docs */\nexport type SolanaSignTransactionMethod = (\n ...inputs: readonly SolanaSignTransactionInput[]\n) => Promise;\n\n/** Input for signing a transaction. */\nexport interface SolanaSignTransactionInput {\n /** Account to use. */\n readonly account: WalletAccount;\n\n /** Serialized transaction, as raw bytes. */\n readonly transaction: Uint8Array;\n\n /** Chain to use. */\n readonly chain?: IdentifierString;\n\n /** TODO: docs */\n readonly options?: SolanaSignTransactionOptions;\n}\n\n/** Output of signing a transaction. */\nexport interface SolanaSignTransactionOutput {\n /**\n * Signed, serialized transaction, as raw bytes.\n * Returning a transaction rather than signatures allows multisig wallets, program wallets, and other wallets that\n * use meta-transactions to return a modified, signed transaction.\n */\n readonly signedTransaction: Uint8Array;\n}\n\n/** Options for signing a transaction. */\nexport type SolanaSignTransactionOptions = {\n /** Preflight commitment level. */\n readonly preflightCommitment?: SolanaTransactionCommitment;\n\n /** The minimum slot that the request can be evaluated at. */\n readonly minContextSlot?: number;\n};\n\n/** Commitment level for transactions. */\nexport type SolanaTransactionCommitment = 'processed' | 'confirmed' | 'finalized';\n","let load = require('./helpers/browser/esm-js-loader');\nmodule.exports = (load(\"lHJg1\")).then(() => parcelRequire('3lp4m'));","\"use strict\";\n\nfunction load(id) {\n // eslint-disable-next-line no-undef\n return __parcel__import__(require('../bundle-manifest').resolve(id));\n}\nmodule.exports = load;","let load = require('./helpers/browser/esm-js-loader');\nmodule.exports = (load(\"2Wmvo\")).then(() => parcelRequire('8VMga'));","require('./helpers/bundle-manifest').register(new __parcel__URL__(\"\").toString(),JSON.parse(\"[\\\"lWpsB\\\",\\\"index.5c102541.js\\\",\\\"lHJg1\\\",\\\"esm.f2712bf6.js\\\",\\\"2Wmvo\\\",\\\"esm.9a35aeda.js\\\"]\"));","import {\n SolflareWalletName,\n SolflareWalletAdapter,\n SolflareWalletAdapterConfig,\n PhantomWalletName,\n PhantomWalletAdapter,\n PhantomWalletAdapterConfig,\n BackpackWalletName,\n BackpackWalletAdapter,\n} from \"@solana/wallet-adapter-wallets\";\nimport {\n WalletAdapter,\n WalletAdapterNetwork,\n WalletNotConnectedError,\n WalletNotReadyError,\n WalletReadyState,\n} from \"@solana/wallet-adapter-base\";\nimport type {\n Adapter,\n MessageSignerWalletAdapter,\n MessageSignerWalletAdapterProps,\n SendTransactionOptions,\n SignerWalletAdapter,\n SignerWalletAdapterProps,\n WalletError,\n WalletName,\n} from \"@solana/wallet-adapter-base\";\nimport { Transaction } from \"@solana/web3.js\";\nimport type {\n Connection,\n PublicKey,\n TransactionSignature,\n VersionedTransaction,\n} from \"@solana/web3.js\";\n\ndeclare global {\n interface Window {\n walletsAlert: any;\n walletsLoad: any;\n walletsDetected: any;\n walletsConnect: any;\n walletsDisconnect: any;\n walletsSign: any;\n walletConnected: any;\n walletConnectedPubKey: string;\n walletConnectEventElement: any;\n walletConnectEventElementName: string;\n }\n}\n\nlet walletConnectConnectedWallet: WalletAdapter | undefined;\n\nlet walletConnectWallets: WalletAdapter[] = [];\n\nfunction onReadyStateChange(this: Adapter, readyState: WalletReadyState) {\n console.log(\"onReadyStateChange\", readyState);\n if (!this) {\n console.log(\"no adapter\");\n return;\n }\n\n console.log(\"adapter\", this);\n console.log(\"readyState\", readyState);\n establishEmitter();\n if (window.walletConnectEventElement) {\n window.walletConnectEventElement.dispatchEvent(\n new CustomEvent(\"walletReadyStateChange\", {\n detail: { name: this.name, ready_state: readyState.toString() },\n }),\n );\n }\n}\n\nfunction onConnect(this: Adapter) {\n if (!this) {\n console.log(\"no adapter\");\n return;\n }\n\n console.log(\"adapter\", this);\n console.log(\"connected\", this.connected);\n console.log(\"publicKey\", this.publicKey?.toString());\n if (this.connected) {\n walletConnectConnectedWallet = this;\n window.walletConnectedPubKey = this.publicKey?.toString() || \"\";\n }\n\n establishEmitter();\n if (window.walletConnectEventElement) {\n window.walletConnectEventElement.dispatchEvent(\n new CustomEvent(\"walletConnect\", {\n detail: { public_key: this.publicKey?.toString() },\n }),\n );\n }\n}\n\nfunction onAccountChanged(this: Adapter, newPublicKey: PublicKey | null) {\n console.log(\"adapter\", this);\n console.log(\"publicKey\", newPublicKey?.toString());\n if (newPublicKey) {\n window.walletConnectedPubKey = newPublicKey?.toString() || \"\";\n }\n\n establishEmitter();\n if (window.walletConnectEventElement) {\n window.walletConnectEventElement.dispatchEvent(\n new CustomEvent(\"walletAccountChange\", {\n detail: { public_key: newPublicKey?.toString() },\n }),\n );\n }\n}\n\nfunction onDisconnect(this: Adapter) {\n console.log(\"adapter\", this);\n console.log(\"disconnected\");\n walletConnectConnectedWallet = undefined;\n window.walletConnectedPubKey = \"\";\n\n establishEmitter();\n if (window.walletConnectEventElement) {\n window.walletConnectEventElement.dispatchEvent(\n new CustomEvent(\"walletDisconnected\", {\n detail: { public_key: \"\" },\n }),\n );\n }\n}\n\nfunction onError(error: WalletError) {\n console.error(error);\n establishEmitter();\n if (window.walletConnectEventElement) {\n window.walletConnectEventElement.dispatchEvent(\n new CustomEvent(\"walletError\", {\n detail: { error: error.toString() },\n }),\n );\n }\n}\n\nwindow.walletConnected = () => window.walletConnectedPubKey || \"\";\n\nwindow.walletsAlert = (message: string) => {\n window.alert(message);\n};\n\nwindow.walletsDetected = (): { name: string; icon: string }[] => {\n let walletsDetected = walletConnectWallets\n .filter((adapter) => adapter.readyState == WalletReadyState.Installed)\n .map((adapter) => {\n return { name: adapter.name, icon: adapter.icon };\n });\n\n return walletsDetected;\n};\n\nwindow.walletsConnect = async (\n walletName: WalletName,\n): Promise => {\n const adapter = walletConnectWallets.find(\n (adapter) => adapter.name === walletName,\n );\n if (!adapter) {\n throw new Error(`Wallet not found: ${walletName}`);\n }\n\n console.log(`adapter ${adapter.name} in state ${adapter.readyState}`);\n if (adapter.readyState == WalletReadyState.Installed) {\n console.log(`adapter ${adapter.name} is installed. connecting...`);\n await adapter.connect();\n return adapter.publicKey.toString();\n } else {\n console.log(`adapter ${adapter.name} is not installed.`);\n }\n\n return;\n};\n\nwindow.walletsDisconnect = async (): Promise => {\n if (walletConnectConnectedWallet) {\n console.log(\"disconnecting wallet\");\n await walletConnectConnectedWallet.disconnect();\n }\n};\n\nlet establishEmitter = () => {\n if (\n window.walletConnectEventElementName &&\n document.getElementById(window.walletConnectEventElementName)\n ) {\n window.walletConnectEventElement = document.getElementById(\n window.walletConnectEventElementName,\n );\n return window.walletConnectEventElement;\n }\n};\n\nwindow.walletsLoad = (eventElement: string): string[] => {\n // WalletConnect code\n window.walletConnectEventElement = document.getElementById(eventElement);\n window.walletConnectEventElementName = eventElement;\n\n console.log(`${SolflareWalletName} wallet adapter`);\n console.log(`${PhantomWalletName} wallet adapter`);\n console.log(`${BackpackWalletName} wallet adapter`);\n\n const network = WalletAdapterNetwork.Mainnet;\n // const network = WalletAdapterNetwork.Devnet;\n walletConnectWallets = [\n new SolflareWalletAdapter({ network }),\n new BackpackWalletAdapter({ network }),\n new PhantomWalletAdapter({ network }),\n ];\n\n walletConnectWallets.forEach((adapter) => {\n adapter.on(\"readyStateChange\", onReadyStateChange, adapter);\n adapter.on(\"connect\", onConnect, adapter);\n adapter.on(\"disconnect\", onDisconnect, adapter);\n adapter.on(\"accountChanged\", onAccountChanged, adapter);\n adapter.on(\"error\", onError);\n });\n\n return walletConnectWallets.map((adapter) => adapter.name);\n // adapter.on('disconnect', onDisconnect);\n};\n\nwindow.walletsSign = async (encodedTx: string): Promise => {\n console.log(`encodedTx to sign: ${encodedTx}`);\n if (walletConnectConnectedWallet) {\n const tx = Transaction.from(Buffer.from(encodedTx, \"base64\"));\n\n if (\"signTransaction\" in walletConnectConnectedWallet) {\n const signedTx = await (\n walletConnectConnectedWallet as SignerWalletAdapter\n ).signTransaction(tx);\n const serialized = signedTx.serialize().toString(\"base64\");\n console.log(`signature: ${serialized}`);\n return serialized;\n }\n\n throw new Error(\n `Wallet ${walletConnectConnectedWallet.name} does not support signing transactions`,\n );\n }\n};\n","import { BaseMessageSignerWalletAdapter, scopePollingDetectionStrategy, WalletAccountError, WalletConnectionError, WalletDisconnectedError, WalletDisconnectionError, WalletNotConnectedError, WalletNotReadyError, WalletPublicKeyError, WalletReadyState, WalletSendTransactionError, WalletSignMessageError, WalletSignTransactionError, } from '@solana/wallet-adapter-base';\nimport { PublicKey } from '@solana/web3.js';\nexport const BackpackWalletName = 'Backpack';\nexport class BackpackWalletAdapter extends BaseMessageSignerWalletAdapter {\n constructor(config = {}) {\n super();\n this.name = BackpackWalletName;\n this.url = 'https://backpack.app';\n this.icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAbvSURBVHgB7Z1dUtxGEMf/LZH3fU0V4PUJQg4QVj5BnBOAT2BzAsMJAic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KhggUVYAEEP8fO+UiMgziDCvCwrnU3aw0nOATMQu8LVIIPAq+JdAerdwWBaQ/fjEBwAaQVmMnN7sEJCB3EqP3tlRGJy6qqmPkFMcZw7sucmfZiHQ6hRBNgSXdaCHbA7KeFfBvz9pxlxtl1gcN2XBWRfwHK959XFRG6AgAAAABJRU5ErkJggg==';\n this.supportedTransactionVersions = null;\n this._readyState = typeof window === 'undefined' || typeof document === 'undefined'\n ? WalletReadyState.Unsupported\n : WalletReadyState.NotDetected;\n this._disconnected = () => {\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n this._wallet = null;\n this._publicKey = null;\n this.emit('error', new WalletDisconnectedError());\n this.emit('disconnect');\n }\n };\n this._connecting = false;\n this._wallet = null;\n this._publicKey = null;\n if (this._readyState !== WalletReadyState.Unsupported) {\n scopePollingDetectionStrategy(() => {\n if (window.backpack?.isBackpack) {\n this._readyState = WalletReadyState.Installed;\n this.emit('readyStateChange', this._readyState);\n return true;\n }\n return false;\n });\n }\n }\n get publicKey() {\n return this._publicKey;\n }\n get connecting() {\n return this._connecting;\n }\n get connected() {\n return !!this._wallet?.isConnected;\n }\n get readyState() {\n return this._readyState;\n }\n async connect() {\n try {\n if (this.connected || this.connecting)\n return;\n if (this._readyState !== WalletReadyState.Installed)\n throw new WalletNotReadyError();\n this._connecting = true;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const wallet = window.backpack;\n try {\n await wallet.connect();\n }\n catch (error) {\n throw new WalletConnectionError(error?.message, error);\n }\n if (!wallet.publicKey)\n throw new WalletAccountError();\n let publicKey;\n try {\n publicKey = new PublicKey(wallet.publicKey.toBytes());\n }\n catch (error) {\n throw new WalletPublicKeyError(error?.message, error);\n }\n wallet.on('disconnect', this._disconnected);\n this._wallet = wallet;\n this._publicKey = publicKey;\n this.emit('connect', publicKey);\n }\n catch (error) {\n this.emit('error', error);\n throw error;\n }\n finally {\n this._connecting = false;\n }\n }\n async disconnect() {\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n this._wallet = null;\n this._publicKey = null;\n try {\n await wallet.disconnect();\n }\n catch (error) {\n this.emit('error', new WalletDisconnectionError(error?.message, error));\n }\n }\n this.emit('disconnect');\n }\n async sendTransaction(transaction, connection, options = {}) {\n try {\n const wallet = this._wallet;\n if (!wallet)\n throw new WalletNotConnectedError();\n const { signers, ...sendOptions } = options;\n try {\n return await wallet.send(transaction, signers, sendOptions, connection, this.publicKey);\n }\n catch (error) {\n throw new WalletSendTransactionError(error?.message, error);\n }\n }\n catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signTransaction(transaction) {\n try {\n const wallet = this._wallet;\n if (!wallet)\n throw new WalletNotConnectedError();\n try {\n return (await wallet.signTransaction(transaction, this.publicKey));\n }\n catch (error) {\n throw new WalletSignTransactionError(error?.message, error);\n }\n }\n catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signAllTransactions(transactions) {\n try {\n const wallet = this._wallet;\n if (!wallet)\n throw new WalletNotConnectedError();\n try {\n return (await wallet.signAllTransactions(transactions, this.publicKey));\n }\n catch (error) {\n throw new WalletSignTransactionError(error?.message, error);\n }\n }\n catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signMessage(message) {\n try {\n const wallet = this._wallet;\n if (!wallet)\n throw new WalletNotConnectedError();\n try {\n return await wallet.signMessage(message, this.publicKey);\n }\n catch (error) {\n throw new WalletSignMessageError(error?.message, error);\n }\n }\n catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n}\n//# sourceMappingURL=adapter.js.map","import type { EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base';\nimport {\n BaseMessageSignerWalletAdapter,\n scopePollingDetectionStrategy,\n WalletAccountError,\n WalletConnectionError,\n WalletDisconnectedError,\n WalletDisconnectionError,\n WalletNotConnectedError,\n WalletNotReadyError,\n WalletPublicKeyError,\n WalletReadyState,\n WalletSendTransactionError,\n WalletSignMessageError,\n WalletSignTransactionError,\n} from '@solana/wallet-adapter-base';\nimport type { Connection, SendOptions, Signer, Transaction, TransactionSignature } from '@solana/web3.js';\nimport { PublicKey } from '@solana/web3.js';\n\ninterface BackpackWalletEvents {\n connect(...args: unknown[]): unknown;\n disconnect(...args: unknown[]): unknown;\n}\n\ninterface BackpackWallet extends EventEmitter {\n isBackpack?: boolean;\n publicKey?: { toBytes(): Uint8Array };\n isConnected: boolean;\n signTransaction(transaction: Transaction, publicKey?: PublicKey | null): Promise;\n signAllTransactions(transactions: Transaction[], publicKey?: PublicKey | null): Promise;\n send(\n transaction: Transaction,\n signers?: Signer[],\n options?: SendOptions,\n connection?: Connection,\n publicKey?: PublicKey | null\n ): Promise;\n signMessage(message: Uint8Array, publicKey?: PublicKey | null): Promise;\n connect(): Promise;\n disconnect(): Promise;\n}\n\ninterface BackpackWindow extends Window {\n backpack?: BackpackWallet;\n}\n\ndeclare const window: BackpackWindow;\n\nexport interface BackpackWalletAdapterConfig {}\n\nexport const BackpackWalletName = 'Backpack' as WalletName<'Backpack'>;\n\nexport class BackpackWalletAdapter extends BaseMessageSignerWalletAdapter {\n name = BackpackWalletName;\n url = 'https://backpack.app';\n icon =\n 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAbvSURBVHgB7Z1dUtxGEMf/LZH3fU0V4PUJQg4QVj5BnBOAT2BzAsMJAicwPoHJCRDrAxifgLVxVV73ObDqdEtsjKn4C8+0NDv9e7AxprRC85uvnp4RYYW5qKpxCVTcYKsgfiDfGjMwIsZIvh7d/lkmzAiYy5fzhultyZhdlagf1vU5VhjCiiGFXq01zYSJdqWgx/hB5AHN5I/6iuilyFBjxVgZAdqCZ34ORoVIqAzSOhxsvq6PsSIkL4A281LwL2IW/F1UhLKgRz/X9QyJUyBhuuae31gWviLjiPF1wxeX29vPkTjJtgAftrd3GHSMnmHw4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foFhsjnRduD+DnWIkkXXACJl1cwRoMmf3cbRaOjLRzDXnKZVj9GBIILUJBtbVzyj9HAU19AgR6I9VzDtwCgMXpAo2Yxp0v/Ybi49ennJtIFEPMY/TCKHTvv+aTSUQzBgwrQ92YHbQVi3UN3GAVZhrf/jzECE1SAq/7n4yOJ074KPSBcJoii598vxgwrqAByg70HZJZbr0JJ0G5XZz5Z1e1rYccA5TAicqEk0O5ECl/3LvYys7mLTLHHCEzS7wz6Esv3+nyYTF58rwha63XAl8PG1aCnhesWq6EdOcKM3WvmXRHh+Gvv/tNVTJlJPC4a3RVEK72+sCSZ4+J/FBVhTUS43J7gJqFjrnl33A3sxtCa3nAWhX6bbAT4hJugCsNZ2TGA8224AJnjAmSOC5A5LkDmuACZ4wJkjguQOS5A5rgAmeMCZI4LkDkuQOa4AJnjAmSOC5A5LkDmuACZ4wJkjguQOWEFYJvz85xwBBWgKM1P68oKKsI/36ACdC9nsDlWPTsIJ5t1Hfw01OBjgI1p/YwLegIibw0CwESz9gUYZ2d/wHEcx3Ecx3Ecx3Ecx3HuS5QjfdrXxTHv3JzEkd2xKwHR9xPNuKGjzdf1MSIQXAA9XUsuuw8nKPpK3PWzs+AvrgwqgP1LojOjoEf3fRv6Zy+JgBSLOGfaOx1NE/6o+rCrgeT9fWp4SljmuACZ4wJkjguQOS5A5rgAmeMCZI4LkDkuQOa4AJnjAmSOC5A5LkDmuACZ4wJkjguQOS5A5rgAmeMCZI4LkDkuQOa4AJnj5wRmTlABqHQBohKhggUVYAEEP8fO+UiMgziDCvCwrnU3aw0nOATMQu8LVIIPAq+JdAerdwWBaQ/fjEBwAaQVmMnN7sEJCB3EqP3tlRGJy6qqmPkFMcZw7sucmfZiHQ6hRBNgSXdaCHbA7KeFfBvz9pxlxtl1gcN2XBWRfwHK959XFRG6AgAAAABJRU5ErkJggg==';\n readonly supportedTransactionVersions = null;\n\n private _connecting: boolean;\n private _wallet: BackpackWallet | null;\n private _publicKey: PublicKey | null;\n private _readyState: WalletReadyState =\n typeof window === 'undefined' || typeof document === 'undefined'\n ? WalletReadyState.Unsupported\n : WalletReadyState.NotDetected;\n\n constructor(config: BackpackWalletAdapterConfig = {}) {\n super();\n this._connecting = false;\n this._wallet = null;\n this._publicKey = null;\n\n if (this._readyState !== WalletReadyState.Unsupported) {\n scopePollingDetectionStrategy(() => {\n if (window.backpack?.isBackpack) {\n this._readyState = WalletReadyState.Installed;\n this.emit('readyStateChange', this._readyState);\n return true;\n }\n return false;\n });\n }\n }\n\n get publicKey() {\n return this._publicKey;\n }\n\n get connecting() {\n return this._connecting;\n }\n\n get connected() {\n return !!this._wallet?.isConnected;\n }\n\n get readyState() {\n return this._readyState;\n }\n\n async connect(): Promise {\n try {\n if (this.connected || this.connecting) return;\n if (this._readyState !== WalletReadyState.Installed) throw new WalletNotReadyError();\n\n this._connecting = true;\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const wallet = window.backpack!;\n\n try {\n await wallet.connect();\n } catch (error: any) {\n throw new WalletConnectionError(error?.message, error);\n }\n\n if (!wallet.publicKey) throw new WalletAccountError();\n\n let publicKey: PublicKey;\n try {\n publicKey = new PublicKey(wallet.publicKey.toBytes());\n } catch (error: any) {\n throw new WalletPublicKeyError(error?.message, error);\n }\n\n wallet.on('disconnect', this._disconnected);\n\n this._wallet = wallet;\n this._publicKey = publicKey;\n\n this.emit('connect', publicKey);\n } catch (error: any) {\n this.emit('error', error);\n throw error;\n } finally {\n this._connecting = false;\n }\n }\n\n async disconnect(): Promise {\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n\n this._wallet = null;\n this._publicKey = null;\n\n try {\n await wallet.disconnect();\n } catch (error: any) {\n this.emit('error', new WalletDisconnectionError(error?.message, error));\n }\n }\n\n this.emit('disconnect');\n }\n\n async sendTransaction(\n transaction: Transaction,\n connection: Connection,\n options: SendTransactionOptions = {}\n ): Promise {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new WalletNotConnectedError();\n\n const { signers, ...sendOptions } = options;\n\n try {\n return await wallet.send(transaction, signers, sendOptions, connection, this.publicKey);\n } catch (error: any) {\n throw new WalletSendTransactionError(error?.message, error);\n }\n } catch (error: any) {\n this.emit('error', error);\n throw error;\n }\n }\n\n async signTransaction(transaction: T): Promise {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new WalletNotConnectedError();\n\n try {\n return (await wallet.signTransaction(transaction, this.publicKey)) as T;\n } catch (error: any) {\n throw new WalletSignTransactionError(error?.message, error);\n }\n } catch (error: any) {\n this.emit('error', error);\n throw error;\n }\n }\n\n async signAllTransactions(transactions: T[]): Promise {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new WalletNotConnectedError();\n\n try {\n return (await wallet.signAllTransactions(transactions, this.publicKey)) as T[];\n } catch (error: any) {\n throw new WalletSignTransactionError(error?.message, error);\n }\n } catch (error: any) {\n this.emit('error', error);\n throw error;\n }\n }\n\n async signMessage(message: Uint8Array): Promise {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new WalletNotConnectedError();\n\n try {\n return await wallet.signMessage(message, this.publicKey);\n } catch (error: any) {\n throw new WalletSignMessageError(error?.message, error);\n }\n } catch (error: any) {\n this.emit('error', error);\n throw error;\n }\n }\n\n private _disconnected = () => {\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n\n this._wallet = null;\n this._publicKey = null;\n\n this.emit('error', new WalletDisconnectedError());\n this.emit('disconnect');\n }\n };\n}\n","import { BaseWalletAdapter, } from './adapter.js';\nimport { WalletSendTransactionError, WalletSignTransactionError } from './errors.js';\nimport { isVersionedTransaction } from './transaction.js';\nexport class BaseSignerWalletAdapter extends BaseWalletAdapter {\n async sendTransaction(transaction, connection, options = {}) {\n let emit = true;\n try {\n if (isVersionedTransaction(transaction)) {\n if (!this.supportedTransactionVersions)\n throw new WalletSendTransactionError(`Sending versioned transactions isn't supported by this wallet`);\n if (!this.supportedTransactionVersions.has(transaction.version))\n throw new WalletSendTransactionError(`Sending transaction version ${transaction.version} isn't supported by this wallet`);\n try {\n transaction = await this.signTransaction(transaction);\n const rawTransaction = transaction.serialize();\n return await connection.sendRawTransaction(rawTransaction, options);\n }\n catch (error) {\n // If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event\n if (error instanceof WalletSignTransactionError) {\n emit = false;\n throw error;\n }\n throw new WalletSendTransactionError(error?.message, error);\n }\n }\n else {\n try {\n const { signers, ...sendOptions } = options;\n transaction = await this.prepareTransaction(transaction, connection, sendOptions);\n signers?.length && transaction.partialSign(...signers);\n transaction = await this.signTransaction(transaction);\n const rawTransaction = transaction.serialize();\n return await connection.sendRawTransaction(rawTransaction, sendOptions);\n }\n catch (error) {\n // If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event\n if (error instanceof WalletSignTransactionError) {\n emit = false;\n throw error;\n }\n throw new WalletSendTransactionError(error?.message, error);\n }\n }\n }\n catch (error) {\n if (emit) {\n this.emit('error', error);\n }\n throw error;\n }\n }\n async signAllTransactions(transactions) {\n for (const transaction of transactions) {\n if (isVersionedTransaction(transaction)) {\n if (!this.supportedTransactionVersions)\n throw new WalletSignTransactionError(`Signing versioned transactions isn't supported by this wallet`);\n if (!this.supportedTransactionVersions.has(transaction.version))\n throw new WalletSignTransactionError(`Signing transaction version ${transaction.version} isn't supported by this wallet`);\n }\n }\n const signedTransactions = [];\n for (const transaction of transactions) {\n signedTransactions.push(await this.signTransaction(transaction));\n }\n return signedTransactions;\n }\n}\nexport class BaseMessageSignerWalletAdapter extends BaseSignerWalletAdapter {\n}\nexport class BaseSignInMessageSignerWalletAdapter extends BaseMessageSignerWalletAdapter {\n}\n//# sourceMappingURL=signer.js.map","import type { SolanaSignInInput, SolanaSignInOutput } from '@solana/wallet-standard-features';\nimport type { Connection, TransactionSignature } from '@solana/web3.js';\nimport {\n BaseWalletAdapter,\n type SendTransactionOptions,\n type WalletAdapter,\n type WalletAdapterProps,\n} from './adapter.js';\nimport { WalletSendTransactionError, WalletSignTransactionError } from './errors.js';\nimport { isVersionedTransaction, type TransactionOrVersionedTransaction } from './transaction.js';\n\nexport interface SignerWalletAdapterProps extends WalletAdapterProps {\n signTransaction>(\n transaction: T\n ): Promise;\n signAllTransactions>(\n transactions: T[]\n ): Promise;\n}\n\nexport type SignerWalletAdapter = WalletAdapter & SignerWalletAdapterProps;\n\nexport abstract class BaseSignerWalletAdapter\n extends BaseWalletAdapter\n implements SignerWalletAdapter\n{\n async sendTransaction(\n transaction: TransactionOrVersionedTransaction,\n connection: Connection,\n options: SendTransactionOptions = {}\n ): Promise {\n let emit = true;\n try {\n if (isVersionedTransaction(transaction)) {\n if (!this.supportedTransactionVersions)\n throw new WalletSendTransactionError(\n `Sending versioned transactions isn't supported by this wallet`\n );\n\n if (!this.supportedTransactionVersions.has(transaction.version))\n throw new WalletSendTransactionError(\n `Sending transaction version ${transaction.version} isn't supported by this wallet`\n );\n\n try {\n transaction = await this.signTransaction(transaction);\n\n const rawTransaction = transaction.serialize();\n\n return await connection.sendRawTransaction(rawTransaction, options);\n } catch (error: any) {\n // If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event\n if (error instanceof WalletSignTransactionError) {\n emit = false;\n throw error;\n }\n throw new WalletSendTransactionError(error?.message, error);\n }\n } else {\n try {\n const { signers, ...sendOptions } = options;\n\n transaction = await this.prepareTransaction(transaction, connection, sendOptions);\n\n signers?.length && transaction.partialSign(...signers);\n\n transaction = await this.signTransaction(transaction);\n\n const rawTransaction = transaction.serialize();\n\n return await connection.sendRawTransaction(rawTransaction, sendOptions);\n } catch (error: any) {\n // If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event\n if (error instanceof WalletSignTransactionError) {\n emit = false;\n throw error;\n }\n throw new WalletSendTransactionError(error?.message, error);\n }\n }\n } catch (error: any) {\n if (emit) {\n this.emit('error', error);\n }\n throw error;\n }\n }\n\n abstract signTransaction>(\n transaction: T\n ): Promise;\n\n async signAllTransactions>(\n transactions: T[]\n ): Promise {\n for (const transaction of transactions) {\n if (isVersionedTransaction(transaction)) {\n if (!this.supportedTransactionVersions)\n throw new WalletSignTransactionError(\n `Signing versioned transactions isn't supported by this wallet`\n );\n\n if (!this.supportedTransactionVersions.has(transaction.version))\n throw new WalletSignTransactionError(\n `Signing transaction version ${transaction.version} isn't supported by this wallet`\n );\n }\n }\n\n const signedTransactions: T[] = [];\n for (const transaction of transactions) {\n signedTransactions.push(await this.signTransaction(transaction));\n }\n return signedTransactions;\n }\n}\n\nexport interface MessageSignerWalletAdapterProps extends WalletAdapterProps {\n signMessage(message: Uint8Array): Promise;\n}\n\nexport type MessageSignerWalletAdapter = WalletAdapter &\n MessageSignerWalletAdapterProps;\n\nexport abstract class BaseMessageSignerWalletAdapter\n extends BaseSignerWalletAdapter\n implements MessageSignerWalletAdapter\n{\n abstract signMessage(message: Uint8Array): Promise;\n}\n\nexport interface SignInMessageSignerWalletAdapterProps extends WalletAdapterProps {\n signIn(input?: SolanaSignInInput): Promise;\n}\n\nexport type SignInMessageSignerWalletAdapter = WalletAdapter &\n SignInMessageSignerWalletAdapterProps;\n\nexport abstract class BaseSignInMessageSignerWalletAdapter\n extends BaseMessageSignerWalletAdapter\n implements SignInMessageSignerWalletAdapter\n{\n abstract signIn(input?: SolanaSignInInput): Promise;\n}\n","import EventEmitter from 'eventemitter3';\nimport { WalletNotConnectedError } from './errors.js';\nexport { EventEmitter };\n/**\n * A wallet's readiness describes a series of states that the wallet can be in,\n * depending on what kind of wallet it is. An installable wallet (eg. a browser\n * extension like Phantom) might be `Installed` if we've found the Phantom API\n * in the global scope, or `NotDetected` otherwise. A loadable, zero-install\n * runtime (eg. Torus Wallet) might simply signal that it's `Loadable`. Use this\n * metadata to personalize the wallet list for each user (eg. to show their\n * installed wallets first).\n */\nexport var WalletReadyState;\n(function (WalletReadyState) {\n /**\n * User-installable wallets can typically be detected by scanning for an API\n * that they've injected into the global context. If such an API is present,\n * we consider the wallet to have been installed.\n */\n WalletReadyState[\"Installed\"] = \"Installed\";\n WalletReadyState[\"NotDetected\"] = \"NotDetected\";\n /**\n * Loadable wallets are always available to you. Since you can load them at\n * any time, it's meaningless to say that they have been detected.\n */\n WalletReadyState[\"Loadable\"] = \"Loadable\";\n /**\n * If a wallet is not supported on a given platform (eg. server-rendering, or\n * mobile) then it will stay in the `Unsupported` state.\n */\n WalletReadyState[\"Unsupported\"] = \"Unsupported\";\n})(WalletReadyState || (WalletReadyState = {}));\nexport class BaseWalletAdapter extends EventEmitter {\n get connected() {\n return !!this.publicKey;\n }\n async autoConnect() {\n await this.connect();\n }\n async prepareTransaction(transaction, connection, options = {}) {\n const publicKey = this.publicKey;\n if (!publicKey)\n throw new WalletNotConnectedError();\n transaction.feePayer = transaction.feePayer || publicKey;\n transaction.recentBlockhash =\n transaction.recentBlockhash ||\n (await connection.getLatestBlockhash({\n commitment: options.preflightCommitment,\n minContextSlot: options.minContextSlot,\n })).blockhash;\n return transaction;\n }\n}\nexport function scopePollingDetectionStrategy(detect) {\n // Early return when server-side rendering\n if (typeof window === 'undefined' || typeof document === 'undefined')\n return;\n const disposers = [];\n function detectAndDispose() {\n const detected = detect();\n if (detected) {\n for (const dispose of disposers) {\n dispose();\n }\n }\n }\n // Strategy #1: Try detecting every second.\n const interval = \n // TODO: #334 Replace with idle callback strategy.\n setInterval(detectAndDispose, 1000);\n disposers.push(() => clearInterval(interval));\n // Strategy #2: Detect as soon as the DOM becomes 'ready'/'interactive'.\n if (\n // Implies that `DOMContentLoaded` has not yet fired.\n document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', detectAndDispose, { once: true });\n disposers.push(() => document.removeEventListener('DOMContentLoaded', detectAndDispose));\n }\n // Strategy #3: Detect after the `window` has fully loaded.\n if (\n // If the `complete` state has been reached, we're too late.\n document.readyState !== 'complete') {\n window.addEventListener('load', detectAndDispose, { once: true });\n disposers.push(() => window.removeEventListener('load', detectAndDispose));\n }\n // Strategy #4: Detect synchronously, now.\n detectAndDispose();\n}\n/**\n * Users on iOS can be redirected into a wallet's in-app browser automatically,\n * if that wallet has a universal link configured to do so\n * But should not be redirected from within a webview, eg. if they're already\n * inside a wallet's browser\n * This function can be used to identify users who are on iOS and can be redirected\n *\n * @returns true if the user can be redirected\n */\nexport function isIosAndRedirectable() {\n // SSR: return false\n if (!navigator)\n return false;\n const userAgent = navigator.userAgent.toLowerCase();\n // if on iOS the user agent will contain either iPhone or iPad\n // caveat: if requesting desktop site then this won't work\n const isIos = userAgent.includes('iphone') || userAgent.includes('ipad');\n // if in a webview then it will not include Safari\n // note that other iOS browsers also include Safari\n // so we will redirect only if Safari is also included\n const isSafari = userAgent.includes('safari');\n return isIos && isSafari;\n}\n//# sourceMappingURL=adapter.js.map","import type { Connection, PublicKey, SendOptions, Signer, Transaction, TransactionSignature } from '@solana/web3.js';\nimport EventEmitter from 'eventemitter3';\nimport { type WalletError, WalletNotConnectedError } from './errors.js';\nimport type { SupportedTransactionVersions, TransactionOrVersionedTransaction } from './transaction.js';\n\nexport { EventEmitter };\n\nexport interface WalletAdapterEvents {\n connect(publicKey: PublicKey): void;\n disconnect(): void;\n error(error: WalletError): void;\n readyStateChange(readyState: WalletReadyState): void;\n}\n\nexport interface SendTransactionOptions extends SendOptions {\n signers?: Signer[];\n}\n\n// WalletName is a nominal type that wallet adapters should use, e.g. `'MyCryptoWallet' as WalletName<'MyCryptoWallet'>`\n// https://medium.com/@KevinBGreene/surviving-the-typescript-ecosystem-branding-and-type-tagging-6cf6e516523d\nexport type WalletName = T & { __brand__: 'WalletName' };\n\nexport interface WalletAdapterProps {\n name: WalletName;\n url: string;\n icon: string;\n readyState: WalletReadyState;\n publicKey: PublicKey | null;\n connecting: boolean;\n connected: boolean;\n supportedTransactionVersions?: SupportedTransactionVersions;\n\n autoConnect(): Promise;\n connect(): Promise;\n disconnect(): Promise;\n sendTransaction(\n transaction: TransactionOrVersionedTransaction,\n connection: Connection,\n options?: SendTransactionOptions\n ): Promise;\n}\n\nexport type WalletAdapter = WalletAdapterProps & EventEmitter;\n\n/**\n * A wallet's readiness describes a series of states that the wallet can be in,\n * depending on what kind of wallet it is. An installable wallet (eg. a browser\n * extension like Phantom) might be `Installed` if we've found the Phantom API\n * in the global scope, or `NotDetected` otherwise. A loadable, zero-install\n * runtime (eg. Torus Wallet) might simply signal that it's `Loadable`. Use this\n * metadata to personalize the wallet list for each user (eg. to show their\n * installed wallets first).\n */\nexport enum WalletReadyState {\n /**\n * User-installable wallets can typically be detected by scanning for an API\n * that they've injected into the global context. If such an API is present,\n * we consider the wallet to have been installed.\n */\n Installed = 'Installed',\n NotDetected = 'NotDetected',\n /**\n * Loadable wallets are always available to you. Since you can load them at\n * any time, it's meaningless to say that they have been detected.\n */\n Loadable = 'Loadable',\n /**\n * If a wallet is not supported on a given platform (eg. server-rendering, or\n * mobile) then it will stay in the `Unsupported` state.\n */\n Unsupported = 'Unsupported',\n}\n\nexport abstract class BaseWalletAdapter\n extends EventEmitter\n implements WalletAdapter\n{\n abstract name: WalletName;\n abstract url: string;\n abstract icon: string;\n abstract readyState: WalletReadyState;\n abstract publicKey: PublicKey | null;\n abstract connecting: boolean;\n abstract supportedTransactionVersions?: SupportedTransactionVersions;\n\n get connected() {\n return !!this.publicKey;\n }\n\n async autoConnect() {\n await this.connect();\n }\n\n abstract connect(): Promise;\n abstract disconnect(): Promise;\n\n abstract sendTransaction(\n transaction: TransactionOrVersionedTransaction,\n connection: Connection,\n options?: SendTransactionOptions\n ): Promise;\n\n protected async prepareTransaction(\n transaction: Transaction,\n connection: Connection,\n options: SendOptions = {}\n ): Promise {\n const publicKey = this.publicKey;\n if (!publicKey) throw new WalletNotConnectedError();\n\n transaction.feePayer = transaction.feePayer || publicKey;\n transaction.recentBlockhash =\n transaction.recentBlockhash ||\n (\n await connection.getLatestBlockhash({\n commitment: options.preflightCommitment,\n minContextSlot: options.minContextSlot,\n })\n ).blockhash;\n\n return transaction;\n }\n}\n\nexport function scopePollingDetectionStrategy(detect: () => boolean): void {\n // Early return when server-side rendering\n if (typeof window === 'undefined' || typeof document === 'undefined') return;\n\n const disposers: (() => void)[] = [];\n\n function detectAndDispose() {\n const detected = detect();\n if (detected) {\n for (const dispose of disposers) {\n dispose();\n }\n }\n }\n\n // Strategy #1: Try detecting every second.\n const interval =\n // TODO: #334 Replace with idle callback strategy.\n setInterval(detectAndDispose, 1000);\n disposers.push(() => clearInterval(interval));\n\n // Strategy #2: Detect as soon as the DOM becomes 'ready'/'interactive'.\n if (\n // Implies that `DOMContentLoaded` has not yet fired.\n document.readyState === 'loading'\n ) {\n document.addEventListener('DOMContentLoaded', detectAndDispose, { once: true });\n disposers.push(() => document.removeEventListener('DOMContentLoaded', detectAndDispose));\n }\n\n // Strategy #3: Detect after the `window` has fully loaded.\n if (\n // If the `complete` state has been reached, we're too late.\n document.readyState !== 'complete'\n ) {\n window.addEventListener('load', detectAndDispose, { once: true });\n disposers.push(() => window.removeEventListener('load', detectAndDispose));\n }\n\n // Strategy #4: Detect synchronously, now.\n detectAndDispose();\n}\n\n/**\n * Users on iOS can be redirected into a wallet's in-app browser automatically,\n * if that wallet has a universal link configured to do so\n * But should not be redirected from within a webview, eg. if they're already\n * inside a wallet's browser\n * This function can be used to identify users who are on iOS and can be redirected\n *\n * @returns true if the user can be redirected\n */\nexport function isIosAndRedirectable() {\n // SSR: return false\n if (!navigator) return false;\n\n const userAgent = navigator.userAgent.toLowerCase();\n\n // if on iOS the user agent will contain either iPhone or iPad\n // caveat: if requesting desktop site then this won't work\n const isIos = userAgent.includes('iphone') || userAgent.includes('ipad');\n\n // if in a webview then it will not include Safari\n // note that other iOS browsers also include Safari\n // so we will redirect only if Safari is also included\n const isSafari = userAgent.includes('safari');\n\n return isIos && isSafari;\n}\n","'use strict';\n\nvar has = Object.prototype.hasOwnProperty\n , prefix = '~';\n\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @private\n */\nfunction Events() {}\n\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n Events.prototype = Object.create(null);\n\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new Events().__proto__) prefix = false;\n}\n\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @private\n */\nfunction EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n\n/**\n * Add a listener for a given event.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} once Specify if the listener is a one-time listener.\n * @returns {EventEmitter}\n * @private\n */\nfunction addListener(emitter, event, fn, context, once) {\n if (typeof fn !== 'function') {\n throw new TypeError('The listener must be a function');\n }\n\n var listener = new EE(fn, context || emitter, once)\n , evt = prefix ? prefix + event : event;\n\n if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;\n else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);\n else emitter._events[evt] = [emitter._events[evt], listener];\n\n return emitter;\n}\n\n/**\n * Clear event by name.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} evt The Event name.\n * @private\n */\nfunction clearEvent(emitter, evt) {\n if (--emitter._eventsCount === 0) emitter._events = new Events();\n else delete emitter._events[evt];\n}\n\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @public\n */\nfunction EventEmitter() {\n this._events = new Events();\n this._eventsCount = 0;\n}\n\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @public\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n var names = []\n , events\n , name;\n\n if (this._eventsCount === 0) return names;\n\n for (name in (events = this._events)) {\n if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);\n }\n\n if (Object.getOwnPropertySymbols) {\n return names.concat(Object.getOwnPropertySymbols(events));\n }\n\n return names;\n};\n\n/**\n * Return the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Array} The registered listeners.\n * @public\n */\nEventEmitter.prototype.listeners = function listeners(event) {\n var evt = prefix ? prefix + event : event\n , handlers = this._events[evt];\n\n if (!handlers) return [];\n if (handlers.fn) return [handlers.fn];\n\n for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {\n ee[i] = handlers[i].fn;\n }\n\n return ee;\n};\n\n/**\n * Return the number of listeners listening to a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Number} The number of listeners.\n * @public\n */\nEventEmitter.prototype.listenerCount = function listenerCount(event) {\n var evt = prefix ? prefix + event : event\n , listeners = this._events[evt];\n\n if (!listeners) return 0;\n if (listeners.fn) return 1;\n return listeners.length;\n};\n\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return false;\n\n var listeners = this._events[evt]\n , len = arguments.length\n , args\n , i;\n\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n switch (len) {\n case 1: return listeners.fn.call(listeners.context), true;\n case 2: return listeners.fn.call(listeners.context, a1), true;\n case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n\n for (i = 1, args = new Array(len -1); i < len; i++) {\n args[i - 1] = arguments[i];\n }\n\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length\n , j;\n\n for (i = 0; i < length; i++) {\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n switch (len) {\n case 1: listeners[i].fn.call(listeners[i].context); break;\n case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;\n default:\n if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {\n args[j - 1] = arguments[j];\n }\n\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n\n return true;\n};\n\n/**\n * Add a listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n return addListener(this, event, fn, context, false);\n};\n\n/**\n * Add a one-time listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n return addListener(this, event, fn, context, true);\n};\n\n/**\n * Remove the listeners of a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {*} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return this;\n if (!fn) {\n clearEvent(this, evt);\n return this;\n }\n\n var listeners = this._events[evt];\n\n if (listeners.fn) {\n if (\n listeners.fn === fn &&\n (!once || listeners.once) &&\n (!context || listeners.context === context)\n ) {\n clearEvent(this, evt);\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (\n listeners[i].fn !== fn ||\n (once && !listeners[i].once) ||\n (context && listeners[i].context !== context)\n ) {\n events.push(listeners[i]);\n }\n }\n\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else clearEvent(this, evt);\n }\n\n return this;\n};\n\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {(String|Symbol)} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n\n if (event) {\n evt = prefix ? prefix + event : event;\n if (this._events[evt]) clearEvent(this, evt);\n } else {\n this._events = new Events();\n this._eventsCount = 0;\n }\n\n return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\nEventEmitter.EventEmitter = EventEmitter;\n\n//\n// Expose the module.\n//\nif ('undefined' !== typeof module) {\n module.exports = EventEmitter;\n}\n","export class WalletError extends Error {\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n constructor(message, error) {\n super(message);\n this.error = error;\n }\n}\nexport class WalletNotReadyError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletNotReadyError';\n }\n}\nexport class WalletLoadError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletLoadError';\n }\n}\nexport class WalletConfigError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletConfigError';\n }\n}\nexport class WalletConnectionError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletConnectionError';\n }\n}\nexport class WalletDisconnectedError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletDisconnectedError';\n }\n}\nexport class WalletDisconnectionError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletDisconnectionError';\n }\n}\nexport class WalletAccountError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletAccountError';\n }\n}\nexport class WalletPublicKeyError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletPublicKeyError';\n }\n}\nexport class WalletKeypairError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletKeypairError';\n }\n}\nexport class WalletNotConnectedError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletNotConnectedError';\n }\n}\nexport class WalletSendTransactionError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletSendTransactionError';\n }\n}\nexport class WalletSignTransactionError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletSignTransactionError';\n }\n}\nexport class WalletSignMessageError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletSignMessageError';\n }\n}\nexport class WalletSignInError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletSignInError';\n }\n}\nexport class WalletTimeoutError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletTimeoutError';\n }\n}\nexport class WalletWindowBlockedError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletWindowBlockedError';\n }\n}\nexport class WalletWindowClosedError extends WalletError {\n constructor() {\n super(...arguments);\n this.name = 'WalletWindowClosedError';\n }\n}\n//# sourceMappingURL=errors.js.map","export class WalletError extends Error {\n error: any;\n\n // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\n constructor(message?: string, error?: any) {\n super(message);\n this.error = error;\n }\n}\n\nexport class WalletNotReadyError extends WalletError {\n name = 'WalletNotReadyError';\n}\n\nexport class WalletLoadError extends WalletError {\n name = 'WalletLoadError';\n}\n\nexport class WalletConfigError extends WalletError {\n name = 'WalletConfigError';\n}\n\nexport class WalletConnectionError extends WalletError {\n name = 'WalletConnectionError';\n}\n\nexport class WalletDisconnectedError extends WalletError {\n name = 'WalletDisconnectedError';\n}\n\nexport class WalletDisconnectionError extends WalletError {\n name = 'WalletDisconnectionError';\n}\n\nexport class WalletAccountError extends WalletError {\n name = 'WalletAccountError';\n}\n\nexport class WalletPublicKeyError extends WalletError {\n name = 'WalletPublicKeyError';\n}\n\nexport class WalletKeypairError extends WalletError {\n name = 'WalletKeypairError';\n}\n\nexport class WalletNotConnectedError extends WalletError {\n name = 'WalletNotConnectedError';\n}\n\nexport class WalletSendTransactionError extends WalletError {\n name = 'WalletSendTransactionError';\n}\n\nexport class WalletSignTransactionError extends WalletError {\n name = 'WalletSignTransactionError';\n}\n\nexport class WalletSignMessageError extends WalletError {\n name = 'WalletSignMessageError';\n}\n\nexport class WalletSignInError extends WalletError {\n name = 'WalletSignInError';\n}\n\nexport class WalletTimeoutError extends WalletError {\n name = 'WalletTimeoutError';\n}\n\nexport class WalletWindowBlockedError extends WalletError {\n name = 'WalletWindowBlockedError';\n}\n\nexport class WalletWindowClosedError extends WalletError {\n name = 'WalletWindowClosedError';\n}\n","export function isVersionedTransaction(transaction) {\n return 'version' in transaction;\n}\n//# sourceMappingURL=transaction.js.map","import type { Transaction, TransactionVersion, VersionedTransaction } from '@solana/web3.js';\n\nexport type SupportedTransactionVersions = ReadonlySet | null | undefined;\n\nexport type TransactionOrVersionedTransaction = S extends null | undefined\n ? Transaction\n : Transaction | VersionedTransaction;\n\nexport function isVersionedTransaction(\n transaction: Transaction | VersionedTransaction\n): transaction is VersionedTransaction {\n return 'version' in transaction;\n}\n","import { BaseMessageSignerWalletAdapter, isIosAndRedirectable, isVersionedTransaction, scopePollingDetectionStrategy, WalletAccountError, WalletConnectionError, WalletDisconnectedError, WalletDisconnectionError, WalletError, WalletNotConnectedError, WalletNotReadyError, WalletPublicKeyError, WalletReadyState, WalletSendTransactionError, WalletSignMessageError, WalletSignTransactionError, } from '@solana/wallet-adapter-base';\nimport { PublicKey } from '@solana/web3.js';\nexport const PhantomWalletName = 'Phantom';\nexport class PhantomWalletAdapter extends BaseMessageSignerWalletAdapter {\n constructor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YgNDcuOTY1OCA3NC42OTg5IDQ2LjE3MDQgNzQuNjk4OSA0Mi41Nzk0Qzc0LjY5ODkgMzguOTg4NSA3Ni43ODE2IDM3LjE5MzEgNzkuMTg3NSAzNy4xOTMxQzgxLjU1NzUgMzcuMTkzMSA4My42NzYxIDM4Ljk4ODUgODMuNjc2MSA0Mi41Nzk0Wk03MC4yMTAzIDQyLjU3OTVDNzAuMjEwMyA0Ni4xNzA0IDY4LjA5MTYgNDcuOTY1OCA2NS43MjE2IDQ3Ljk2NThDNjMuMzE1NyA0Ny45NjU4IDYxLjIzMyA0Ni4xNzA0IDYxLjIzMyA0Mi41Nzk1QzYxLjIzMyAzOC45ODg1IDYzLjMxNTcgMzcuMTkzMSA2NS43MjE2IDM3LjE5MzFDNjguMDkxNiAzNy4xOTMxIDcwLjIxMDMgMzguOTg4NSA3MC4yMTAzIDQyLjU3OTVaIiBmaWxsPSIjRkZGREY4Ii8+Cjwvc3ZnPg==';\n this.supportedTransactionVersions = new Set(['legacy', 0]);\n this._readyState = typeof window === 'undefined' || typeof document === 'undefined'\n ? WalletReadyState.Unsupported\n : WalletReadyState.NotDetected;\n this._disconnected = () => {\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n wallet.off('accountChanged', this._accountChanged);\n this._wallet = null;\n this._publicKey = null;\n this.emit('error', new WalletDisconnectedError());\n this.emit('disconnect');\n }\n };\n this._accountChanged = (newPublicKey) => {\n const publicKey = this._publicKey;\n if (!publicKey)\n return;\n try {\n newPublicKey = new PublicKey(newPublicKey.toBytes());\n }\n catch (error) {\n this.emit('error', new WalletPublicKeyError(error?.message, error));\n return;\n }\n if (publicKey.equals(newPublicKey))\n return;\n this._publicKey = newPublicKey;\n this.emit('connect', newPublicKey);\n };\n this._connecting = false;\n this._wallet = null;\n this._publicKey = null;\n if (this._readyState !== WalletReadyState.Unsupported) {\n if (isIosAndRedirectable()) {\n // when in iOS (not webview), set Phantom as loadable instead of checking for install\n this._readyState = WalletReadyState.Loadable;\n this.emit('readyStateChange', this._readyState);\n }\n else {\n scopePollingDetectionStrategy(() => {\n if (window.phantom?.solana?.isPhantom || window.solana?.isPhantom) {\n this._readyState = WalletReadyState.Installed;\n this.emit('readyStateChange', this._readyState);\n return true;\n }\n return false;\n });\n }\n }\n }\n get publicKey() {\n return this._publicKey;\n }\n get connecting() {\n return this._connecting;\n }\n get readyState() {\n return this._readyState;\n }\n async autoConnect() {\n // Skip autoconnect in the Loadable state\n // We can't redirect to a universal link without user input\n if (this.readyState === WalletReadyState.Installed) {\n await this.connect();\n }\n }\n async connect() {\n try {\n if (this.connected || this.connecting)\n return;\n if (this.readyState === WalletReadyState.Loadable) {\n // redirect to the Phantom /browse universal link\n // this will open the current URL in the Phantom in-wallet browser\n const url = encodeURIComponent(window.location.href);\n const ref = encodeURIComponent(window.location.origin);\n window.location.href = `https://phantom.app/ul/browse/${url}?ref=${ref}`;\n return;\n }\n if (this.readyState !== WalletReadyState.Installed)\n throw new WalletNotReadyError();\n this._connecting = true;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const wallet = window.phantom?.solana || window.solana;\n if (!wallet.isConnected) {\n try {\n await wallet.connect();\n }\n catch (error) {\n throw new WalletConnectionError(error?.message, error);\n }\n }\n if (!wallet.publicKey)\n throw new WalletAccountError();\n let publicKey;\n try {\n publicKey = new PublicKey(wallet.publicKey.toBytes());\n }\n catch (error) {\n throw new WalletPublicKeyError(error?.message, error);\n }\n wallet.on('disconnect', this._disconnected);\n wallet.on('accountChanged', this._accountChanged);\n this._wallet = wallet;\n this._publicKey = publicKey;\n this.emit('connect', publicKey);\n }\n catch (error) {\n this.emit('error', error);\n throw error;\n }\n finally {\n this._connecting = false;\n }\n }\n async disconnect() {\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n wallet.off('accountChanged', this._accountChanged);\n this._wallet = null;\n this._publicKey = null;\n try {\n await wallet.disconnect();\n }\n catch (error) {\n this.emit('error', new WalletDisconnectionError(error?.message, error));\n }\n }\n this.emit('disconnect');\n }\n async sendTransaction(transaction, connection, options = {}) {\n try {\n const wallet = this._wallet;\n if (!wallet)\n throw new WalletNotConnectedError();\n try {\n const { signers, ...sendOptions } = options;\n if (isVersionedTransaction(transaction)) {\n signers?.length && transaction.sign(signers);\n }\n else {\n transaction = (await this.prepareTransaction(transaction, connection, sendOptions));\n signers?.length && transaction.partialSign(...signers);\n }\n sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment;\n const { signature } = await wallet.signAndSendTransaction(transaction, sendOptions);\n return signature;\n }\n catch (error) {\n if (error instanceof WalletError)\n throw error;\n throw new WalletSendTransactionError(error?.message, error);\n }\n }\n catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signTransaction(transaction) {\n try {\n const wallet = this._wallet;\n if (!wallet)\n throw new WalletNotConnectedError();\n try {\n return (await wallet.signTransaction(transaction)) || transaction;\n }\n catch (error) {\n throw new WalletSignTransactionError(error?.message, error);\n }\n }\n catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signAllTransactions(transactions) {\n try {\n const wallet = this._wallet;\n if (!wallet)\n throw new WalletNotConnectedError();\n try {\n return (await wallet.signAllTransactions(transactions)) || transactions;\n }\n catch (error) {\n throw new WalletSignTransactionError(error?.message, error);\n }\n }\n catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signMessage(message) {\n try {\n const wallet = this._wallet;\n if (!wallet)\n throw new WalletNotConnectedError();\n try {\n const { signature } = await wallet.signMessage(message);\n return signature;\n }\n catch (error) {\n throw new WalletSignMessageError(error?.message, error);\n }\n }\n catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n}\n//# sourceMappingURL=adapter.js.map","import type { EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base';\nimport {\n BaseMessageSignerWalletAdapter,\n isIosAndRedirectable,\n isVersionedTransaction,\n scopePollingDetectionStrategy,\n WalletAccountError,\n WalletConnectionError,\n WalletDisconnectedError,\n WalletDisconnectionError,\n WalletError,\n WalletNotConnectedError,\n WalletNotReadyError,\n WalletPublicKeyError,\n WalletReadyState,\n WalletSendTransactionError,\n WalletSignMessageError,\n WalletSignTransactionError,\n} from '@solana/wallet-adapter-base';\nimport type {\n Connection,\n SendOptions,\n Transaction,\n TransactionSignature,\n TransactionVersion,\n VersionedTransaction,\n} from '@solana/web3.js';\nimport { PublicKey } from '@solana/web3.js';\n\ninterface PhantomWalletEvents {\n connect(...args: unknown[]): unknown;\n disconnect(...args: unknown[]): unknown;\n accountChanged(newPublicKey: PublicKey): unknown;\n}\n\ninterface PhantomWallet extends EventEmitter {\n isPhantom?: boolean;\n publicKey?: { toBytes(): Uint8Array };\n isConnected: boolean;\n signTransaction(transaction: T): Promise;\n signAllTransactions(transactions: T[]): Promise;\n signAndSendTransaction(\n transaction: T,\n options?: SendOptions\n ): Promise<{ signature: TransactionSignature }>;\n signMessage(message: Uint8Array): Promise<{ signature: Uint8Array }>;\n connect(): Promise;\n disconnect(): Promise;\n}\n\ninterface PhantomWindow extends Window {\n phantom?: {\n solana?: PhantomWallet;\n };\n solana?: PhantomWallet;\n}\n\ndeclare const window: PhantomWindow;\n\nexport interface PhantomWalletAdapterConfig {}\n\nexport const PhantomWalletName = 'Phantom' as WalletName<'Phantom'>;\n\nexport class PhantomWalletAdapter extends BaseMessageSignerWalletAdapter {\n name = PhantomWalletName;\n url = 'https://phantom.app';\n icon =\n 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiB2aWV3Qm94PSIwIDAgMTA4IDEwOCIgZmlsbD0ibm9uZSI+CjxyZWN0IHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiByeD0iMjYiIGZpbGw9IiNBQjlGRjIiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00Ni41MjY3I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yAzOC45ODg1IDYzLjMxNTcgMzcuMTkzMSA2NS43MjE2IDM3LjE5MzFDNjguMDkxNiAzNy4xOTMxIDcwLjIxMDMgMzguOTg4NSA3MC4yMTAzIDQyLjU3OTVaIiBmaWxsPSIjRkZGREY4Ii8+Cjwvc3ZnPg==';\n supportedTransactionVersions: ReadonlySet = new Set(['legacy', 0]);\n\n private _connecting: boolean;\n private _wallet: PhantomWallet | null;\n private _publicKey: PublicKey | null;\n private _readyState: WalletReadyState =\n typeof window === 'undefined' || typeof document === 'undefined'\n ? WalletReadyState.Unsupported\n : WalletReadyState.NotDetected;\n\n constructor(config: PhantomWalletAdapterConfig = {}) {\n super();\n this._connecting = false;\n this._wallet = null;\n this._publicKey = null;\n\n if (this._readyState !== WalletReadyState.Unsupported) {\n if (isIosAndRedirectable()) {\n // when in iOS (not webview), set Phantom as loadable instead of checking for install\n this._readyState = WalletReadyState.Loadable;\n this.emit('readyStateChange', this._readyState);\n } else {\n scopePollingDetectionStrategy(() => {\n if (window.phantom?.solana?.isPhantom || window.solana?.isPhantom) {\n this._readyState = WalletReadyState.Installed;\n this.emit('readyStateChange', this._readyState);\n return true;\n }\n return false;\n });\n }\n }\n }\n\n get publicKey() {\n return this._publicKey;\n }\n\n get connecting() {\n return this._connecting;\n }\n\n get readyState() {\n return this._readyState;\n }\n\n async autoConnect(): Promise {\n // Skip autoconnect in the Loadable state\n // We can't redirect to a universal link without user input\n if (this.readyState === WalletReadyState.Installed) {\n await this.connect();\n }\n }\n\n async connect(): Promise {\n try {\n if (this.connected || this.connecting) return;\n\n if (this.readyState === WalletReadyState.Loadable) {\n // redirect to the Phantom /browse universal link\n // this will open the current URL in the Phantom in-wallet browser\n const url = encodeURIComponent(window.location.href);\n const ref = encodeURIComponent(window.location.origin);\n window.location.href = `https://phantom.app/ul/browse/${url}?ref=${ref}`;\n return;\n }\n\n if (this.readyState !== WalletReadyState.Installed) throw new WalletNotReadyError();\n\n this._connecting = true;\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const wallet = window.phantom?.solana || window.solana!;\n\n if (!wallet.isConnected) {\n try {\n await wallet.connect();\n } catch (error: any) {\n throw new WalletConnectionError(error?.message, error);\n }\n }\n\n if (!wallet.publicKey) throw new WalletAccountError();\n\n let publicKey: PublicKey;\n try {\n publicKey = new PublicKey(wallet.publicKey.toBytes());\n } catch (error: any) {\n throw new WalletPublicKeyError(error?.message, error);\n }\n\n wallet.on('disconnect', this._disconnected);\n wallet.on('accountChanged', this._accountChanged);\n\n this._wallet = wallet;\n this._publicKey = publicKey;\n\n this.emit('connect', publicKey);\n } catch (error: any) {\n this.emit('error', error);\n throw error;\n } finally {\n this._connecting = false;\n }\n }\n\n async disconnect(): Promise {\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n wallet.off('accountChanged', this._accountChanged);\n\n this._wallet = null;\n this._publicKey = null;\n\n try {\n await wallet.disconnect();\n } catch (error: any) {\n this.emit('error', new WalletDisconnectionError(error?.message, error));\n }\n }\n\n this.emit('disconnect');\n }\n\n async sendTransaction(\n transaction: T,\n connection: Connection,\n options: SendTransactionOptions = {}\n ): Promise {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new WalletNotConnectedError();\n\n try {\n const { signers, ...sendOptions } = options;\n\n if (isVersionedTransaction(transaction)) {\n signers?.length && transaction.sign(signers);\n } else {\n transaction = (await this.prepareTransaction(transaction, connection, sendOptions)) as T;\n signers?.length && (transaction as Transaction).partialSign(...signers);\n }\n\n sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment;\n\n const { signature } = await wallet.signAndSendTransaction(transaction, sendOptions);\n return signature;\n } catch (error: any) {\n if (error instanceof WalletError) throw error;\n throw new WalletSendTransactionError(error?.message, error);\n }\n } catch (error: any) {\n this.emit('error', error);\n throw error;\n }\n }\n\n async signTransaction(transaction: T): Promise {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new WalletNotConnectedError();\n\n try {\n return (await wallet.signTransaction(transaction)) || transaction;\n } catch (error: any) {\n throw new WalletSignTransactionError(error?.message, error);\n }\n } catch (error: any) {\n this.emit('error', error);\n throw error;\n }\n }\n\n async signAllTransactions(transactions: T[]): Promise {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new WalletNotConnectedError();\n\n try {\n return (await wallet.signAllTransactions(transactions)) || transactions;\n } catch (error: any) {\n throw new WalletSignTransactionError(error?.message, error);\n }\n } catch (error: any) {\n this.emit('error', error);\n throw error;\n }\n }\n\n async signMessage(message: Uint8Array): Promise {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new WalletNotConnectedError();\n\n try {\n const { signature } = await wallet.signMessage(message);\n return signature;\n } catch (error: any) {\n throw new WalletSignMessageError(error?.message, error);\n }\n } catch (error: any) {\n this.emit('error', error);\n throw error;\n }\n }\n\n private _disconnected = () => {\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n wallet.off('accountChanged', this._accountChanged);\n\n this._wallet = null;\n this._publicKey = null;\n\n this.emit('error', new WalletDisconnectedError());\n this.emit('disconnect');\n }\n };\n\n private _accountChanged = (newPublicKey: PublicKey) => {\n const publicKey = this._publicKey;\n if (!publicKey) return;\n\n try {\n newPublicKey = new PublicKey(newPublicKey.toBytes());\n } catch (error: any) {\n this.emit('error', new WalletPublicKeyError(error?.message, error));\n return;\n }\n\n if (publicKey.equals(newPublicKey)) return;\n\n this._publicKey = newPublicKey;\n this.emit('connect', newPublicKey);\n };\n}\n","import { BaseMessageSignerWalletAdapter, WalletConfigError, WalletConnectionError, WalletDisconnectedError, WalletDisconnectionError, WalletError, WalletLoadError, WalletNotConnectedError, WalletNotReadyError, WalletPublicKeyError, WalletReadyState, WalletSendTransactionError, WalletSignMessageError, WalletSignTransactionError, isIosAndRedirectable, isVersionedTransaction, scopePollingDetectionStrategy, } from '@solana/wallet-adapter-base';\nimport { PublicKey } from '@solana/web3.js';\nimport { detectAndRegisterSolflareMetaMaskWallet } from './metamask/detect.js';\nexport const SolflareWalletName = 'Solflare';\nexport class SolflareWalletAdapter extends BaseMessageSignerWalletAdapter {\n constructor(config = {}) {\n super();\n this.name = SolflareWalletName;\n this.url = 'https://solflare.com';\n this.icon = 'data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjUwIiB2aWV3Qm94PSIwIDAgNTAgNTAiIHdpZHRoPSI1MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PGxpbmVhckdyYWRpZW50IGlkPSJhIj48c3RvcCBvZmZzZXQ9IjAiIHN0b3AtY29sb3I9IiNmZmMxMGIiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNmYjNmMmUiLz48L2xpbmVhckdyYWRpZW50PjxsaW5lYXJHcmFkaWVudCBpZD0iYiIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiIHgxPSI2LjQ3ODM1IiB4Mj0iMzQuOTEwNyIgeGxpbms6aHJlZj0iI2EiIHkxPSI3LjkyIiB5Mj0iMzMuNjU5MyIvPjxyYWRpYWxHcmFkaWVudCBpZD0iYyIgY3g9IjAiIGN5PSIwIiBncmFkaWVudFRyYW5zZm9ybT0ibWF0cml4KDQuOTkyMTg4MzIgMTIuMDYzODc5NjMgLTEyLjE4MTEzNjU1IDUuMDQwNzEwNzQgMjIuNTIwMiAyMC42MTgzKSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiIHI9IjEiIHhsaW5rOmhyZWY9IiNhIi8+PHBhdGggZD0ibTI1LjE3MDggNDcuOTEwNGMuNTI1IDAgLjk1MDcuNDIxLjk1MDcuOTQwM3MtLjQyNTcuOTQwMi0uOTUwNy45NDAyLS45NTA3LS40MjA5LS45NTA3LS45NDAyLjQyNTctLjk0MDMuOTUwNy0uOTQwM3ptLTEuMDMyOC00NC45MTU2NWMuNDY0Ni4wMzgzNi44Mzk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A1My00LjAyMDYtOC44ODE5LTguOTgwMi04Ljg4MTlzLTguOTgwMiAzLjk3NjYtOC45ODAyIDguODgxOWMwIDQuOTA1NCA0LjAyMDYgOC44ODE5IDguOTgwMiA4Ljg4MTl6IiBmaWxsPSJ1cmwoI2MpIi8+PC9zdmc+';\n this.supportedTransactionVersions = new Set(['legacy', 0]);\n this._readyState = typeof window === 'undefined' || typeof document === 'undefined'\n ? WalletReadyState.Unsupported\n : WalletReadyState.Loadable;\n this._disconnected = () => {\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n this._wallet = null;\n this._publicKey = null;\n this.emit('error', new WalletDisconnectedError());\n this.emit('disconnect');\n }\n };\n this._accountChanged = (newPublicKey) => {\n if (!newPublicKey)\n return;\n const publicKey = this._publicKey;\n if (!publicKey)\n return;\n try {\n newPublicKey = new PublicKey(newPublicKey.toBytes());\n }\n catch (error) {\n this.emit('error', new WalletPublicKeyError(error?.message, error));\n return;\n }\n if (publicKey.equals(newPublicKey))\n return;\n this._publicKey = newPublicKey;\n this.emit('connect', newPublicKey);\n };\n this._connecting = false;\n this._publicKey = null;\n this._wallet = null;\n this._config = config;\n if (this._readyState !== WalletReadyState.Unsupported) {\n scopePollingDetectionStrategy(() => {\n if (window.solflare?.isSolflare || window.SolflareApp) {\n this._readyState = WalletReadyState.Installed;\n this.emit('readyStateChange', this._readyState);\n return true;\n }\n return false;\n });\n detectAndRegisterSolflareMetaMaskWallet();\n }\n }\n get publicKey() {\n return this._publicKey;\n }\n get connecting() {\n return this._connecting;\n }\n get connected() {\n return !!this._wallet?.connected;\n }\n get readyState() {\n return this._readyState;\n }\n async autoConnect() {\n // Skip autoconnect in the Loadable state on iOS\n // We can't redirect to a universal link without user input\n if (!(this.readyState === WalletReadyState.Loadable && isIosAndRedirectable())) {\n await this.connect();\n }\n }\n async connect() {\n try {\n if (this.connected || this.connecting)\n return;\n if (this._readyState !== WalletReadyState.Loadable && this._readyState !== WalletReadyState.Installed)\n throw new WalletNotReadyError();\n // redirect to the Solflare /browse universal link\n // this will open the current URL in the Solflare in-wallet browser\n if (this.readyState === WalletReadyState.Loadable && isIosAndRedirectable()) {\n const url = encodeURIComponent(window.location.href);\n const ref = encodeURIComponent(window.location.origin);\n window.location.href = `https://solflare.com/ul/v1/browse/${url}?ref=${ref}`;\n return;\n }\n let SolflareClass;\n try {\n SolflareClass = (await import('@solflare-wallet/sdk')).default;\n }\n catch (error) {\n throw new WalletLoadError(error?.message, error);\n }\n let wallet;\n try {\n wallet = new SolflareClass({ network: this._config.network });\n }\n catch (error) {\n throw new WalletConfigError(error?.message, error);\n }\n this._connecting = true;\n if (!wallet.connected) {\n try {\n await wallet.connect();\n }\n catch (error) {\n throw new WalletConnectionError(error?.message, error);\n }\n }\n if (!wallet.publicKey)\n throw new WalletConnectionError();\n let publicKey;\n try {\n publicKey = new PublicKey(wallet.publicKey.toBytes());\n }\n catch (error) {\n throw new WalletPublicKeyError(error?.message, error);\n }\n wallet.on('disconnect', this._disconnected);\n wallet.on('accountChanged', this._accountChanged);\n this._wallet = wallet;\n this._publicKey = publicKey;\n this.emit('connect', publicKey);\n }\n catch (error) {\n this.emit('error', error);\n throw error;\n }\n finally {\n this._connecting = false;\n }\n }\n async disconnect() {\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n wallet.off('accountChanged', this._accountChanged);\n this._wallet = null;\n this._publicKey = null;\n try {\n await wallet.disconnect();\n }\n catch (error) {\n this.emit('error', new WalletDisconnectionError(error?.message, error));\n }\n }\n this.emit('disconnect');\n }\n async sendTransaction(transaction, connection, options = {}) {\n try {\n const wallet = this._wallet;\n if (!wallet)\n throw new WalletNotConnectedError();\n try {\n const { signers, ...sendOptions } = options;\n if (isVersionedTransaction(transaction)) {\n signers?.length && transaction.sign(signers);\n }\n else {\n transaction = (await this.prepareTransaction(transaction, connection, sendOptions));\n signers?.length && transaction.partialSign(...signers);\n }\n sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment;\n return await wallet.signAndSendTransaction(transaction, sendOptions);\n }\n catch (error) {\n if (error instanceof WalletError)\n throw error;\n throw new WalletSendTransactionError(error?.message, error);\n }\n }\n catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signTransaction(transaction) {\n try {\n const wallet = this._wallet;\n if (!wallet)\n throw new WalletNotConnectedError();\n try {\n return (await wallet.signTransaction(transaction)) || transaction;\n }\n catch (error) {\n throw new WalletSignTransactionError(error?.message, error);\n }\n }\n catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signAllTransactions(transactions) {\n try {\n const wallet = this._wallet;\n if (!wallet)\n throw new WalletNotConnectedError();\n try {\n return (await wallet.signAllTransactions(transactions)) || transactions;\n }\n catch (error) {\n throw new WalletSignTransactionError(error?.message, error);\n }\n }\n catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n async signMessage(message) {\n try {\n const wallet = this._wallet;\n if (!wallet)\n throw new WalletNotConnectedError();\n try {\n return await wallet.signMessage(message, 'utf8');\n }\n catch (error) {\n throw new WalletSignMessageError(error?.message, error);\n }\n }\n catch (error) {\n this.emit('error', error);\n throw error;\n }\n }\n}\n//# sourceMappingURL=adapter.js.map","import type { WalletAdapterNetwork, WalletName } from '@solana/wallet-adapter-base';\nimport {\n BaseMessageSignerWalletAdapter,\n WalletConfigError,\n WalletConnectionError,\n WalletDisconnectedError,\n WalletDisconnectionError,\n WalletError,\n WalletLoadError,\n WalletNotConnectedError,\n WalletNotReadyError,\n WalletPublicKeyError,\n WalletReadyState,\n WalletSendTransactionError,\n WalletSignMessageError,\n WalletSignTransactionError,\n isIosAndRedirectable,\n isVersionedTransaction,\n scopePollingDetectionStrategy,\n type SendTransactionOptions,\n} from '@solana/wallet-adapter-base';\nimport type { Transaction, TransactionVersion, VersionedTransaction } from '@solana/web3.js';\nimport { PublicKey, type Connection, type TransactionSignature } from '@solana/web3.js';\nimport type { default as Solflare } from '@solflare-wallet/sdk';\nimport { detectAndRegisterSolflareMetaMaskWallet } from './metamask/detect.js';\n\ninterface SolflareWindow extends Window {\n solflare?: {\n isSolflare?: boolean;\n };\n SolflareApp?: unknown;\n}\n\ndeclare const window: SolflareWindow;\n\nexport interface SolflareWalletAdapterConfig {\n network?: WalletAdapterNetwork;\n}\n\nexport const SolflareWalletName = 'Solflare' as WalletName<'Solflare'>;\n\nexport class SolflareWalletAdapter extends BaseMessageSignerWalletAdapter {\n name = SolflareWalletName;\n url = 'https://solflare.com';\n icon =\n 'data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjUwIiB2aWV3Qm94PSIwIDAgNTAgNTAiIHdpZHRoPSI1MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PGxpbmVhckdyYWRpZW50IGlkPSJhIj48c3RvcCBvZmZzZXQ9IjAiIHN0b3AtY29sb3I9IiNmZmMxMGIiLz48c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiNmYjNmMmUiLz48L2xpbmVhckdyYWRpZW50PjxsaW5lYXJHcmFkaWVudCBpZD0iYiIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiIHgxPSI2LjQ3ODM1IiB4Mj0iMzQuOTEwNyIgeGxpbms6aHJlZj0iI2EiIHkxPSI3LjkyIiB5Mj0iMzMuNjU5MyIvPjxyYWRpYWxHcmFkaWVudCBpZD0iYyIgY3g9IjAiIGN5PSIwIiBncmFkaWVudFRyYW5zZm9ybT0ibWF0cml4KDQuOTkyMTg4MzIgMTIuMDYzODc5NjMgLTEyLjE4MTEzNjU1IDUuMDQwNzEwNzQgMjIuNTIwMiAyMC42MTgzKSIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiIHI9IjEiIHhsaW5rOmhyZWY9IiNhIi8+PHBhdGggZD0ibTI1LjE3MDggNDcuOTEwNGMuNTI1IDAgLjk1MD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MTkyOTcuNDI1Ni0uOTQwMjcuOTUwNy0uOTQwMjd6IiBmaWxsPSJ1cmwoI2IpIi8+PHBhdGggZD0ibTI0LjU3MSAzMi43NzkyYzQuOTU5NiAwIDguOTgwMi0zLjk3NjUgOC45ODAyLTguODgxOSAwLTQuOTA1My00LjAyMDYtOC44ODE5LTguOTgwMi04Ljg4MTlzLTguOTgwMiAzLjk3NjYtOC45ODAyIDguODgxOWMwIDQuOTA1NCA0LjAyMDYgOC44ODE5IDguOTgwMiA4Ljg4MTl6IiBmaWxsPSJ1cmwoI2MpIi8+PC9zdmc+';\n supportedTransactionVersions: ReadonlySet = new Set(['legacy', 0]);\n\n private _connecting: boolean;\n private _wallet: Solflare | null;\n private _publicKey: PublicKey | null;\n private _config: SolflareWalletAdapterConfig;\n private _readyState: WalletReadyState =\n typeof window === 'undefined' || typeof document === 'undefined'\n ? WalletReadyState.Unsupported\n : WalletReadyState.Loadable;\n\n constructor(config: SolflareWalletAdapterConfig = {}) {\n super();\n this._connecting = false;\n this._publicKey = null;\n this._wallet = null;\n this._config = config;\n\n if (this._readyState !== WalletReadyState.Unsupported) {\n scopePollingDetectionStrategy(() => {\n if (window.solflare?.isSolflare || window.SolflareApp) {\n this._readyState = WalletReadyState.Installed;\n this.emit('readyStateChange', this._readyState);\n return true;\n }\n return false;\n });\n detectAndRegisterSolflareMetaMaskWallet();\n }\n }\n\n get publicKey() {\n return this._publicKey;\n }\n\n get connecting() {\n return this._connecting;\n }\n\n get connected() {\n return !!this._wallet?.connected;\n }\n\n get readyState() {\n return this._readyState;\n }\n\n async autoConnect(): Promise {\n // Skip autoconnect in the Loadable state on iOS\n // We can't redirect to a universal link without user input\n if (!(this.readyState === WalletReadyState.Loadable && isIosAndRedirectable())) {\n await this.connect();\n }\n }\n\n async connect(): Promise {\n try {\n if (this.connected || this.connecting) return;\n if (this._readyState !== WalletReadyState.Loadable && this._readyState !== WalletReadyState.Installed)\n throw new WalletNotReadyError();\n\n // redirect to the Solflare /browse universal link\n // this will open the current URL in the Solflare in-wallet browser\n if (this.readyState === WalletReadyState.Loadable && isIosAndRedirectable()) {\n const url = encodeURIComponent(window.location.href);\n const ref = encodeURIComponent(window.location.origin);\n window.location.href = `https://solflare.com/ul/v1/browse/${url}?ref=${ref}`;\n return;\n }\n\n let SolflareClass: typeof Solflare;\n try {\n SolflareClass = (await import('@solflare-wallet/sdk')).default;\n } catch (error: any) {\n throw new WalletLoadError(error?.message, error);\n }\n\n let wallet: Solflare;\n try {\n wallet = new SolflareClass({ network: this._config.network });\n } catch (error: any) {\n throw new WalletConfigError(error?.message, error);\n }\n\n this._connecting = true;\n\n if (!wallet.connected) {\n try {\n await wallet.connect();\n } catch (error: any) {\n throw new WalletConnectionError(error?.message, error);\n }\n }\n\n if (!wallet.publicKey) throw new WalletConnectionError();\n\n let publicKey: PublicKey;\n try {\n publicKey = new PublicKey(wallet.publicKey.toBytes());\n } catch (error: any) {\n throw new WalletPublicKeyError(error?.message, error);\n }\n\n wallet.on('disconnect', this._disconnected);\n wallet.on('accountChanged', this._accountChanged);\n\n this._wallet = wallet;\n this._publicKey = publicKey;\n\n this.emit('connect', publicKey);\n } catch (error: any) {\n this.emit('error', error);\n throw error;\n } finally {\n this._connecting = false;\n }\n }\n\n async disconnect(): Promise {\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n wallet.off('accountChanged', this._accountChanged);\n\n this._wallet = null;\n this._publicKey = null;\n\n try {\n await wallet.disconnect();\n } catch (error: any) {\n this.emit('error', new WalletDisconnectionError(error?.message, error));\n }\n }\n\n this.emit('disconnect');\n }\n\n async sendTransaction(\n transaction: T,\n connection: Connection,\n options: SendTransactionOptions = {}\n ): Promise {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new WalletNotConnectedError();\n\n try {\n const { signers, ...sendOptions } = options;\n\n if (isVersionedTransaction(transaction)) {\n signers?.length && transaction.sign(signers);\n } else {\n transaction = (await this.prepareTransaction(transaction, connection, sendOptions)) as T;\n signers?.length && (transaction as Transaction).partialSign(...signers);\n }\n\n sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment;\n\n return await wallet.signAndSendTransaction(transaction, sendOptions);\n } catch (error: any) {\n if (error instanceof WalletError) throw error;\n throw new WalletSendTransactionError(error?.message, error);\n }\n } catch (error: any) {\n this.emit('error', error);\n throw error;\n }\n }\n\n async signTransaction(transaction: T): Promise {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new WalletNotConnectedError();\n\n try {\n return ((await wallet.signTransaction(transaction)) as T) || transaction;\n } catch (error: any) {\n throw new WalletSignTransactionError(error?.message, error);\n }\n } catch (error: any) {\n this.emit('error', error);\n throw error;\n }\n }\n\n async signAllTransactions(transactions: T[]): Promise {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new WalletNotConnectedError();\n\n try {\n return ((await wallet.signAllTransactions(transactions)) as T[]) || transactions;\n } catch (error: any) {\n throw new WalletSignTransactionError(error?.message, error);\n }\n } catch (error: any) {\n this.emit('error', error);\n throw error;\n }\n }\n\n async signMessage(message: Uint8Array): Promise {\n try {\n const wallet = this._wallet;\n if (!wallet) throw new WalletNotConnectedError();\n\n try {\n return await wallet.signMessage(message, 'utf8');\n } catch (error: any) {\n throw new WalletSignMessageError(error?.message, error);\n }\n } catch (error: any) {\n this.emit('error', error);\n throw error;\n }\n }\n\n private _disconnected = () => {\n const wallet = this._wallet;\n if (wallet) {\n wallet.off('disconnect', this._disconnected);\n\n this._wallet = null;\n this._publicKey = null;\n\n this.emit('error', new WalletDisconnectedError());\n this.emit('disconnect');\n }\n };\n\n private _accountChanged = (newPublicKey?: PublicKey) => {\n if (!newPublicKey) return;\n\n const publicKey = this._publicKey;\n if (!publicKey) return;\n\n try {\n newPublicKey = new PublicKey(newPublicKey.toBytes());\n } catch (error: any) {\n this.emit('error', new WalletPublicKeyError(error?.message, error));\n return;\n }\n\n if (publicKey.equals(newPublicKey)) return;\n\n this._publicKey = newPublicKey;\n this.emit('connect', newPublicKey);\n };\n}\n","import { registerWallet } from '@wallet-standard/wallet';\nimport { SolflareMetaMaskWallet } from './wallet.js';\nlet registered = false;\nfunction register() {\n if (registered)\n return;\n registerWallet(new SolflareMetaMaskWallet());\n registered = true;\n}\n/** @internal */\nexport async function detectAndRegisterSolflareMetaMaskWallet() {\n const id = 'solflare-detect-metamask';\n function postMessage() {\n window.postMessage({\n target: 'metamask-contentscript',\n data: {\n name: 'metamask-provider',\n data: {\n id,\n jsonrpc: '2.0',\n method: 'wallet_getSnaps',\n },\n },\n }, window.location.origin);\n }\n function onMessage(event) {\n const message = event.data;\n if (message?.target === 'metamask-inpage' && message.data?.name === 'metamask-provider') {\n if (message.data.data?.id === id) {\n window.removeEventListener('message', onMessage);\n if (!message.data.data.error) {\n register();\n }\n }\n else {\n postMessage();\n }\n }\n }\n window.addEventListener('message', onMessage);\n window.setTimeout(() => window.removeEventListener('message', onMessage), 5000);\n postMessage();\n}\n//# sourceMappingURL=detect.js.map","import { registerWallet } from '@wallet-standard/wallet';\nimport { SolflareMetaMaskWallet } from './wallet.js';\n\nlet registered = false;\n\nfunction register() {\n if (registered) return;\n registerWallet(new SolflareMetaMaskWallet());\n registered = true;\n}\n\n/** @internal */\nexport async function detectAndRegisterSolflareMetaMaskWallet(): Promise {\n const id = 'solflare-detect-metamask';\n\n function postMessage() {\n window.postMessage(\n {\n target: 'metamask-contentscript',\n data: {\n name: 'metamask-provider',\n data: {\n id,\n jsonrpc: '2.0',\n method: 'wallet_getSnaps',\n },\n },\n },\n window.location.origin\n );\n }\n\n function onMessage(event: MessageEvent) {\n const message = event.data;\n if (message?.target === 'metamask-inpage' && message.data?.name === 'metamask-provider') {\n if (message.data.data?.id === id) {\n window.removeEventListener('message', onMessage);\n\n if (!message.data.data.error) {\n register();\n }\n } else {\n postMessage();\n }\n }\n }\n\n window.addEventListener('message', onMessage);\n window.setTimeout(() => window.removeEventListener('message', onMessage), 5000);\n\n postMessage();\n}\n","var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n};\nvar __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n};\nvar _RegisterWalletEvent_detail;\n/**\n * Register a {@link \"@wallet-standard/base\".Wallet} as a Standard Wallet with the app.\n *\n * This dispatches a {@link \"@wallet-standard/base\".WindowRegisterWalletEvent} to notify the app that the Wallet is\n * ready to be registered.\n *\n * This also adds a listener for {@link \"@wallet-standard/base\".WindowAppReadyEvent} to listen for a notification from\n * the app that the app is ready to register the Wallet.\n *\n * This combination of event dispatch and listener guarantees that the Wallet will be registered synchronously as soon\n * as the app is ready whether the Wallet loads before or after the app.\n *\n * @param wallet Wallet to register.\n *\n * @group Wallet\n */\nexport function registerWallet(wallet) {\n const callback = ({ register }) => register(wallet);\n try {\n window.dispatchEvent(new RegisterWalletEvent(callback));\n }\n catch (error) {\n console.error('wallet-standard:register-wallet event could not be dispatched\\n', error);\n }\n try {\n window.addEventListener('wallet-standard:app-ready', ({ detail: api }) => callback(api));\n }\n catch (error) {\n console.error('wallet-standard:app-ready event listener could not be added\\n', error);\n }\n}\nclass RegisterWalletEvent extends Event {\n get detail() {\n return __classPrivateFieldGet(this, _RegisterWalletEvent_detail, \"f\");\n }\n get type() {\n return 'wallet-standard:register-wallet';\n }\n constructor(callback) {\n super('wallet-standard:register-wallet', {\n bubbles: false,\n cancelable: false,\n composed: false,\n });\n _RegisterWalletEvent_detail.set(this, void 0);\n __classPrivateFieldSet(this, _RegisterWalletEvent_detail, callback, \"f\");\n }\n /** @deprecated */\n preventDefault() {\n throw new Error('preventDefault cannot be called');\n }\n /** @deprecated */\n stopImmediatePropagation() {\n throw new Error('stopImmediatePropagation cannot be called');\n }\n /** @deprecated */\n stopPropagation() {\n throw new Error('stopPropagation cannot be called');\n }\n}\n_RegisterWalletEvent_detail = new WeakMap();\n/**\n * @deprecated Use {@link registerWallet} instead.\n *\n * @group Deprecated\n */\nexport function DEPRECATED_registerWallet(wallet) {\n var _a;\n registerWallet(wallet);\n try {\n ((_a = window.navigator).wallets || (_a.wallets = [])).push(({ register }) => register(wallet));\n }\n catch (error) {\n console.error('window.navigator.wallets could not be pushed\\n', error);\n }\n}\n//# sourceMappingURL=register.js.map","import type {\n DEPRECATED_WalletsWindow,\n Wallet,\n WalletEventsWindow,\n WindowRegisterWalletEvent,\n WindowRegisterWalletEventCallback,\n} from '@wallet-standard/base';\n\n/**\n * Register a {@link \"@wallet-standard/base\".Wallet} as a Standard Wallet with the app.\n *\n * This dispatches a {@link \"@wallet-standard/base\".WindowRegisterWalletEvent} to notify the app that the Wallet is\n * ready to be registered.\n *\n * This also adds a listener for {@link \"@wallet-standard/base\".WindowAppReadyEvent} to listen for a notification from\n * the app that the app is ready to register the Wallet.\n *\n * This combination of event dispatch and listener guarantees that the Wallet will be registered synchronously as soon\n * as the app is ready whether the Wallet loads before or after the app.\n *\n * @param wallet Wallet to register.\n *\n * @group Wallet\n */\nexport function registerWallet(wallet: Wallet): void {\n const callback: WindowRegisterWalletEventCallback = ({ register }) => register(wallet);\n try {\n (window as WalletEventsWindow).dispatchEvent(new RegisterWalletEvent(callback));\n } catch (error) {\n console.error('wallet-standard:register-wallet event could not be dispatched\\n', error);\n }\n try {\n (window as WalletEventsWindow).addEventListener('wallet-standard:app-ready', ({ detail: api }) =>\n callback(api)\n );\n } catch (error) {\n console.error('wallet-standard:app-ready event listener could not be added\\n', error);\n }\n}\n\nclass RegisterWalletEvent extends Event implements WindowRegisterWalletEvent {\n readonly #detail: WindowRegisterWalletEventCallback;\n\n get detail() {\n return this.#detail;\n }\n\n get type() {\n return 'wallet-standard:register-wallet' as const;\n }\n\n constructor(callback: WindowRegisterWalletEventCallback) {\n super('wallet-standard:register-wallet', {\n bubbles: false,\n cancelable: false,\n composed: false,\n });\n this.#detail = callback;\n }\n\n /** @deprecated */\n preventDefault(): never {\n throw new Error('preventDefault cannot be called');\n }\n\n /** @deprecated */\n stopImmediatePropagation(): never {\n throw new Error('stopImmediatePropagation cannot be called');\n }\n\n /** @deprecated */\n stopPropagation(): never {\n throw new Error('stopPropagation cannot be called');\n }\n}\n\n/**\n * @deprecated Use {@link registerWallet} instead.\n *\n * @group Deprecated\n */\nexport function DEPRECATED_registerWallet(wallet: Wallet): void {\n registerWallet(wallet);\n try {\n ((window as DEPRECATED_WalletsWindow).navigator.wallets ||= []).push(({ register }) => register(wallet));\n } catch (error) {\n console.error('window.navigator.wallets could not be pushed\\n', error);\n }\n}\n","var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\n};\nvar __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\n};\nvar _SolflareMetaMaskWallet_instances, _SolflareMetaMaskWallet_listeners, _SolflareMetaMaskWallet_version, _SolflareMetaMaskWallet_name, _SolflareMetaMaskWallet_icon, _SolflareMetaMaskWallet_solflareMetaMask, _SolflareMetaMaskWallet_on, _SolflareMetaMaskWallet_emit, _SolflareMetaMaskWallet_off, _SolflareMetaMaskWallet_connect, _SolflareMetaMaskWallet_disconnect, _SolflareMetaMaskWallet_signAndSendTransaction, _SolflareMetaMaskWallet_signTransaction, _SolflareMetaMaskWallet_signMessage;\nimport { WalletNotConnectedError } from '@solana/wallet-adapter-base';\nimport { SOLANA_DEVNET_CHAIN, SOLANA_MAINNET_CHAIN, SOLANA_TESTNET_CHAIN } from '@solana/wallet-standard-chains';\nimport { SolanaSignAndSendTransaction, SolanaSignMessage, SolanaSignTransaction, } from '@solana/wallet-standard-features';\nimport { StandardConnect, StandardDisconnect, StandardEvents, } from '@wallet-standard/features';\nimport { icon } from './icon.js';\nexport class SolflareMetaMaskWallet {\n constructor() {\n _SolflareMetaMaskWallet_instances.add(this);\n _SolflareMetaMaskWallet_listeners.set(this, {});\n _SolflareMetaMaskWallet_version.set(this, '1.0.0');\n _SolflareMetaMaskWallet_name.set(this, 'MetaMask');\n _SolflareMetaMaskWallet_icon.set(this, icon);\n _SolflareMetaMaskWallet_solflareMetaMask.set(this, null);\n _SolflareMetaMaskWallet_on.set(this, (event, listener) => {\n __classPrivateFieldGet(this, _SolflareMetaMaskWallet_listeners, \"f\")[event]?.push(listener) || (__classPrivateFieldGet(this, _SolflareMetaMaskWallet_listeners, \"f\")[event] = [listener]);\n return () => __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instances, \"m\", _SolflareMetaMaskWallet_off).call(this, event, listener);\n });\n _SolflareMetaMaskWallet_connect.set(this, async () => {\n if (!__classPrivateFieldGet(this, _SolflareMetaMaskWallet_solflareMetaMask, \"f\")) {\n let SolflareMetaMaskClass;\n try {\n SolflareMetaMaskClass = (await import('@solflare-wallet/metamask-sdk')).default;\n }\n catch (error) {\n throw new Error('Unable to load Solflare MetaMask SDK');\n }\n __classPrivateFieldSet(this, _SolflareMetaMaskWallet_solflareMetaMask, new SolflareMetaMaskClass(), \"f\");\n __classPrivateFieldGet(this, _SolflareMetaMaskWallet_solflareMetaMask, \"f\").on('standard_change', (properties) => __classPrivateFieldGet(this, _SolflareMetaMaskWallet_instances, \"m\", _SolflareMetaMaskWallet_emit).call(this, 'change', properties));\n }\n if (!this.accounts.length) {\n await __classPrivateFieldGet(this, _SolflareMetaMaskWallet_solflareMetaMask, \"f\").connect();\n }\n return { accounts: this.accounts };\n });\n _SolflareMetaMaskWallet_disconnect.set(this, async () => {\n if (!__classPrivateFieldGet(this, _SolflareMetaMaskWallet_solflareMetaMask, \"f\"))\n return;\n await __classPrivateFieldGet(this, _SolflareMetaMaskWallet_solflareMetaMask, \"f\").disconnect();\n });\n _SolflareMetaMaskWallet_signAndSendTransaction.set(this, async (...inputs) => {\n if (!__classPrivateFieldGet(this, _SolflareMetaMaskWallet_solflareMetaMask, \"f\"))\n throw new WalletNotConnectedError();\n return await __classPrivateFieldGet(this, _SolflareMetaMaskWallet_solflareMetaMask, \"f\").standardSignAndSendTransaction(...inputs);\n });\n _SolflareMetaMaskWallet_signTransaction.set(this, async (...inputs) => {\n if (!__classPrivateFieldGet(this, _SolflareMetaMaskWallet_solflareMetaMask, \"f\"))\n throw new WalletNotConnectedError();\n return await __classPrivateFieldGet(this, _SolflareMetaMaskWallet_solflareMetaMask, \"f\").standardSignTransaction(...inputs);\n });\n _SolflareMetaMaskWallet_signMessage.set(this, async (...inputs) => {\n if (!__classPrivateFieldGet(this, _SolflareMetaMaskWallet_solflareMetaMask, \"f\"))\n throw new WalletNotConnectedError();\n return await __classPrivateFieldGet(this, _SolflareMetaMaskWallet_solflareMetaMask, \"f\").standardSignMessage(...inputs);\n });\n }\n get version() {\n return __classPrivateFieldGet(this, _SolflareMetaMaskWallet_version, \"f\");\n }\n get name() {\n return __classPrivateFieldGet(this, _SolflareMetaMaskWallet_name, \"f\");\n }\n get icon() {\n return __classPrivateFieldGet(this, _SolflareMetaMaskWallet_icon, \"f\");\n }\n get chains() {\n return [SOLANA_MAINNET_CHAIN, SOLANA_DEVNET_CHAIN, SOLANA_TESTNET_CHAIN];\n }\n get features() {\n return {\n [StandardConnect]: {\n version: '1.0.0',\n connect: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_connect, \"f\"),\n },\n [StandardDisconnect]: {\n version: '1.0.0',\n disconnect: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_disconnect, \"f\"),\n },\n [StandardEvents]: {\n version: '1.0.0',\n on: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_on, \"f\"),\n },\n [SolanaSignAndSendTransaction]: {\n version: '1.0.0',\n supportedTransactionVersions: ['legacy', 0],\n signAndSendTransaction: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_signAndSendTransaction, \"f\"),\n },\n [SolanaSignTransaction]: {\n version: '1.0.0',\n supportedTransactionVersions: ['legacy', 0],\n signTransaction: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_signTransaction, \"f\"),\n },\n [SolanaSignMessage]: {\n version: '1.0.0',\n signMessage: __classPrivateFieldGet(this, _SolflareMetaMaskWallet_signMessage, \"f\"),\n },\n };\n }\n get accounts() {\n return __classPrivateFieldGet(this, _SolflareMetaMaskWallet_solflareMetaMask, \"f\") ? __classPrivateFieldGet(this, _SolflareMetaMaskWallet_solflareMetaMask, \"f\").standardAccounts : [];\n }\n}\n_SolflareMetaMaskWallet_listeners = new WeakMap(), _SolflareMetaMaskWallet_version = new WeakMap(), _SolflareMetaMaskWallet_name = new WeakMap(), _SolflareMetaMaskWallet_icon = new WeakMap(), _SolflareMetaMaskWallet_solflareMetaMask = new WeakMap(), _SolflareMetaMaskWallet_on = new WeakMap(), _SolflareMetaMaskWallet_connect = new WeakMap(), _SolflareMetaMaskWallet_disconnect = new WeakMap(), _SolflareMetaMaskWallet_signAndSendTransaction = new WeakMap(), _SolflareMetaMaskWallet_signTransaction = new WeakMap(), _SolflareMetaMaskWallet_signMessage = new WeakMap(), _SolflareMetaMaskWallet_instances = new WeakSet(), _SolflareMetaMaskWallet_emit = function _SolflareMetaMaskWallet_emit(event, ...args) {\n // eslint-disable-next-line prefer-spread\n __classPrivateFieldGet(this, _SolflareMetaMaskWallet_listeners, \"f\")[event]?.forEach((listener) => listener.apply(null, args));\n}, _SolflareMetaMaskWallet_off = function _SolflareMetaMaskWallet_off(event, listener) {\n __classPrivateFieldGet(this, _SolflareMetaMaskWallet_listeners, \"f\")[event] = __classPrivateFieldGet(this, _SolflareMetaMaskWallet_listeners, \"f\")[event]?.filter((existingListener) => listener !== existingListener);\n};\n//# sourceMappingURL=wallet.js.map","import { WalletNotConnectedError } from '@solana/wallet-adapter-base';\nimport { SOLANA_DEVNET_CHAIN, SOLANA_MAINNET_CHAIN, SOLANA_TESTNET_CHAIN } from '@solana/wallet-standard-chains';\nimport {\n SolanaSignAndSendTransaction,\n type SolanaSignAndSendTransactionFeature,\n type SolanaSignAndSendTransactionMethod,\n SolanaSignMessage,\n type SolanaSignMessageFeature,\n type SolanaSignMessageMethod,\n SolanaSignTransaction,\n type SolanaSignTransactionFeature,\n type SolanaSignTransactionMethod,\n} from '@solana/wallet-standard-features';\nimport type { default as SolflareMetaMask } from '@solflare-wallet/metamask-sdk';\nimport type { Wallet } from '@wallet-standard/base';\nimport {\n StandardConnect,\n type StandardConnectFeature,\n type StandardConnectMethod,\n StandardDisconnect,\n type StandardDisconnectFeature,\n type StandardDisconnectMethod,\n StandardEvents,\n type StandardEventsChangeProperties,\n type StandardEventsFeature,\n type StandardEventsListeners,\n type StandardEventsNames,\n type StandardEventsOnMethod,\n} from '@wallet-standard/features';\nimport { icon } from './icon.js';\n\nexport class SolflareMetaMaskWallet implements Wallet {\n readonly #listeners: { [E in StandardEventsNames]?: StandardEventsListeners[E][] } = {};\n readonly #version = '1.0.0' as const;\n readonly #name = 'MetaMask' as const;\n readonly #icon = icon;\n #solflareMetaMask: SolflareMetaMask | null = null;\n\n get version() {\n return this.#version;\n }\n\n get name() {\n return this.#name;\n }\n\n get icon() {\n return this.#icon;\n }\n\n get chains() {\n return [SOLANA_MAINNET_CHAIN, SOLANA_DEVNET_CHAIN, SOLANA_TESTNET_CHAIN] as const;\n }\n\n get features(): StandardConnectFeature &\n StandardDisconnectFeature &\n StandardEventsFeature &\n SolanaSignAndSendTransactionFeature &\n SolanaSignTransactionFeature &\n SolanaSignMessageFeature {\n return {\n [StandardConnect]: {\n version: '1.0.0',\n connect: this.#connect,\n },\n [StandardDisconnect]: {\n version: '1.0.0',\n disconnect: this.#disconnect,\n },\n [StandardEvents]: {\n version: '1.0.0',\n on: this.#on,\n },\n [SolanaSignAndSendTransaction]: {\n version: '1.0.0',\n supportedTransactionVersions: ['legacy', 0],\n signAndSendTransaction: this.#signAndSendTransaction,\n },\n [SolanaSignTransaction]: {\n version: '1.0.0',\n supportedTransactionVersions: ['legacy', 0],\n signTransaction: this.#signTransaction,\n },\n [SolanaSignMessage]: {\n version: '1.0.0',\n signMessage: this.#signMessage,\n },\n };\n }\n\n get accounts() {\n return this.#solflareMetaMask ? this.#solflareMetaMask.standardAccounts : [];\n }\n\n #on: StandardEventsOnMethod = (event, listener) => {\n this.#listeners[event]?.push(listener) || (this.#listeners[event] = [listener]);\n return (): void => this.#off(event, listener);\n };\n\n #emit(event: E, ...args: Parameters): void {\n // eslint-disable-next-line prefer-spread\n this.#listeners[event]?.forEach((listener) => listener.apply(null, args));\n }\n\n #off(event: E, listener: StandardEventsListeners[E]): void {\n this.#listeners[event] = this.#listeners[event]?.filter((existingListener) => listener !== existingListener);\n }\n\n #connect: StandardConnectMethod = async () => {\n if (!this.#solflareMetaMask) {\n let SolflareMetaMaskClass: typeof SolflareMetaMask;\n try {\n SolflareMetaMaskClass = (await import('@solflare-wallet/metamask-sdk')).default;\n } catch (error: any) {\n throw new Error('Unable to load Solflare MetaMask SDK');\n }\n this.#solflareMetaMask = new SolflareMetaMaskClass();\n this.#solflareMetaMask.on('standard_change', (properties: StandardEventsChangeProperties) =>\n this.#emit('change', properties)\n );\n }\n\n if (!this.accounts.length) {\n await this.#solflareMetaMask.connect();\n }\n\n return { accounts: this.accounts };\n };\n\n #disconnect: StandardDisconnectMethod = async () => {\n if (!this.#solflareMetaMask) return;\n await this.#solflareMetaMask.disconnect();\n };\n\n #signAndSendTransaction: SolanaSignAndSendTransactionMethod = async (...inputs) => {\n if (!this.#solflareMetaMask) throw new WalletNotConnectedError();\n return await this.#solflareMetaMask.standardSignAndSendTransaction(...inputs);\n };\n\n #signTransaction: SolanaSignTransactionMethod = async (...inputs) => {\n if (!this.#solflareMetaMask) throw new WalletNotConnectedError();\n return await this.#solflareMetaMask.standardSignTransaction(...inputs);\n };\n\n #signMessage: SolanaSignMessageMethod = async (...inputs) => {\n if (!this.#solflareMetaMask) throw new WalletNotConnectedError();\n return await this.#solflareMetaMask.standardSignMessage(...inputs);\n };\n}\n","/** Solana Mainnet (beta) cluster, e.g. https://api.mainnet-beta.solana.com */\nexport const SOLANA_MAINNET_CHAIN = 'solana:mainnet';\n/** Solana Devnet cluster, e.g. https://api.devnet.solana.com */\nexport const SOLANA_DEVNET_CHAIN = 'solana:devnet';\n/** Solana Testnet cluster, e.g. https://api.testnet.solana.com */\nexport const SOLANA_TESTNET_CHAIN = 'solana:testnet';\n/** Solana Localnet cluster, e.g. http://localhost:8899 */\nexport const SOLANA_LOCALNET_CHAIN = 'solana:localnet';\n/** Array of all Solana clusters */\nexport const SOLANA_CHAINS = [\n SOLANA_MAINNET_CHAIN,\n SOLANA_DEVNET_CHAIN,\n SOLANA_TESTNET_CHAIN,\n SOLANA_LOCALNET_CHAIN,\n];\n/**\n * Check if a chain corresponds with one of the Solana clusters.\n */\nexport function isSolanaChain(chain) {\n return SOLANA_CHAINS.includes(chain);\n}\n//# sourceMappingURL=index.js.map","import type { IdentifierString } from '@wallet-standard/base';\n\n/** Solana Mainnet (beta) cluster, e.g. https://api.mainnet-beta.solana.com */\nexport const SOLANA_MAINNET_CHAIN = 'solana:mainnet';\n\n/** Solana Devnet cluster, e.g. https://api.devnet.solana.com */\nexport const SOLANA_DEVNET_CHAIN = 'solana:devnet';\n\n/** Solana Testnet cluster, e.g. https://api.testnet.solana.com */\nexport const SOLANA_TESTNET_CHAIN = 'solana:testnet';\n\n/** Solana Localnet cluster, e.g. http://localhost:8899 */\nexport const SOLANA_LOCALNET_CHAIN = 'solana:localnet';\n\n/** Array of all Solana clusters */\nexport const SOLANA_CHAINS = [\n SOLANA_MAINNET_CHAIN,\n SOLANA_DEVNET_CHAIN,\n SOLANA_TESTNET_CHAIN,\n SOLANA_LOCALNET_CHAIN,\n] as const;\n\n/** Type of all Solana clusters */\nexport type SolanaChain = (typeof SOLANA_CHAINS)[number];\n\n/**\n * Check if a chain corresponds with one of the Solana clusters.\n */\nexport function isSolanaChain(chain: IdentifierString): chain is SolanaChain {\n return SOLANA_CHAINS.includes(chain as SolanaChain);\n}\n","/** Name of the feature. */\nexport const StandardConnect = 'standard:connect';\n/**\n * @deprecated Use {@link StandardConnect} instead.\n *\n * @group Deprecated\n */\nexport const Connect = StandardConnect;\n//# sourceMappingURL=connect.js.map","import type { WalletAccount } from '@wallet-standard/base';\n\n/** Name of the feature. */\nexport const StandardConnect = 'standard:connect';\n/**\n * @deprecated Use {@link StandardConnect} instead.\n *\n * @group Deprecated\n */\nexport const Connect = StandardConnect;\n\n/**\n * `standard:connect` is a {@link \"@wallet-standard/base\".Wallet.features | feature} that may be implemented by a\n * {@link \"@wallet-standard/base\".Wallet} to allow the app to obtain authorization to use\n * {@link \"@wallet-standard/base\".Wallet.accounts}.\n *\n * @group Connect\n */\nexport type StandardConnectFeature = {\n /** Name of the feature. */\n readonly [StandardConnect]: {\n /** Version of the feature implemented by the Wallet. */\n readonly version: StandardConnectVersion;\n /** Method to call to use the feature. */\n readonly connect: StandardConnectMethod;\n };\n};\n/**\n * @deprecated Use {@link StandardConnectFeature} instead.\n *\n * @group Deprecated\n */\nexport type ConnectFeature = StandardConnectFeature;\n\n/**\n * Version of the {@link StandardConnectFeature} implemented by a {@link \"@wallet-standard/base\".Wallet}.\n *\n * @group Connect\n */\nexport type StandardConnectVersion = '1.0.0';\n/**\n * @deprecated Use {@link StandardConnectVersion} instead.\n *\n * @group Deprecated\n */\nexport type ConnectVersion = StandardConnectVersion;\n\n/**\n * Method to call to use the {@link StandardConnectFeature}.\n *\n * @group Connect\n */\nexport type StandardConnectMethod = (input?: StandardConnectInput) => Promise;\n/**\n * @deprecated Use {@link StandardConnectMethod} instead.\n *\n * @group Deprecated\n */\nexport type ConnectMethod = StandardConnectMethod;\n\n/**\n * Input for the {@link StandardConnectMethod}.\n *\n * @group Connect\n */\nexport interface StandardConnectInput {\n /**\n * By default, using the {@link StandardConnectFeature} should prompt the user to request authorization to accounts.\n * Set the `silent` flag to `true` to request accounts that have already been authorized without prompting.\n *\n * This flag may or may not be used by the Wallet and the app should not depend on it being used.\n * If this flag is used by the Wallet, the Wallet should not prompt the user, and should return only the accounts\n * that the app is authorized to use.\n */\n readonly silent?: boolean;\n}\n/**\n * @deprecated Use {@link StandardConnectInput} instead.\n *\n * @group Deprecated\n */\nexport type ConnectInput = StandardConnectInput;\n\n/**\n * Output of the {@link StandardConnectMethod}.\n *\n * @group Connect\n */\nexport interface StandardConnectOutput {\n /** List of accounts in the {@link \"@wallet-standard/base\".Wallet} that the app has been authorized to use. */\n readonly accounts: readonly WalletAccount[];\n}\n/**\n * @deprecated Use {@link StandardConnectOutput} instead.\n *\n * @group Deprecated\n */\nexport type ConnectOutput = StandardConnectOutput;\n","/** Name of the feature. */\nexport const StandardDisconnect = 'standard:disconnect';\n/**\n * @deprecated Use {@link StandardDisconnect} instead.\n *\n * @group Deprecated\n */\nexport const Disconnect = StandardDisconnect;\n//# sourceMappingURL=disconnect.js.map","/** Name of the feature. */\nexport const StandardDisconnect = 'standard:disconnect';\n/**\n * @deprecated Use {@link StandardDisconnect} instead.\n *\n * @group Deprecated\n */\nexport const Disconnect = StandardDisconnect;\n\n/**\n * `standard:disconnect` is a {@link \"@wallet-standard/base\".Wallet.features | feature} that may be implemented by a\n * {@link \"@wallet-standard/base\".Wallet} to allow the app to perform any cleanup work.\n *\n * This feature may or may not be used by the app and the Wallet should not depend on it being used.\n * If this feature is used by the app, the Wallet should perform any cleanup work, but should not revoke authorization\n * to use accounts previously granted through the {@link ConnectFeature}.\n *\n * @group Disconnect\n */\nexport type StandardDisconnectFeature = {\n /** Name of the feature. */\n readonly [StandardDisconnect]: {\n /** Version of the feature implemented by the Wallet. */\n readonly version: StandardDisconnectVersion;\n /** Method to call to use the feature. */\n readonly disconnect: StandardDisconnectMethod;\n };\n};\n/**\n * @deprecated Use {@link StandardDisconnectFeature} instead.\n *\n * @group Deprecated\n */\nexport type DisconnectFeature = StandardDisconnectFeature;\n\n/**\n * Version of the {@link StandardDisconnectFeature} implemented by a Wallet.\n *\n * @group Disconnect\n */\nexport type StandardDisconnectVersion = '1.0.0';\n/**\n * @deprecated Use {@link StandardDisconnectVersion} instead.\n *\n * @group Deprecated\n */\nexport type DisconnectVersion = StandardDisconnectVersion;\n\n/**\n * Method to call to use the {@link StandardDisconnectFeature}.\n *\n * @group Disconnect\n */\nexport type StandardDisconnectMethod = () => Promise;\n/**\n * @deprecated Use {@link StandardDisconnectMethod} instead.\n *\n * @group Deprecated\n */\nexport type DisconnectMethod = StandardDisconnectMethod;\n","/** Name of the feature. */\nexport const StandardEvents = 'standard:events';\n/**\n * @deprecated Use {@link StandardEvents} instead.\n *\n * @group Deprecated\n */\nexport const Events = StandardEvents;\n//# sourceMappingURL=events.js.map","import type { Wallet } from '@wallet-standard/base';\n\n/** Name of the feature. */\nexport const StandardEvents = 'standard:events';\n/**\n * @deprecated Use {@link StandardEvents} instead.\n *\n * @group Deprecated\n */\nexport const Events = StandardEvents;\n\n/**\n * `standard:events` is a {@link \"@wallet-standard/base\".Wallet.features | feature} that may be implemented by a\n * {@link \"@wallet-standard/base\".Wallet} to allow the app to add an event listener and subscribe to events emitted by\n * the Wallet when properties of the Wallet {@link StandardEventsListeners.change}.\n *\n * @group Events\n */\nexport type StandardEventsFeature = {\n /** Name of the feature. */\n readonly [StandardEvents]: {\n /** Version of the feature implemented by the {@link \"@wallet-standard/base\".Wallet}. */\n readonly version: StandardEventsVersion;\n /** Method to call to use the feature. */\n readonly on: StandardEventsOnMethod;\n };\n};\n/**\n * @deprecated Use {@link StandardEventsFeature} instead.\n *\n * @group Deprecated\n */\nexport type EventsFeature = StandardEventsFeature;\n\n/**\n * Version of the {@link StandardEventsFeature} implemented by a {@link \"@wallet-standard/base\".Wallet}.\n *\n * @group Events\n */\nexport type StandardEventsVersion = '1.0.0';\n/**\n * @deprecated Use {@link StandardEventsVersion} instead.\n *\n * @group Deprecated\n */\nexport type EventsVersion = StandardEventsVersion;\n\n/**\n * Method to call to use the {@link StandardEventsFeature}.\n *\n * @param event Event type to listen for. {@link StandardEventsListeners.change | `change`} is the only event type.\n * @param listener Function that will be called when an event of the type is emitted.\n *\n * @return\n * `off` function which may be called to remove the event listener and unsubscribe from events.\n *\n * As with all event listeners, be careful to avoid memory leaks.\n *\n * @group Events\n */\nexport type StandardEventsOnMethod = (\n event: E,\n listener: StandardEventsListeners[E]\n) => () => void;\n/**\n * @deprecated Use {@link StandardEventsOnMethod} instead.\n *\n * @group Deprecated\n */\nexport type EventsOnMethod = StandardEventsOnMethod;\n\n/**\n * Types of event listeners of the {@link StandardEventsFeature}.\n *\n * @group Events\n */\nexport interface StandardEventsListeners {\n /**\n * Listener that will be called when {@link StandardEventsChangeProperties | properties} of the\n * {@link \"@wallet-standard/base\".Wallet} have changed.\n *\n * @param properties Properties that changed with their **new** values.\n */\n change(properties: StandardEventsChangeProperties): void;\n}\n/**\n * @deprecated Use {@link StandardEventsListeners} instead.\n *\n * @group Deprecated\n */\nexport type EventsListeners = StandardEventsListeners;\n\n/**\n * Names of {@link StandardEventsListeners} that can be listened for.\n *\n * @group Events\n */\nexport type StandardEventsNames = keyof StandardEventsListeners;\n/**\n * @deprecated Use {@link StandardEventsNames} instead.\n *\n * @group Deprecated\n */\nexport type EventsNames = StandardEventsNames;\n\n/**\n * Properties of a {@link \"@wallet-standard/base\".Wallet} that {@link StandardEventsListeners.change | changed} with their\n * **new** values.\n *\n * @group Events\n */\nexport interface StandardEventsChangeProperties {\n /**\n * {@link \"@wallet-standard/base\".Wallet.chains | Chains} supported by the Wallet.\n *\n * The Wallet should only define this field if the value of the property has changed.\n *\n * The value must be the **new** value of the property.\n */\n readonly chains?: Wallet['chains'];\n /**\n * {@link \"@wallet-standard/base\".Wallet.features | Features} supported by the Wallet.\n *\n * The Wallet should only define this field if the value of the property has changed.\n *\n * The value must be the **new** value of the property.\n */\n readonly features?: Wallet['features'];\n /**\n * {@link \"@wallet-standard/base\".Wallet.accounts | Accounts} that the app is authorized to use.\n *\n * The Wallet should only define this field if the value of the property has changed.\n *\n * The value must be the **new** value of the property.\n */\n readonly accounts?: Wallet['accounts'];\n}\n/**\n * @deprecated Use {@link StandardEventsChangeProperties} instead.\n *\n * @group Deprecated\n */\nexport type EventsChangeProperties = StandardEventsChangeProperties;\n","/** @internal */\nexport const icon = 'data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjMxIiB2aWV3Qm94PSIwIDAgMzEgMzEiIHdpZHRoPSIzMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PGxpbmVhckdyYWRpZW50IGlkPSJhIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjIwLjI1IiB4Mj0iMjYuNTcxIiB5MT0iMjcuMTczIiB5Mj0iMTkuODU4Ij48c3RvcCBvZmZzZXQ9Ii4wOCIgc3RvcC1jb2xvcj0iIzk5NDVmZiIvPjxzdG9wIG9mZnNldD0iLjMiIHN0b3AtY29sb3I9IiM4NzUyZjMi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gLjA1Ni0uMDY1Yy4wMTItLjAyNi4wMTUtLjA1Ni4wMS0uMDg0cy0uMDE4LS4wNTUtLjAzOS0uMDc2em0tNi40MzEtLjk4M2g2LjIwOWEuMzEuMzEgMCAwIDAgLjEyMS0uMDI0Yy4wMzgtLjAxNi4wNzMtLjA0LjEwMS0uMDdsMS4zMS0xLjM2OGMuMDItLjAyMS4wMzQtLjA0Ny4wMzktLjA3NnMuMDAxLS4wNTgtLjAxLS4wODRhLjE1LjE1IDAgMCAwIC0uMDU2LS4wNjVjLS4wMjUtLjAxNi0uMDU0LS4wMjQtLjA4My0uMDI0aC02LjIwOGEuMzEuMzEgMCAwIDAgLS4xMjEuMDI1Yy0uMDM4LjAxNi0uMDcyLjA0LS4xMDEuMDY5bC0xLjMxIDEuMzY4Yy0uMDIuMDIxLS4wMzQuMDQ3LS4wMzkuMDc2cy0uMDAxLjA1OC4wMS4wODQuMDMxLjA0OS4wNTYuMDY1LjA1NC4wMjQuMDgzLjAyNHoiIGZpbGw9InVybCgjYSkiLz48L3N2Zz4=';\n//# sourceMappingURL=icon.js.map","import type { WalletIcon } from '@wallet-standard/base';\n\n/** @internal */\nexport const icon: WalletIcon =\n 'data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjMxIiB2aWV3Qm94PSIwIDAgMzEgMzEiIHdpZHRoPSIzMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PGxpbmVhckdyYWRpZW50IGlkPSJhIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjIwLjI1IiB4Mj0iMjYuNTcxIiB5MT0iMjcuMTczIiB5Mj0iMTkuODU4Ij48c3RvcCBvZmZzZXQ9Ii4wOCIgc3RvcC1jb2xvcj0iIzk5NDVmZiIvPjxzdG9wIG9mZnNldD0iLjMiIHN0b3AtY29sb3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TUuMTUgMCAwIDAgLjA1Ni0uMDY1Yy4wMTItLjAyNi4wMTUtLjA1Ni4wMS0uMDg0cy0uMDE4LS4wNTUtLjAzOS0uMDc2em0tNi40MzEtLjk4M2g2LjIwOWEuMzEuMzEgMCAwIDAgLjEyMS0uMDI0Yy4wMzgtLjAxNi4wNzMtLjA0LjEwMS0uMDdsMS4zMS0xLjM2OGMuMDItLjAyMS4wMzQtLjA0Ny4wMzktLjA3NnMuMDAxLS4wNTgtLjAxLS4wODRhLjE1LjE1IDAgMCAwIC0uMDU2LS4wNjVjLS4wMjUtLjAxNi0uMDU0LS4wMjQtLjA4My0uMDI0aC02LjIwOGEuMzEuMzEgMCAwIDAgLS4xMjEuMDI1Yy0uMDM4LjAxNi0uMDcyLjA0LS4xMDEuMDY5bC0xLjMxIDEuMzY4Yy0uMDIuMDIxLS4wMzQuMDQ3LS4wMzkuMDc2cy0uMDAxLjA1OC4wMS4wODQuMDMxLjA0OS4wNTYuMDY1LjA1NC4wMjQuMDgzLjAyNHoiIGZpbGw9InVybCgjYSkiLz48L3N2Zz4=' as const;\n","export var WalletAdapterNetwork;\n(function (WalletAdapterNetwork) {\n WalletAdapterNetwork[\"Mainnet\"] = \"mainnet-beta\";\n WalletAdapterNetwork[\"Testnet\"] = \"testnet\";\n WalletAdapterNetwork[\"Devnet\"] = \"devnet\";\n})(WalletAdapterNetwork || (WalletAdapterNetwork = {}));\n//# sourceMappingURL=types.js.map","import type { WalletAdapter } from './adapter.js';\nimport type { MessageSignerWalletAdapter, SignerWalletAdapter, SignInMessageSignerWalletAdapter } from './signer.js';\nimport type { StandardWalletAdapter } from './standard.js';\n\nexport type Adapter =\n | WalletAdapter\n | SignerWalletAdapter\n | MessageSignerWalletAdapter\n | SignInMessageSignerWalletAdapter\n | StandardWalletAdapter;\n\nexport enum WalletAdapterNetwork {\n Mainnet = 'mainnet-beta',\n Testnet = 'testnet',\n Devnet = 'devnet',\n}\n"],"names":["$543d6d2a56ed7d8d$var$walletConnectConnectedWallet","$parcel$export","e","n","v","s","Object","defineProperty","get","set","enumerable","configurable","$parcel$interopDefault","a","__esModule","default","WalletReadyState","WalletAdapterNetwork","$a27aaf340df890aa$export$2a7b8071105d05b6","$aff560f1983590b4$var$_RegisterWalletEvent_detail","$047e59d25887ab3f$var$_SolflareMetaMaskWallet_instances","$047e59d25887ab3f$var$_SolflareMetaMaskWallet_listeners","$047e59d25887ab3f$var$_SolflareMetaMaskWallet_version","$047e59d25887ab3f$var$_SolflareMetaMaskWallet_name","$047e59d25887ab3f$var$_SolflareMetaMaskWallet_icon","$047e59d25887ab3f$var$_SolflareMetaMaskWallet_solflareMetaMask","$047e59d25887ab3f$var$_SolflareMetaMaskWallet_on","$047e59d25887ab3f$var$_SolflareMetaMaskWallet_emit","$047e59d25887ab3f$var$_SolflareMetaMaskWallet_off","$047e59d25887ab3f$var$_SolflareMetaMaskWallet_connect","$047e59d25887ab3f$var$_SolflareMetaMaskWallet_disconnect","$047e59d25887ab3f$var$_SolflareMetaMaskWallet_signAndSendTransaction","$047e59d25887ab3f$var$_SolflareMetaMaskWallet_signTransaction","$047e59d25887ab3f$var$_SolflareMetaMaskWallet_signMessage","$0e615402198d55c8$export$90767a7ae4c388dc","$parcel$global","globalThis","$parcel$modules","$parcel$inits","parcelRequire","id","exports","init","module","call","err","Error","code","register","parcelRegister","$18c11f3350a906ea$export$6503ec6e8aabbaf","$18c11f3350a906ea$export$f7ad0328861e2f03","$18c11f3350a906ea$var$mapping","Map","baseUrl","manifest","i","length","path","resolved","URL","toString","$51861dfc7ca9d588$export$a143d493d941bafc","$51861dfc7ca9d588$export$e4cf37d7f6fb9e0a","$51861dfc7ca9d588$export$f99ded8fe4b79145","$51861dfc7ca9d588$export$599f31c3813fae4d","$kuxul","$9NvM5","$51861dfc7ca9d588$var$customInspectSymbol","Symbol","$51861dfc7ca9d588$var$createBuffer","RangeError","buf","Uint8Array","setPrototypeOf","$51861dfc7ca9d588$var$Buffer","prototype","arg","encodingOrOffset","TypeError","$51861dfc7ca9d588$var$allocUnsafe","$51861dfc7ca9d588$var$from","value","$51861dfc7ca9d588$var$fromString","string","encoding","isEncoding","$51861dfc7ca9d588$var$byteLength","actual","write","slice","ArrayBuffer","isView","$51861dfc7ca9d588$var$fromArrayView","arrayView","$51861dfc7ca9d588$var$isInstance","copy","$51861dfc7ca9d588$var$fromArrayBuffer","buffer","byteOffset","byteLength","$51861dfc7ca9d588$var$fromArrayLike","SharedArrayBuffer","valueOf","from","b","$51861dfc7ca9d588$var$fromObject","obj","isBuffer","len","$51861dfc7ca9d588$var$checked","undefined","type","Array","isArray","data","toPrimitive","$51861dfc7ca9d588$var$assertSize","size","array","mustMatch","arguments","loweredCase","$51861dfc7ca9d588$var$utf8ToBytes","$51861dfc7ca9d588$var$base64ToBytes","toLowerCase","$51861dfc7ca9d588$var$slowToString","start","end","$51861dfc7ca9d588$var$hexSlice","out","$51861dfc7ca9d588$var$hexSliceLookupTable","$51861dfc7ca9d588$var$utf8Slice","$51861dfc7ca9d588$var$asciiSlice","ret","Math","min","String","fromCharCode","$51861dfc7ca9d588$var$latin1Slice","fromByteArray","$51861dfc7ca9d588$var$utf16leSlice","bytes","res","$51861dfc7ca9d588$var$swap","m","$51861dfc7ca9d588$var$bidirectionalIndexOf","val","dir","$51861dfc7ca9d588$var$arrayIndexOf","indexOf","lastIndexOf","arr","indexSize","arrLength","valLength","read","readUInt16BE","foundIndex","found","j","firstByte","codePoint","bytesPerSequence","secondByte","thirdByte","fourthByte","tempCodePoint","push","$51861dfc7ca9d588$var$decodeCodePointsArray","codePoints","apply","$51861dfc7ca9d588$var$checkOffset","offset","ext","$51861dfc7ca9d588$var$checkInt","max","$51861dfc7ca9d588$var$wrtBigUInt64LE","$51861dfc7ca9d588$var$checkIntBI","lo","Number","BigInt","hi","$51861dfc7ca9d588$var$wrtBigUInt64BE","$51861dfc7ca9d588$var$checkIEEE754","$51861dfc7ca9d588$var$writeFloat","littleEndian","noAssert","$51861dfc7ca9d588$var$writeDouble","alloc","TYPED_ARRAY_SUPPORT","$51861dfc7ca9d588$var$typedArraySupport","proto","foo","console","error","poolSize","fill","allocUnsafe","allocUnsafeSlow","_isBuffer","compare","x","y","concat","list","pos","swap16","swap32","swap64","toLocaleString","equals","inspect","str","replace","trim","target","thisStart","thisEnd","thisCopy","targetCopy","includes","isFinite","remaining","$51861dfc7ca9d588$var$hexWrite","strLen","parsed","parseInt","substr","$51861dfc7ca9d588$var$blitBuffer","$51861dfc7ca9d588$var$asciiToBytes","byteArray","charCodeAt","$51861dfc7ca9d588$var$utf16leToBytes","units","c","toJSON","_arr","newBuf","subarray","readUintLE","readUIntLE","mul","readUintBE","readUIntBE","readUint8","readUInt8","readUint16LE","readUInt16LE","readUint16BE","readUint32LE","readUInt32LE","readUint32BE","readUInt32BE","readBigUInt64LE","$51861dfc7ca9d588$var$defineBigIntMethod","$51861dfc7ca9d588$var$validateNumber","first","last","$51861dfc7ca9d588$var$boundsError","readBigUInt64BE","readIntLE","pow","readIntBE","readInt8","readInt16LE","readInt16BE","readInt32LE","readInt32BE","readBigInt64LE","readBigInt64BE","readFloatLE","readFloatBE","readDoubleLE","readDoubleBE","writeUintLE","writeUIntLE","maxBytes","writeUintBE","writeUIntBE","writeUint8","writeUInt8","writeUint16LE","writeUInt16LE","writeUint16BE","writeUInt16BE","writeUint32LE","writeUInt32LE","writeUint32BE","writeUInt32BE","writeBigUInt64LE","writeBigUInt64BE","writeIntLE","limit","sub","writeIntBE","writeInt8","writeInt16LE","writeInt16BE","writeInt32LE","writeInt32BE","writeBigInt64LE","writeBigInt64BE","writeFloatLE","writeFloatBE","writeDoubleLE","writeDoubleBE","targetStart","copyWithin","$51861dfc7ca9d588$var$errors","$51861dfc7ca9d588$var$E","sym","getMessage","Base","constructor","writable","name","stack","message","$51861dfc7ca9d588$var$addNumericalSeparator","range","ERR_OUT_OF_RANGE","ERR_INVALID_ARG_TYPE","floor","ERR_BUFFER_OUT_OF_BOUNDS","input","msg","received","isInteger","abs","$51861dfc7ca9d588$var$INVALID_BASE64_RE","Infinity","leadSurrogate","toByteArray","$51861dfc7ca9d588$var$base64clean","split","src","dst","alphabet","table","i16","fn","$51861dfc7ca9d588$var$BufferBigIntNotDefined","$eeb0961446aae8e3$export$d622b2ad8d90c771","$eeb0961446aae8e3$export$6100ba28696e12de","b64","tmp","lens","$eeb0961446aae8e3$var$getLens","validLen","placeHoldersLen","$eeb0961446aae8e3$var$Arr","curByte","$eeb0961446aae8e3$var$revLookup","uint8","extraBytes","parts","len2","$eeb0961446aae8e3$var$encodeChunk","output","$eeb0961446aae8e3$var$lookup","num","join","$eeb0961446aae8e3$var$code","$eeb0961446aae8e3$var$i","$eeb0961446aae8e3$var$len","$7221566bd4d49f44$export$aafa59e2e03f2942","$7221566bd4d49f44$export$68d8715fc104d294","isLE","mLen","nBytes","eLen","eMax","eBias","nBits","d","NaN","rt","isNaN","log","LN2","$c3af9e523501759a$export$ca8b6604d6ce14de","$c3af9e523501759a$export$febc5573c75cefb0","$c3af9e523501759a$export$232cc3f078dcc284","$6ZWSX","$kE5x4","$dEXSZ","$bYkMz","$6XnWx","$75BJw","$Q02IV","$gyRuj","$5DqgT","$ga6mf","$J0sDk","$5r7db","ed25519","utils","randomPrivateKey","$c3af9e523501759a$var$generateKeypair","privateScalar","publicKey","$c3af9e523501759a$var$getPublicKey","secretKey","getPublicKey","$c3af9e523501759a$var$isOnCurve","ExtendedPoint","fromHex","$c3af9e523501759a$var$sign","sign","$c3af9e523501759a$var$verify","verify","$c3af9e523501759a$var$toBuffer","Buffer","$c3af9e523501759a$export$eabc71f011df675a","properties","assign","encode","serialize","$c3af9e523501759a$export$68d13ce9b4cc48f3","decode","deserialize","decodeUnchecked","deserializeUnchecked","$c3af9e523501759a$var$uniquePublicKeyCounter","_bn","decoded","unique","key","toBuffer","eq","toBase58","toBytes","toArrayLike","zeroPad","toStringTag","createWithSeed","fromPublicKey","seed","programId","sha256","createProgramAddressSync","seeds","forEach","publicKeyBytes","createProgramAddress","findProgramAddressSync","address","nonce","seedsWithNonce","findProgramAddress","isOnCurve","pubkeyData","pubkey","kind","fields","$c3af9e523501759a$export$718fcd78527f88ed","signature","$c3af9e523501759a$export$b822204c22e46bdf","timeoutSeconds","toFixed","$c3af9e523501759a$export$a3e7565a95f5a1e5","$c3af9e523501759a$export$109914c107623102","staticAccountKeys","accountKeysFromLookups","keySegments","readonly","index","keySegment","flat","compileInstructions","instructions","U8_MAX","keyIndexMap","findKeyIndex","keyIndex","map","instruction","programIdIndex","accountKeyIndexes","keys","meta","$c3af9e523501759a$var$publicKey","property","blob","$c3af9e523501759a$var$signature","$c3af9e523501759a$var$rustString","rsl","struct","u32","_decode","bind","_encode","rslShim","chars","span","$c3af9e523501759a$var$decodeLength","elem","shift","$c3af9e523501759a$var$encodeLength","rem_len","$c3af9e523501759a$var$assert","condition","$c3af9e523501759a$var$CompiledKeys","payer","keyMetaMap","compile","getOrInsertDefault","keyMeta","isSigner","isWritable","isInvoked","payerKeyMeta","ix","accountMeta","getMessageComponents","mapEntries","entries","writableSigners","filter","readonlySigners","writableNonSigners","readonlyNonSigners","header","numRequiredSignatures","numReadonlySignedAccounts","numReadonlyUnsignedAccounts","payerAddress","extractTableLookup","lookupTable","writableIndexes","drainedWritableKeys","drainKeysFoundInLookupTable","state","addresses","readonlyIndexes","drainedReadonlyKeys","accountKey","lookupTableEntries","keyMetaFilter","lookupTableIndexes","drainedKeys","lookupTableIndex","findIndex","entry","delete","$c3af9e523501759a$var$END_OF_BUFFER_ERROR_MESSAGE","$c3af9e523501759a$var$guardedShift","$c3af9e523501759a$var$guardedSplice","args","splice","$c3af9e523501759a$export$f69c19e57285b83a","accountKeys","recentBlockhash","indexToProgramIds","account","version","compiledInstructions","accounts","addressTableLookups","getAccountKeys","compiledKeys","payerKey","isAccountSigner","isAccountWritable","numSignedAccounts","numWritableUnsignedAccounts","numUnsignedAccounts","unsignedAccountIndex","isProgramId","has","programIds","values","nonProgramIds","_","numKeys","keyCount","keyIndicesCount","dataCount","keyIndices","dataLength","instructionCount","instructionBuffer","instructionBufferLength","instructionLayout","u8","seq","signDataLayout","transaction","signData","accountCount","dataSlice","$c3af9e523501759a$export$ee274c70e0fae590","numAccountKeysFromLookups","count","lookup","addressLookupTableAccounts","resolveAddressTableLookups","numStaticAccountKeys","lookupAccountKeysIndex","reduce","tableLookup","tableAccount","find","extractResult","addressTableLookup","encodedStaticAccountKeysLength","serializedInstructions","serializeInstructions","encodedInstructionsLength","serializedAddressTableLookups","serializeAddressTableLookups","encodedAddressTableLookupsLength","messageLayout","serializedMessage","serializedMessageLength","prefix","staticAccountKeysLength","instructionsLength","addressTableLookupsLength","serializedLength","encodedAccountKeyIndexesLength","encodedDataLength","encodedWritableIndexesLength","encodedReadonlyIndexesLength","addressTableLookupLayout","maskedPrefix","accountKeyIndexesLength","addressTableLookupsCount","writableIndexesLength","readonlyIndexesLength","$c3af9e523501759a$export$b0a61927d00ede7f","deserializeMessageVersion","$c3af9e523501759a$var$DEFAULT_SIGNATURE","$c3af9e523501759a$export$a7a3aa8360ac9f59","opts","signatures","feePayer","lastValidBlockHeight","nonceInfo","minNonceContextSlot","_message","_json","hasOwnProperty","minContextSlot","blockhash","nonceInstruction","signers","add","items","item","compileMessage","JSON","stringify","warn","accountMetas","uniqueMetas","pubkeyString","uniqueIndex","sort","localeCompare","localeMatcher","usage","sensitivity","ignorePunctuation","numeric","caseFirst","feePayerIndex","payerMeta","unshift","signedKeys","unsignedKeys","_compile","every","pair","serializeMessage","getEstimatedFee","connection","getFeeForMessage","setSigners","seen","Set","uniqueSigners","signer","_partialSign","partialSign","_addSignature","addSignature","sigpair","verifySignatures","requireAllSignatures","_getMessageSignednessErrors","errors","missing","invalid","config","sigErrors","errorMessage","p","_serialize","signatureCount","transactionLength","wireTransaction","keyObj","populate","sigPubkeyPair","some","defaultSignatures","encodedSignaturesLength","transactionLayout","serializedTransaction","serializedTransactionLength","signaturesLength","messageData","signerPubkeys","signerIndex","$c3af9e523501759a$export$393aa1412d47050e","$c3af9e523501759a$export$e74201139e9833db","$c3af9e523501759a$export$970d0190cdb3a8e9","$c3af9e523501759a$export$ca994171317280ea","$c3af9e523501759a$export$121e803f723b3045","action","transactionMessage","logs","maybeLogsOutput","guideText","transactionLogs","transactionError","cachedLogs","getLogs","Promise","resolve","reject","getTransaction","then","tx","logMessages","catch","$c3af9e523501759a$export$4ad6fe6dae0b6bc3","options","status","sendOptions","skipPreflight","preflightCommitment","commitment","maxRetries","sendTransaction","confirmTransaction","abortSignal","nonceAccountPubkey","nonceValue","$c3af9e523501759a$var$encodeData","allocLength","layout","$c3af9e523501759a$var$getAlloc","getItemAlloc","field","elementLayout","layoutFields","$c3af9e523501759a$export$d1cc579b1c48f515","nu64","$c3af9e523501759a$export$7126250b6d8bd94a","$c3af9e523501759a$var$NonceAccountLayout","$c3af9e523501759a$var$encodeDecode","$c3af9e523501759a$var$u64","bigIntLayout","toBigIntLE","bigInt","toBufferLE","$c3af9e523501759a$export$74bdf41d8d1e7108","freeze","Create","ns64","Assign","Transfer","CreateWithSeed","AdvanceNonceAccount","WithdrawNonceAccount","InitializeNonceAccount","AuthorizeNonceAccount","Allocate","AllocateWithSeed","AssignWithSeed","TransferWithSeed","UpgradeNonceAccount","$c3af9e523501759a$export$d8c4e17726848113","createAccount","params","lamports","space","fromPubkey","newAccountPubkey","transfer","basePubkey","toPubkey","base","accountPubkey","createAccountWithSeed","createNonceAccount","noncePubkey","initParams","authorizedPubkey","nonceInitialize","authorized","nonceAdvance","nonceWithdraw","nonceAuthorize","newAuthorizedPubkey","allocate","$c3af9e523501759a$export$3b0d6d7590275603","getMinNumSignatures","ceil","chunkSize","load","program","balanceNeeded","getMinimumBalanceForRentExemption","programInfo","getAccountInfo","executable","owner","dataLayout","transactions","bytesLength","bytesLengthPadding","_rpcEndpoint","setTimeout","all","deployCommitment","finalizeSignature","context","currentSlot","getSlot","slot","round","$c3af9e523501759a$var$MS_PER_SLOT","$c3af9e523501759a$export$4c6d5b89e1596f26","CommonClient","$c3af9e523501759a$var$PublicKeyFromString","coerce","instance","$c3af9e523501759a$var$RawAccountDataResult","tuple","literal","$c3af9e523501759a$var$BufferFromRawAccountData","$c3af9e523501759a$var$createRpcResult","result","union","jsonrpc","unknown","optional","any","$c3af9e523501759a$var$UnknownRpcResult","$c3af9e523501759a$var$jsonRpcResult","schema","create","$c3af9e523501759a$var$jsonRpcResultAndContext","number","$c3af9e523501759a$var$notificationResultAndContext","$c3af9e523501759a$var$GetInflationGovernorResult","foundation","foundationTerm","initial","taper","terminal","nullable","epoch","effectiveSlot","amount","postBalance","commission","$c3af9e523501759a$var$GetRecentPrioritizationFeesResult","prioritizationFee","$c3af9e523501759a$var$GetInflationRateResult","total","validator","$c3af9e523501759a$var$GetEpochInfoResult","slotIndex","slotsInEpoch","absoluteSlot","blockHeight","transactionCount","$c3af9e523501759a$var$GetEpochScheduleResult","slotsPerEpoch","leaderScheduleSlotOffset","warmup","boolean","firstNormalEpoch","firstNormalSlot","$c3af9e523501759a$var$GetLeaderScheduleResult","record","$c3af9e523501759a$var$TransactionErrorResult","$c3af9e523501759a$var$SignatureStatusResult","$c3af9e523501759a$var$SignatureReceivedResult","$c3af9e523501759a$var$ParsedInstructionStruct","$c3af9e523501759a$var$PartiallyDecodedInstructionStruct","rentEpoch","unitsConsumed","returnData","innerInstructions","byIdentity","firstSlot","lastSlot","circulating","nonCirculating","nonCirculatingAccounts","$c3af9e523501759a$var$TokenAmountResult","uiAmount","decimals","uiAmountString","$c3af9e523501759a$var$ParsedAccountDataResult","$c3af9e523501759a$var$AccountInfoResult","$c3af9e523501759a$var$ParsedOrRawAccountData","$c3af9e523501759a$var$ParsedAccountInfoResult","active","inactive","memo","blockTime","subscription","$c3af9e523501759a$var$ProgramAccountInfoResult","$c3af9e523501759a$var$SlotInfoResult","parent","root","$c3af9e523501759a$var$SlotUpdateResult","timestamp","stats","numTransactionEntries","numSuccessfulTransactions","numFailedTransactions","maxTransactionsPerEntry","gossip","tpu","rpc","$c3af9e523501759a$var$VoteAccountInfoResult","votePubkey","nodePubkey","activatedStake","epochVoteAccount","epochCredits","lastVote","rootSlot","current","delinquent","$c3af9e523501759a$var$ConfirmationStatus","$c3af9e523501759a$var$SignatureStatusResponse","confirmations","confirmationStatus","$c3af9e523501759a$var$AddressTableLookupStruct","$c3af9e523501759a$var$ConfirmedTransactionResult","$c3af9e523501759a$var$AnnotatedAccountKey","source","$c3af9e523501759a$var$ConfirmedTransactionAccountsModeResult","$c3af9e523501759a$var$ParsedInstructionResult","$c3af9e523501759a$var$RawInstructionResult","$c3af9e523501759a$var$InstructionResult","$c3af9e523501759a$var$UnknownInstructionResult","$c3af9e523501759a$var$ParsedOrRawInstruction","$c3af9e523501759a$var$ParsedConfirmedTransactionResult","$c3af9e523501759a$var$TokenBalanceResult","accountIndex","mint","uiTokenAmount","$c3af9e523501759a$var$LoadedAddressesResult","$c3af9e523501759a$var$ConfirmedTransactionMetaResult","fee","preBalances","postBalances","preTokenBalances","postTokenBalances","loadedAddresses","computeUnitsConsumed","$c3af9e523501759a$var$ParsedConfirmedTransactionMetaResult","$c3af9e523501759a$var$TransactionVersionStruct","$c3af9e523501759a$var$RewardsResult","rewardType","previousBlockhash","parentSlot","rewards","$c3af9e523501759a$var$PerfSampleResult","numTransactions","numSlots","samplePeriodSecs","feeCalculator","lamportsPerSignature","$c3af9e523501759a$var$LogsResult","$c3af9e523501759a$export$c53bca448cf33676","keypair","_keypair","generate","fromSecretKey","skipValidation","computedPublicKey","ii","fromSeed","CreateLookupTable","FreezeLookupTable","ExtendLookupTable","DeactivateLookupTable","CloseLookupTable","RequestUnits","RequestHeapFrame","SetComputeUnitLimit","SetComputeUnitPrice","$c3af9e523501759a$var$ED25519_INSTRUCTION_LAYOUT","u16","$c3af9e523501759a$export$e5087aea02631e","createInstructionWithPublicKey","instructionIndex","publicKeyOffset","signatureOffset","messageDataOffset","instructionData","numSignatures","padding","signatureInstructionIndex","publicKeyInstructionIndex","messageDataSize","messageInstructionIndex","createInstructionWithPrivateKey","privateKey","$c3af9e523501759a$var$ecdsaSign","msgHash","privKey","secp256k1","toCompactRawBytes","recovery","isValidPrivateKey","$c3af9e523501759a$var$publicKeyCreate","$c3af9e523501759a$var$SECP256K1_INSTRUCTION_LAYOUT","$c3af9e523501759a$export$d85dd4c1161d13c9","publicKeyToEthAddress","keccak_256","recoveryId","createInstructionWithEthAddress","ethAddress","rawAddress","startsWith","dataStart","ethAddressOffset","ethAddressInstructionIndex","pkey","messageHash","$c3af9e523501759a$export$18aac71979bdd08f","$c3af9e523501759a$export$e7f3941ade35598c","unixTimestamp","custodian","$c3af9e523501759a$export$c89793bd2bba8b2e","Initialize","$c3af9e523501759a$var$authorized","$c3af9e523501759a$var$lockup","Authorize","Delegate","Split","Withdraw","Deactivate","Merge","AuthorizeWithSeed","Staker","Withdrawer","$c3af9e523501759a$export$df86f933e9f8fb15","initialize","stakePubkey","lockup","maybeLockup","staker","withdrawer","delegate","authorize","stakeAuthorizationType","custodianPubkey","newAuthorized","authorizeWithSeed","authorityBase","authoritySeed","authorityOwner","splitInstruction","splitStakePubkey","rentExemptReserve","splitWithSeed","merge","sourceStakePubKey","withdraw","deactivate","$c3af9e523501759a$var$VOTE_INSTRUCTION_LAYOUTS","InitializeAccount","$c3af9e523501759a$var$voteInit","UpdateValidatorIdentity","$c3af9e523501759a$var$voteAuthorizeWithSeedArgs","Voter","$c3af9e523501759a$export$83db2bc702bee1eb","initializeAccount","voteInit","authorizedVoter","authorizedWithdrawer","voteAuthorizationType","currentAuthorityDerivedKeyBasePubkey","currentAuthorityDerivedKeyOwnerPubkey","currentAuthorityDerivedKeySeed","voteAuthorizeWithSeedArgs","authorizedWithdrawerPubkey","safeWithdraw","currentVoteAccountBalance","rentExemptMinimum","updateValidatorIdentity","website","details","iconUrl","keybaseUsername","hash_to_ristretto255","hashToRistretto255","RistrettoPoint","encodeToCurve","hashToCurve","edwardsToMontgomery","x25519","ed25519ph","ed25519ctx","ED25519_TORSION_SUBGROUP","edwardsToMontgomeryPub","$f07bd5acd6595f86$var$edwardsToMontgomeryPub","edwardsToMontgomeryPriv","edwardsPriv","hashed","$f07bd5acd6595f86$var$ed25519Defaults","hash","adjustScalarBytes","$3dtER","$3Bcdj","$lkFCe","$qoWOx","$rkPJ6","$2D9sF","$kiLeO","$esaJO","$f07bd5acd6595f86$var$ED25519_P","$f07bd5acd6595f86$var$ED25519_SQRT_M1","$f07bd5acd6595f86$var$_0n","$f07bd5acd6595f86$var$_1n","$f07bd5acd6595f86$var$_2n","$f07bd5acd6595f86$var$_3n","$f07bd5acd6595f86$var$_5n","$f07bd5acd6595f86$var$_8n","$f07bd5acd6595f86$var$ed25519_pow_2_252_3","_10n","_20n","_40n","_80n","b2","x2","b4","pow2","b5","b10","b20","b40","b80","b160","b240","b250","pow_p_5_8","$f07bd5acd6595f86$var$adjustScalarBytes","$f07bd5acd6595f86$var$uvRatio","u","v3","mod","vx2","root1","root2","useRoot1","useRoot2","noRoot","isNegativeLE","isValid","$f07bd5acd6595f86$var$Fp","Field","Fp","h","Gx","Gy","sha512","randomBytes","uvRatio","$f07bd5acd6595f86$var$ed25519_domain","ctx","phflag","concatBytes","utf8ToBytes","edwardsPub","_1n","inv","twistedEdwards","domain","prehash","montgomery","P","montgomeryBits","nByteLength","Gu","powPminus2","$f07bd5acd6595f86$var$ELL2_C1","ORDER","$f07bd5acd6595f86$var$ELL2_C2","$f07bd5acd6595f86$var$ELL2_C3","sqrt","neg","ONE","$f07bd5acd6595f86$var$ELL2_C1_EDWARDS","FpSqrtEven","$f07bd5acd6595f86$var$htf","createHasher","scalars","$f07bd5acd6595f86$var$map_to_curve_elligator2_edwards25519","xMn","xMd","yMn","yMd","$f07bd5acd6595f86$var$map_to_curve_elligator2_curve25519","ELL2_C4","ELL2_J","tv1","sqr","xd","x1n","tv2","gxd","gx1","tv3","y11","y12","e1","eql","y1","cmov","x2n","y21","y22","gx2","e2","y2","e3","xn","e4","isOdd","yn","yd","ZERO","invertBatch","DST","encodeDST","k","expand","$f07bd5acd6595f86$var$assertRstPoint","other","$f07bd5acd6595f86$var$RistPoint","$f07bd5acd6595f86$var$SQRT_AD_MINUS_ONE","$f07bd5acd6595f86$var$INVSQRT_A_MINUS_D","$f07bd5acd6595f86$var$ONE_MINUS_D_SQ","$f07bd5acd6595f86$var$D_MINUS_ONE_SQ","$f07bd5acd6595f86$var$invertSqrt","$f07bd5acd6595f86$var$MAX_255B","$f07bd5acd6595f86$var$bytes255ToNumberLE","CURVE","bytesToNumberLE","$f07bd5acd6595f86$var$calcElligatorRistrettoMap","r0","r","$f07bd5acd6595f86$var$SQRT_M1","Ns","D","Ns_D_is_sq","s_","Nt","s2","W0","W1","W2","W3","ep","fromAffine","ap","hex","R1","ensureBytes","R2","emsg","equalBytes","numberToBytesLE","u1","u2","u1_2","u2_2","I","Dx","Dy","t","msm","points","Fn","nBitLength","pippenger","toRawBytes","ex","ey","ez","z","et","u2sq","invsqrt","D1","D2","zInv","_x","_y","toHex","bytesToHex","X1","Y1","X2","Y2","one","two","subtract","multiply","scalar","multiplyUnsafe","double","negate","BASE","uniform_bytes","expand_message_xmd","sha384","sha512_256","sha512_224","SHA384","SHA512_256","SHA512_224","SHA512","$iYRTw","$eDgKs","$2579977b4e52adba$var$SHA512_Kh","$2579977b4e52adba$var$SHA512_Kl","$2579977b4e52adba$var$SHA512_W_H","Uint32Array","$2579977b4e52adba$var$SHA512_W_L","$2579977b4e52adba$var$SHA512","HashMD","Ah","Al","Bh","Bl","Ch","Cl","Dh","Dl","Eh","El","Fh","Fl","Gh","Gl","Hh","Hl","process","view","getUint32","W15h","W15l","s0h","rotrSH","shrSH","s0l","rotrSL","shrSL","W2h","W2l","s1h","rotrBH","s1l","rotrBL","SUMl","add4L","SUMh","add4H","sigma1h","sigma1l","CHIh","CHIl","T1ll","add5L","T1h","add5H","T1l","sigma0h","sigma0l","MAJh","MAJl","l","All","add3L","add3H","roundClean","destroy","$2579977b4e52adba$var$SHA512_224","outputLen","$2579977b4e52adba$var$SHA512_256","$2579977b4e52adba$var$SHA384","wrapConstructor","setBigUint64","$dd17a2ee919821c7$var$setBigUint64","Chi","Maj","$dNiq9","_32n","_u32_max","wh","wl","setUint32","$dd17a2ee919821c7$var$HashMD","Hash","blockLen","padOffset","finished","destroyed","createView","update","aexists","take","dataView","digestInto","aoutput","oview","outLen","digest","_cloneInto","to","$a0ae23f5901291b4$var$anumber","isSafeInteger","$a0ae23f5901291b4$var$abytes","lengths","anumber","abytes","ahash","checkFinished","nextTick","byteSwapIfBE","isBytes","DataView","rotr","word","rotl","byteSwap","$29ee4d3171d9809b$var$byteSwap","byteSwap32","$29ee4d3171d9809b$var$hexes","hexToBytes","hl","al","ai","n1","$29ee4d3171d9809b$var$asciiToBase16","n2","asyncLoop","$29ee4d3171d9809b$var$asyncLoop","$29ee4d3171d9809b$var$utf8ToBytes","$29ee4d3171d9809b$var$toBytes","arrays","sum","pad","checkOpts","defaults","hashCons","hashC","wrapConstructorWithOpts","wrapXOFConstructorWithOpts","$dUxV2","crypto","getRandomValues","padStart","$29ee4d3171d9809b$var$asciis","_0","_9","A","F","f","ch","$29ee4d3171d9809b$var$nextTick","iters","tick","cb","ts","Date","now","diff","TextEncoder","clone","rotlBL","rotlBH","rotlSL","rotlSH","rotr32L","rotr32H","toBig","fromBig","$aa71b30d36adb919$var$fromBig","$aa71b30d36adb919$var$split","$aa71b30d36adb919$var$add","$aa71b30d36adb919$var$U32_MASK64","$aa71b30d36adb919$var$_32n","le","lst","$aa71b30d36adb919$var$toBig","$aa71b30d36adb919$var$shrSH","_l","$aa71b30d36adb919$var$shrSL","$aa71b30d36adb919$var$rotrSH","$aa71b30d36adb919$var$rotrSL","$aa71b30d36adb919$var$rotrBH","$aa71b30d36adb919$var$rotrBL","$aa71b30d36adb919$var$rotr32H","_h","$aa71b30d36adb919$var$rotr32L","$aa71b30d36adb919$var$rotlSH","$aa71b30d36adb919$var$rotlSL","$aa71b30d36adb919$var$rotlBH","$aa71b30d36adb919$var$rotlBL","$aa71b30d36adb919$var$add3L","$aa71b30d36adb919$var$add3H","low","$aa71b30d36adb919$var$add4L","$aa71b30d36adb919$var$add4H","$aa71b30d36adb919$var$add5L","$aa71b30d36adb919$var$add5H","wNAF","bits","constTimeNegate","hasPrecomputes","elm","getW","unsafeLadder","_0n","precomputeWindow","W","windows","windowSize","calcWOpts","window","precomputes","mask","maxNumber","shiftBy","wbits","offset2","cond1","cond2","wNAFUnsafe","acc","curr","getPrecomputes","transform","comp","pointPrecomputes","wNAFCached","wNAFCachedUnsafe","prev","setWindowSize","validateW","pointWindowSizes","fieldN","validateMSMPoints","validateMSMScalars","zero","bitLen","MASK","buckets","lastBits","BITS","resI","sumI","precomputeMSMUnsafe","tableSize","chunks","tables","validateBasic","curve","validateField","validateObject","nLength","WeakMap","$1ea6901afdde618b$var$mod","$1ea6901afdde618b$var$pow","power","modulo","$1ea6901afdde618b$var$_0n","invert","$1ea6901afdde618b$var$invert","tonelliShanks","$1ea6901afdde618b$var$tonelliShanks","FpSqrt","$1ea6901afdde618b$var$FpSqrt","$1ea6901afdde618b$var$FIELD_FIELDS","BYTES","FpPow","$1ea6901afdde618b$var$FpPow","FpInvertBatch","$1ea6901afdde618b$var$FpInvertBatch","FpDiv","lhs","rhs","FpLegendre","$1ea6901afdde618b$var$FpLegendre","FpIsSquare","legendre","$1ea6901afdde618b$var$nLength","redef","sqrtP","bitMask","$1ea6901afdde618b$var$_1n","is0","div","sqrN","addN","subN","mulN","numberToBytesBE","fromBytes","bytesToNumberBE","FpSqrtOdd","hashToPrivateScalar","groupOrder","hashLen","minLen","getFieldBytesLength","$1ea6901afdde618b$var$getFieldBytesLength","getMinHashLength","$1ea6901afdde618b$var$getMinHashLength","mapHashToField","fieldOrder","fieldLen","reduced","$1ea6901afdde618b$var$_2n","$1ea6901afdde618b$var$_3n","$1ea6901afdde618b$var$_4n","$1ea6901afdde618b$var$_5n","$1ea6901afdde618b$var$_8n","q","gcd","Q","S","Z","legendreC","p1div4","Q1div2","g","t2","ge","c1","nv","nums","lastMultiplied","inverted","reduceRight","order","legendreConst","_nBitLength","bitLength","notImplemented","$a85c028f110aa8ce$var$isBytes","$a85c028f110aa8ce$var$abytes","abool","title","$a85c028f110aa8ce$var$bytesToHex","numberToHexUnpadded","$a85c028f110aa8ce$var$numberToHexUnpadded","hexToNumber","$a85c028f110aa8ce$var$hexToNumber","$a85c028f110aa8ce$var$hexToBytes","reverse","$a85c028f110aa8ce$var$numberToBytesBE","numberToVarBytesBE","expectedLength","$a85c028f110aa8ce$var$concatBytes","inRange","$a85c028f110aa8ce$var$inRange","aInRange","$a85c028f110aa8ce$var$_0n","$a85c028f110aa8ce$var$_1n","bitGet","bitSet","createHmacDrbg","qByteLen","hmacFn","$a85c028f110aa8ce$var$u8n","reset","reseed","$a85c028f110aa8ce$var$u8fr","gen","sl","pred","object","validators","optValidators","checkField","fieldName","isOptional","checkVal","$a85c028f110aa8ce$var$validatorFns","memoized","computed","$a85c028f110aa8ce$var$_2n","$a85c028f110aa8ce$var$hexes","$a85c028f110aa8ce$var$asciis","$a85c028f110aa8ce$var$asciiToBase16","$a85c028f110aa8ce$var$isPosBig","bigint","function","stringOrUint8Array","curveDef","$04f5c7e644575b38$var$validateOpts","mapToCurve","CURVE_ORDER","cHash","cofactor","$04f5c7e644575b38$var$_2n","$04f5c7e644575b38$var$_1n","modP","$04f5c7e644575b38$var$_0n","aCoordinate","assertPoint","Point","toAffineMemo","iz","$04f5c7e644575b38$var$_8n","ax","ay","zz","assertValidMemo","X","Y","T","Z2","Z4","aX2","left","XY","toAffine","normalizeZ","toInv","_setWindowSize","wnaf","assertValidity","Z1","X1Z2","X2Z1","Y1Z2","Y2Z1","B","C","x1y1","E","G","H","X3","Y3","T3","T1","T2","isSmallOrder","isTorsionFree","clearCofactor","zip215","normed","lastByte","isXOdd","isLastByteOdd","fromPrivateKey","getExtendedPublicKey","point","modN","modN_LE","head","pointBytes","hashDomainToScalar","msgs","R","sig","$04f5c7e644575b38$var$VERIFY_DEFAULT","SB","RkA","precompute","$0522aeca5769187c$var$expand_message_xmd","expand_message_xof","$0522aeca5769187c$var$expand_message_xof","hash_to_field","$0522aeca5769187c$var$hash_to_field","isogenyMap","COEFF","xNum","xDen","yNum","yDen","def","u0","$0522aeca5769187c$var$os2ip","$0522aeca5769187c$var$i2osp","$0522aeca5769187c$var$anum","lenInBytes","b_in_bytes","r_in_bytes","ell","DST_prime","Z_pad","l_i_b_str","b_0","$0522aeca5769187c$var$strxor","pseudo_random_bytes","dkLen","prb","_DST","L","log2p","len_in_bytes","elm_offset","tv","montgomeryBytes","cswap","swap","x_2","x_3","dummy","a24","encodeUCoordinate","scalarMult","pu","montgomeryLadder","sw","$ec7a218c4f0875a8$var$_0n","$ec7a218c4f0875a8$var$_1n","z_2","z_3","k_t","AA","BB","DA","CB","dacb","da_cb","x_1","decodeUCoordinate","uEnc","decodeScalar","GuBytes","scalarMultBase","getSharedSecret","module1","assert","inherits","ctor","superCtor","super_","TempCtor","BN","endian","isBN","negative","words","red","_init","wordSize","parseHex4Bits","parseHexByte","lowerBound","parseBase","move","dest","right","cmp","_initNumber","_initArray","_parseHex","_parseBase","toArray","w","off","_strip","parseLength","limbLen","limbPow","imuln","_iaddn","_move","_expand","_normSign","for","zeros","groupSizes","groupBases","smallMulTo","self","carry","ncarry","rword","maxJ","groupSize","groupBase","isZero","modrn","idivn","toNumber","ArrayType","reqLength","_toArrayLikeLE","position","_toArrayLikeBE","clz32","_countBits","_zeroBits","zeroBits","toTwos","width","inotn","iaddn","fromTwos","testn","notn","ineg","isNeg","iuor","ior","or","uor","iuand","iand","and","uand","iuxor","ixor","xor","uxor","bytesNeeded","bitsLeft","setn","bit","wbit","iadd","isub","comb10MulTo","mid","o","a0","al0","ah0","a1","al1","ah1","a2","al2","ah2","a3","al3","ah3","a4","al4","ah4","a5","al5","ah5","a6","al6","ah6","a7","al7","ah7","a8","al8","ah8","a9","al9","ah9","b0","bl0","bh0","b1","bl1","bh1","bl2","bh2","b3","bl3","bh3","bl4","bh4","bl5","bh5","b6","bl6","bh6","b7","bl7","bh7","b8","bl8","bh8","b9","bl9","bh9","w0","imul","w1","w2","w3","w4","w5","w6","w7","w8","w9","w10","w11","w12","w13","w14","w15","w16","w17","w18","bigMulTo","hncarry","FFTM","mulTo","makeRBT","N","revBin","rb","permute","rbt","rws","iws","rtws","itws","rtwdf","cos","PI","itwdf","sin","rtwdf_","itwdf_","re","ie","ro","io","rx","guessLen13b","odd","conjugate","normalize13b","ws","convert13b","stub","ph","mulp","rwst","iwst","nrws","nrwst","niwst","rmws","mulf","isNegNum","muln","isqr","toBitArray","iushln","carryMask","newCarry","ishln","iushrn","hint","extended","maskedWords","ishrn","shln","ushln","shrn","ushrn","imaskn","maskn","isubn","addn","subn","iabs","_ishlnsubmul","_wordDiv","mode","bhi","qj","divmod","positive","divn","umod","divRound","dm","half","r2","andln","modn","egcd","isEven","yp","xp","im","jm","_invmp","x1","delta","cmpn","invm","bincn","ucmp","gtn","gt","gten","gte","ltn","lt","lten","lte","eqn","Red","toRed","convertTo","_forceRed","fromRed","convertFrom","forceRed","redAdd","redIAdd","redSub","redISub","redShl","shl","redMul","_verify2","redIMul","redSqr","_verify1","redISqr","redSqrt","redInvm","redNeg","redPow","primes","k256","p224","p192","p25519","MPrime","_tmp","K256","P224","P192","P25519","prime","_prime","Mont","imod","rinv","minv","ireduce","rlen","imulK","strip","next","mod3","nOne","lpow","wnd","currentLen","mont","$0DhcF","$001e77b0dfd1bf3d$require$_Buffer","$1U9GM","ALPHABET","BASE_MAP","charAt","xc","LEADER","FACTOR","iFACTOR","decodeUnsafe","psz","zeroes","b256","it3","it4","vch","pbegin","pend","b58","it1","it2","repeat","$1632896ed805433d$var$Buffer","$1632896ed805433d$var$copyProps","$1632896ed805433d$var$SafeBuffer","SlowBuffer","sha224","SHA256","$510ad3657d73a9d2$var$SHA256_K","$510ad3657d73a9d2$var$SHA256_IV","$510ad3657d73a9d2$var$SHA256_W","$510ad3657d73a9d2$var$SHA256","W15","s0","s1","sigma0","$510ad3657d73a9d2$var$SHA224","$5296450c35a171ab$require$Buffer","$5296450c35a171ab$var$__createBinding","__createBinding","k2","$5296450c35a171ab$var$__setModuleDefault","__setModuleDefault","$5296450c35a171ab$var$__decorate","__decorate","decorators","desc","getOwnPropertyDescriptor","Reflect","decorate","$5296450c35a171ab$var$__importStar","__importStar","$5296450c35a171ab$var$__importDefault","__importDefault","BinaryReader","BinaryWriter","BorshError","baseDecode","baseEncode","$5296450c35a171ab$var$bn_js_1","$5296450c35a171ab$var$bs58_1","$5296450c35a171ab$var$encoding","$5296450c35a171ab$var$textDecoder","TextDecoder","fatal","$5296450c35a171ab$var$BorshError","fieldPath","originalMessage","addToFieldPath","$5296450c35a171ab$var$BinaryWriter","maybeResize","writeU8","writeU16","writeU32","writeU64","writeBuffer","writeU128","writeU256","writeU512","writeString","writeFixedArray","writeArray","$5296450c35a171ab$var$handlingRangeError","propertyKey","propertyDescriptor","originalMethod","$5296450c35a171ab$var$BinaryReader","readU8","readU16","readU32","readU64","readBuffer","readU128","readU256","readU512","readString","readFixedArray","readArray","$5296450c35a171ab$var$capitalizeFirstLetter","toUpperCase","$5296450c35a171ab$var$serializeField","fieldType","writer","$5296450c35a171ab$var$serializeStruct","borshSerialize","structSchema","idx","$5296450c35a171ab$var$deserializeField","reader","$5296450c35a171ab$var$deserializeStruct","classType","borshDeserialize","fieldValue","Writer","Reader","$f260af419b27244f$var$inRange","$f260af419b27244f$var$ToDictionary","$f260af419b27244f$var$Stream","tokens","$f260af419b27244f$var$decoderError","opt_code_point","$f260af419b27244f$export$88fb0cfd153261a7","$f260af419b27244f$export$9c6b53e35bc51b5c","endOfStream","prepend","token","pop","$f260af419b27244f$var$DEFAULT_ENCODING","$f260af419b27244f$var$TextDecoder","_streaming","_BOMseen","_decoder","_fatal","Boolean","_ignoreBOM","$f260af419b27244f$var$TextEncoder","_encoder","_options","$f260af419b27244f$var$UTF8Decoder","utf8_code_point","utf8_bytes_seen","utf8_bytes_needed","utf8_lower_boundary","utf8_upper_boundary","handler","stream","bite","code_point","$f260af419b27244f$var$UTF8Encoder","temp","input_stream","code_points","$f260af419b27244f$var$codePointsToString","cp","opt_string","$f260af419b27244f$var$stringToCodePoints","s16","s8","nu64be","u48be","u40be","u32be","u24be","u16be","u48","u40","u24","greedy","Constant","UTF8","CString","Blob","BitField","BitStructure","VariantLayout","Union","UnionLayoutDiscriminator","UnionDiscriminator","Structure","Sequence","DoubleBE","Double","FloatBE","Float","NearInt64BE","NearInt64","NearUInt64BE","NearUInt64","IntBE","Int","UIntBE","UInt","OffsetLayout","GreedyCount","ExternalLayout","bindConstructorLayout","nameWithProperty","Layout","uint8ArrayToBuffer","checkUint8Array","constant","utf8","cstr","unionLayoutDiscriminator","f64be","f64","f32be","f32","ns64be","s48be","s40be","s32be","s24be","s16be","s48","s40","s32","s24","$09c4e3f7de797447$var$checkUint8Array","$09c4e3f7de797447$var$uint8ArrayToBuffer","$09c4e3f7de797447$var$Layout","makeDestinationObject","getSpan","replicate","rv","fromArray","$09c4e3f7de797447$var$nameWithProperty","Class","layout_","boundConstructor_","$09c4e3f7de797447$var$ExternalLayout","isCount","$09c4e3f7de797447$var$GreedyCount","elementSpan","rem","$09c4e3f7de797447$var$OffsetLayout","$09c4e3f7de797447$var$UInt","$09c4e3f7de797447$var$UIntBE","$09c4e3f7de797447$var$Int","$09c4e3f7de797447$var$IntBE","$09c4e3f7de797447$var$divmodInt64","hi32","lo32","$09c4e3f7de797447$var$roundedInt64","$09c4e3f7de797447$var$NearUInt64","$09c4e3f7de797447$var$NearUInt64BE","$09c4e3f7de797447$var$NearInt64","$09c4e3f7de797447$var$NearInt64BE","$09c4e3f7de797447$var$Float","$09c4e3f7de797447$var$FloatBE","$09c4e3f7de797447$var$Double","$09c4e3f7de797447$var$DoubleBE","$09c4e3f7de797447$var$Sequence","elo","$09c4e3f7de797447$var$Structure","decodePrefixes","fd","fsp","firstOffset","lastOffset","lastWrote","fv","layoutFor","offsetOf","$09c4e3f7de797447$var$UnionDiscriminator","$09c4e3f7de797447$var$UnionLayoutDiscriminator","$09c4e3f7de797447$var$Union","discr","defaultLayout","discriminator","usesPrefixDiscriminator","registry","boundGetSourceVariant","defaultGetSourceVariant","getSourceVariant","configGetSourceVariant","gsv","vlo","getVariant","tag","dlo","clo","contentOffset","addVariant","variant","$09c4e3f7de797447$var$VariantLayout","vb","$09c4e3f7de797447$var$fixBitwiseResult","$09c4e3f7de797447$var$BitStructure","msb","_packedSetValue","_packedGetValue","addField","bf","$09c4e3f7de797447$var$BitField","addBoolean","$09c4e3f7de797447$var$Boolean","fieldFor","container","totalBits","usedBits","valueMask","wordMask","wordValue","$09c4e3f7de797447$var$Blob","srcBuffer","$09c4e3f7de797447$var$CString","srcb","$09c4e3f7de797447$var$UTF8","maxSpan","$09c4e3f7de797447$var$Constant","$c0e94fe1a84d811b$require$Buffer","reversed","toBigIntBE","toBufferBE","$d36cd0d29f3bcaa8$export$a7a9523472993e97","$d36cd0d29f3bcaa8$export$185802fd694ee1f5","$d36cd0d29f3bcaa8$export$bf9fb029d174d554","$d36cd0d29f3bcaa8$export$516e28dec6a4b6d4","$d36cd0d29f3bcaa8$export$4154a199d7d90455","$d36cd0d29f3bcaa8$export$2f23118c22fb2630","$d36cd0d29f3bcaa8$export$4a21f16c33752377","$d36cd0d29f3bcaa8$export$9544d5bb712b01ea","$d36cd0d29f3bcaa8$export$c8ec6e1ec9fefcb0","$d36cd0d29f3bcaa8$export$133fc36489ac9add","$d36cd0d29f3bcaa8$export$98e628dec113755e","$d36cd0d29f3bcaa8$export$e5185e241753e543","$d36cd0d29f3bcaa8$export$22b082955e083ec3","$d36cd0d29f3bcaa8$export$65e3907585753458","$d36cd0d29f3bcaa8$export$971dd5b0dfd021b6","$d36cd0d29f3bcaa8$export$19282c40b967aec6","$d36cd0d29f3bcaa8$export$8c14e57e778d3873","$d36cd0d29f3bcaa8$export$58cc9131e3e8861b","failure","failures","cached","explanation","rest","cause","$d36cd0d29f3bcaa8$var$isObject","$d36cd0d29f3bcaa8$var$isNonArrayObject","$d36cd0d29f3bcaa8$var$print","$d36cd0d29f3bcaa8$var$toFailures","iterator","$d36cd0d29f3bcaa8$var$toFailure","branch","refinement","$d36cd0d29f3bcaa8$var$run","coercer","refiner","$d36cd0d29f3bcaa8$export$eabc71f011df675a","props","is","$d36cd0d29f3bcaa8$export$a22775fa5e2eebd9","$d36cd0d29f3bcaa8$export$d99f0801a68bbcf1","validate","tuples","$d36cd0d29f3bcaa8$var$shiftIterator","done","$d36cd0d29f3bcaa8$export$f36d6a7a5c09a23e","Element","description","Key","Value","Structs","Never","coerced","$d36cd0d29f3bcaa8$export$226b3eccf92c9ed9","$5647400503806718$require$uuid","$7XmlK","$4kTUs","$5647400503806718$var$ClientBrowser","callServer","reviver","replacer","generator","notificationIdNull","request","method","callback","isBatch","isRaw","hasCallback","response","_parseResponse","responseText","parse","isError","$5caf614dfdadbbf1$export$2e2bcd8739ae039","$8vELy","$pdSq5","rnds","random","rng","$6320d7442e1ae600$export$2e2bcd8739ae039","$6320d7442e1ae600$var$getRandomValues","$6320d7442e1ae600$var$rnds8","msCrypto","$04bd198b9afd43e8$export$2e2bcd8739ae039","$e7Drt","$04bd198b9afd43e8$var$byteToHex","$04bd198b9afd43e8$var$i","uuid","$a480508add5e3ec9$export$2e2bcd8739ae039","$gnfHI","test","$bebaf9d4e743910c$export$2e2bcd8739ae039","$3284662ae09c2cc1$require$uuid","$c01611184c7492cd$export$3909fb301d3dc8c9","$c01611184c7492cd$export$b43a6d9568fa5272","$3hOXp","$c01611184c7492cd$var$WebSocketBrowserImpl","EventEmitter","socket","protocols","WebSocket","onopen","emit","onmessage","event","onerror","onclose","reason","send","optionsOrCallback","close","addEventListener","listener","$c01611184c7492cd$export$9fd32f4b4353d82d","rpc_id","queue","autoconnect","ready","reconnect","reconnect_timer_id","reconnect_interval","max_reconnects","rest_options","current_reconnects","generate_request_id","webSocketFactory","dataPack","_connect","connect","timeout","ws_opts","promise","login","resp","listMethods","notify","subscribe","unsubscribe","setAutoReconnect","setReconnectInterval","interval","setMaxReconnects","clearTimeout","notification","listeners","$264a7caaf26e2751$var$has","$264a7caaf26e2751$var$prefix","$264a7caaf26e2751$var$Events","$264a7caaf26e2751$var$EE","once","$264a7caaf26e2751$var$addListener","emitter","evt","_events","_eventsCount","$264a7caaf26e2751$var$clearEvent","$264a7caaf26e2751$var$EventEmitter","__proto__","eventNames","events","names","getOwnPropertySymbols","handlers","ee","listenerCount","removeListener","on","removeAllListeners","addListener","prefixed","shake256","shake128","keccak_512","keccak_384","keccak_224","sha3_512","sha3_384","sha3_256","sha3_224","Keccak","keccakP","$08748f983f07956b$var$keccakP","$08748f983f07956b$var$SHA3_PI","$08748f983f07956b$var$SHA3_ROTL","$08748f983f07956b$var$_SHA3_IOTA","$08748f983f07956b$var$_0n","$08748f983f07956b$var$_1n","$08748f983f07956b$var$_2n","$08748f983f07956b$var$_7n","$08748f983f07956b$var$_256n","$08748f983f07956b$var$_0x71n","$08748f983f07956b$var$SHA3_IOTA_H","$08748f983f07956b$var$SHA3_IOTA_L","$08748f983f07956b$var$rotlH","$08748f983f07956b$var$rotlL","rounds","idx1","idx0","B0","B1","Th","Tl","curH","curL","$08748f983f07956b$var$Keccak","suffix","enableXOF","posOut","state32","keccak","finish","writeInto","bufferOut","xofInto","xof","$08748f983f07956b$var$gen","$08748f983f07956b$var$genShake","schnorr","$7OcHe","$gNPqy","$3f551179096121b9$var$secp256k1P","$3f551179096121b9$var$secp256k1N","$3f551179096121b9$var$_1n","$3f551179096121b9$var$_2n","$3f551179096121b9$var$divNearest","$3f551179096121b9$var$sqrtMod","_3n","_6n","_11n","_22n","_23n","_44n","_88n","b11","b22","b44","b88","b176","b220","b223","t1","$3f551179096121b9$var$Fpk1","createCurve","lowS","endo","beta","splitScalar","POW_2_128","c2","k1","k1neg","k2neg","$3f551179096121b9$var$_0n","$3f551179096121b9$var$TAGGED_HASH_PREFIXES","$3f551179096121b9$var$taggedHash","messages","tagP","tagH","$3f551179096121b9$var$pointToBytes","$3f551179096121b9$var$numTo32b","$3f551179096121b9$var$modP","$3f551179096121b9$var$modN","$3f551179096121b9$var$Point","ProjectivePoint","$3f551179096121b9$var$GmulAdd","multiplyAndAddUnsafe","$3f551179096121b9$var$schnorrGetExtPubKey","priv","d_","normPrivateKeyToScalar","hasEvenY","$3f551179096121b9$var$lift_x","xx","$3f551179096121b9$var$num","$3f551179096121b9$var$challenge","$3f551179096121b9$var$schnorrVerify","pub","auxRand","px","k_","lift_x","pointToBytes","taggedHash","$3f551179096121b9$var$isoMap","$3f551179096121b9$var$mapSWU","mapToCurveSimpleSWU","$3f551179096121b9$var$htf","getHash","$5af70d1c5fca3e4e$var$getHash","defHash","weierstrass","$70Xw9","hmac","HMAC","$51b6b372898f65c0$var$HMAC","_key","iHash","oHash","getPrototypeOf","DER","DERErr","weierstrassPoints","$c3b91d553ab14e64$var$weierstrassPoints","$c3b91d553ab14e64$var$validateOpts","bits2int","bits2int_modN","compressedLen","uncompressedLen","invN","weierstrassEquation","isWithinCurveOrder","_c","isCompressed","cat","tail","$c3b91d553ab14e64$var$_1n","sqrtError","numToNByteStr","slcNum","Signature","fromCompact","fromDER","toSig","addRecoveryBit","recoverPublicKey","rec","radj","ir","hasHighS","normalizeS","toDERRawBytes","toDERHex","hexFromSig","toCompactHex","isProbPub","ORDER_MASK","int2octets","$c3b91d553ab14e64$var$_0n","defaultSigOpts","defaultVerOpts","privateA","publicB","k2sig","prepSig","extraEntropy","ent","$c3b91d553ab14e64$var$validateSigVerOpts","h1int","seedArgs","kBytes","ik","normS","isBiggerThanHalfOrder","drbg","_sig","format","isHex","isObj","sg","derError","Err","SWUFpSqrtRatio","$c3b91d553ab14e64$var$SWUFpSqrtRatio","sqrtRatio","tv4","tv5","tv6","$c3b91d553ab14e64$var$b2n","$c3b91d553ab14e64$var$h2b","$c3b91d553ab14e64$var$DERErr","_tlv","dataLen","lenLen","lengthBytes","_int","int","tlv","seqBytes","seqLeftBytes","rBytes","rLeftBytes","sBytes","sLeftBytes","rs","ss","$c3b91d553ab14e64$var$_2n","$c3b91d553ab14e64$var$_3n","$c3b91d553ab14e64$var$_4n","$c3b91d553ab14e64$var$validatePointOpts","allowedPrivateKeyLengths","wrapPrivateKey","allowInfinityPoint","_isCompressed","x3","assertPrjPoint","py","pz","U1","U2","Z3","t0","t3","t4","t5","sc","k1p","k2p","fake","f1p","f2p","_bits","_2n_pow_c1_1","_2n_pow_c1","c3","c4","c6","c7","isQR","tvv5","$da368ee8f406d58d$export$dd64f32469f35f81","$5a4be9421d6e6c61$export$22c7939a38084172","$97e08ae06ec466db$export$54187c3796d0ecb","$Gr8vk","url","$28edd11f6c7e9f5f$exports","$28edd11f6c7e9f5f$var$has","$28edd11f6c7e9f5f$var$prefix","$28edd11f6c7e9f5f$var$Events","$28edd11f6c7e9f5f$var$EE","$28edd11f6c7e9f5f$var$addListener","$28edd11f6c7e9f5f$var$clearEvent","$28edd11f6c7e9f5f$var$EventEmitter","$92c515b2e16b5c4e$export$f46ec6f9dba8711d","$92c515b2e16b5c4e$export$d65db264eda99cd7","$92c515b2e16b5c4e$export$9a551f94af9b0bf8","$92c515b2e16b5c4e$export$9525019988612a5e","$92c515b2e16b5c4e$export$38f21f1c810261c7","$92c515b2e16b5c4e$export$bf7028c52ebda81e","$92c515b2e16b5c4e$export$92e2b26fad5723ee","$92c515b2e16b5c4e$export$cd6fa2f8e2a8a612","$92c515b2e16b5c4e$export$735bef3bfb0f2c86","$92c515b2e16b5c4e$export$313d299817c74896","$92c515b2e16b5c4e$export$769332ac3f90f46c","$92c515b2e16b5c4e$export$96f177062fdd8180","$92c515b2e16b5c4e$export$2622c1721bbd4b17","$a27aaf340df890aa$export$2af1ea2892adc469","connected","autoConnect","prepareTransaction","getLatestBlockhash","$a27aaf340df890aa$export$378bae4c88e0b46e","detect","document","disposers","detectAndDispose","dispose","setInterval","clearInterval","readyState","removeEventListener","$a27aaf340df890aa$export$bf89b558d1e273a2","navigator","userAgent","isIos","isSafari","$afa5c06c212ba160$export$37ce1cc82e255d8","$71b3859dfb523e38$export$9a51bf5d1bea9e98","supportedTransactionVersions","rawTransaction","signTransaction","sendRawTransaction","signAllTransactions","signedTransactions","$71b3859dfb523e38$export$9db08bcddd106c96","$gNDby","$35fb31345295b098$export$c094e79b0fad9c07","$35fb31345295b098$export$9c8fcf9b2dfe1d6a","icon","_readyState","Unsupported","NotDetected","_disconnected","wallet","_wallet","_publicKey","_connecting","backpack","isBackpack","Installed","connecting","isConnected","PublicKey","disconnect","signMessage","$27b337e06adc69ec$export$37766f30d842581a","$27b337e06adc69ec$export$a8fff984faa686f6","_accountChanged","newPublicKey","Loadable","phantom","solana","isPhantom","encodeURIComponent","location","href","ref","origin","signAndSendTransaction","$aff560f1983590b4$var$__classPrivateFieldGet","receiver","$aff560f1983590b4$var$__classPrivateFieldSet","$aff560f1983590b4$var$RegisterWalletEvent","Event","detail","bubbles","cancelable","composed","preventDefault","stopImmediatePropagation","stopPropagation","$iJxGt","$7KE4n","$d2raY","$047e59d25887ab3f$var$__classPrivateFieldGet","$047e59d25887ab3f$var$__classPrivateFieldSet","$047e59d25887ab3f$export$b9711d1b27bbdcc","SolflareMetaMaskClass","inputs","standardSignAndSendTransaction","standardSignTransaction","standardSignMessage","chains","features","SolanaSignAndSendTransaction","SolanaSignTransaction","SolanaSignMessage","standardAccounts","WeakSet","existingListener","$44e588f5cc38e309$var$registered","$44e588f5cc38e309$export$2dd247ebd3228ce5","postMessage","onMessage","dispatchEvent","api","$8315e39d7cf92168$export$588524c4690a874f","$8315e39d7cf92168$export$9fd69c70c5f8b9b4","_config","solflare","isSolflare","SolflareApp","SolflareClass","network","$543d6d2a56ed7d8d$require$Buffer","$543d6d2a56ed7d8d$var$walletConnectWallets","$543d6d2a56ed7d8d$var$onReadyStateChange","$543d6d2a56ed7d8d$var$establishEmitter","walletConnectEventElement","CustomEvent","ready_state","$543d6d2a56ed7d8d$var$onConnect","walletConnectedPubKey","public_key","$543d6d2a56ed7d8d$var$onAccountChanged","$543d6d2a56ed7d8d$var$onDisconnect","$543d6d2a56ed7d8d$var$onError","walletConnected","walletsAlert","alert","walletsDetected","adapter","walletsConnect","walletName","walletsDisconnect","walletConnectEventElementName","getElementById","walletsLoad","eventElement","Mainnet","walletsSign","encodedTx","Transaction","serialized","signedTx","generatePrivateKey","generateKeypair","Struct","SOLANA_SCHEMA","Enum","enum","MAX_SEED_LENGTH","PUBLIC_KEY_LENGTH","isPublicKeyData","uniquePublicKeyCounter","bs58","_PublicKey","Account","_secretKey","secretKeyBuffer","BPF_LOADER_DEPRECATED_PROGRAM_ID","PACKET_DATA_SIZE","VERSION_PREFIX_MASK","SIGNATURE_LENGTH_IN_BYTES","TransactionExpiredBlockheightExceededError","TransactionExpiredTimeoutError","TransactionExpiredNonceInvalidError","MessageAccountKeys","BufferLayout","rustString","getAlloc","decodeLength","encodeLength","CompiledKeys","END_OF_BUFFER_ERROR_MESSAGE","guardedShift","guardedSplice","Message","numWritableSignedAccounts","shortvec","messageArgs","MessageV0","numWritableLookupAccountKeys","lookupTableAccounts","MESSAGE_VERSION_0_PREFIX","VersionedMessage","TransactionStatus","DEFAULT_SIGNATURE","TransactionInstruction","invariant","valid","signatureErrors","TransactionMessage","decompile","compiledIx","compileToLegacyMessage","compileToV0Message","VersionedTransaction","NUM_TICKS_PER_SECOND","DEFAULT_TICKS_PER_SLOT","NUM_SLOTS_PER_SECOND","MS_PER_SLOT","SYSVAR_CLOCK_PUBKEY","SYSVAR_EPOCH_SCHEDULE_PUBKEY","SYSVAR_INSTRUCTIONS_PUBKEY","SYSVAR_RECENT_BLOCKHASHES_PUBKEY","SYSVAR_RENT_PUBKEY","SYSVAR_REWARDS_PUBKEY","SYSVAR_SLOT_HASHES_PUBKEY","SYSVAR_SLOT_HISTORY_PUBKEY","SYSVAR_STAKE_HISTORY_PUBKEY","SendTransactionError","SolanaJSONRPCErrorCode","JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP","JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE","JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE","JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE","JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY","JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE","JSON_RPC_SERVER_ERROR_SLOT_SKIPPED","JSON_RPC_SERVER_ERROR_NO_SNAPSHOT","JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED","JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX","JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE","JSON_RPC_SCAN_ERROR","JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH","JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET","JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION","JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED","SolanaJSONRPCError","customMessage","sendAndConfirmTransaction","sleep","ms","encodeData","decodeData","FeeCalculatorLayout","NonceAccountLayout","NONCE_ACCOUNT_LENGTH","NonceAccount","fromAccountData","nonceAccount","encodeDecode","u64","SystemInstruction","decodeInstructionType","checkProgramId","instructionTypeLayout","typeIndex","ixType","SYSTEM_INSTRUCTION_LAYOUTS","decodeCreateAccount","checkKeyLength","decodeTransfer","decodeTransferWithSeed","decodeAllocate","decodeAllocateWithSeed","decodeAssign","decodeAssignWithSeed","decodeCreateWithSeed","decodeNonceInitialize","decodeNonceAdvance","decodeNonceWithdraw","decodeNonceAuthorize","SystemProgram","CHUNK_SIZE","Loader","REQUESTS_PER_SECOND","BPF_LOADER_PROGRAM_ID","BpfLoader","elf","loaderProgramId","fastStableStringify","MINIMUM_SLOT_PER_EPOCH","trailingZeros","nextPowerOfTwo","EpochSchedule","getEpoch","getEpochAndSlotIndex","epochLen","getSlotsInEpoch","normalSlotIndex","normalEpochIndex","getFirstSlotInEpoch","getLastSlotInEpoch","fetch","RpcWebSocketClient","createRpc","underlyingSocket","LOOKUP_TABLE_META_SIZE","AddressLookupTableAccount","isActive","U64_MAX","deactivationSlot","accountData","LookupTableMetaLayout","serializedAddressesLen","numSerializedAddresses","lastExtendedSlot","lastExtendedSlotStartIndex","lastExtendedStartIndex","authority","URL_RE","makeWebsocketUrl","endpoint","matches","match","hostish","portWithColon","protocol","startPort","websocketPort","PublicKeyFromString","RawAccountDataResult","BufferFromRawAccountData","BLOCKHASH_CACHE_TIMEOUT_MS","assertEndpointUrl","putativeUrl","extractCommitmentFromConfig","commitmentOrConfig","specifiedCommitment","specifiedConfig","applyDefaultMemcmpEncodingToFilters","filters","memcmp","createRpcResult","pick","UnknownRpcResult","jsonRpcResult","jsonRpcResultAndContext","notificationResultAndContext","versionedMessageFromResponse","GetInflationGovernorResult","GetInflationRewardResult","GetRecentPrioritizationFeesResult","GetInflationRateResult","GetEpochInfoResult","GetEpochScheduleResult","GetLeaderScheduleResult","TransactionErrorResult","SignatureStatusResult","SignatureReceivedResult","VersionResult","ParsedInstructionStruct","PartiallyDecodedInstructionStruct","SimulatedTransactionResponseStruct","BlockProductionResponseStruct","createRpcClient","httpHeaders","customFetch","fetchMiddleware","disableRetryOnRateLimit","httpAgent","fetchImpl","agent","fetchWithMiddleware","info","modifiedFetchArgs","modifiedInfo","modifiedInit","clientBrowser","RpcClient","body","headers","COMMON_HTTP_HEADERS","too_many_requests_retries","waitTime","statusText","text","ok","createRpcRequest","client","createRpcBatchRequest","requests","batch","methodName","GetInflationGovernorRpcResult","GetInflationRateRpcResult","GetRecentPrioritizationFeesRpcResult","GetEpochInfoRpcResult","GetEpochScheduleRpcResult","GetLeaderScheduleRpcResult","SlotRpcResult","GetSupplyRpcResult","TokenAmountResult","GetTokenLargestAccountsResult","GetTokenAccountsByOwner","ParsedAccountDataResult","GetParsedTokenAccountsByOwner","GetLargestAccountsRpcResult","AccountInfoResult","KeyedAccountInfoResult","ParsedOrRawAccountData","ParsedAccountInfoResult","KeyedParsedAccountInfoResult","StakeActivationResult","GetConfirmedSignaturesForAddress2RpcResult","GetSignaturesForAddressRpcResult","AccountNotificationResult","ProgramAccountInfoResult","ProgramAccountNotificationResult","SlotInfoResult","SlotNotificationResult","SlotUpdateResult","SlotUpdateNotificationResult","SignatureNotificationResult","RootNotificationResult","ContactInfoResult","VoteAccountInfoResult","GetVoteAccounts","ConfirmationStatus","SignatureStatusResponse","GetSignatureStatusesRpcResult","GetMinimumBalanceForRentExemptionRpcResult","AddressTableLookupStruct","ConfirmedTransactionResult","AnnotatedAccountKey","ConfirmedTransactionAccountsModeResult","ParsedInstructionResult","RawInstructionResult","InstructionResult","UnknownInstructionResult","ParsedOrRawInstruction","ParsedConfirmedTransactionResult","TokenBalanceResult","LoadedAddressesResult","ConfirmedTransactionMetaResult","ParsedConfirmedTransactionMetaResult","TransactionVersionStruct","RewardsResult","GetBlockRpcResult","GetNoneModeBlockRpcResult","GetAccountsModeBlockRpcResult","GetParsedBlockRpcResult","GetParsedAccountsModeBlockRpcResult","GetParsedNoneModeBlockRpcResult","GetConfirmedBlockRpcResult","GetBlockSignaturesRpcResult","GetTransactionRpcResult","GetParsedTransactionRpcResult","GetLatestBlockhashRpcResult","IsBlockhashValidRpcResult","PerfSampleResult","GetRecentPerformanceSamplesRpcResult","GetFeeCalculatorRpcResult","RequestAirdropRpcResult","SendTransactionRpcResult","LogsResult","LogsNotificationResult","Connection","_commitment","_confirmTransactionInitialTimeout","_rpcWsEndpoint","_rpcClient","_rpcRequest","_rpcBatchRequest","_rpcWebSocket","_rpcWebSocketConnected","_rpcWebSocketHeartbeat","_rpcWebSocketIdleTimeout","_rpcWebSocketGeneration","_disableBlockhashCaching","_pollingBlockhash","_blockhashInfo","latestBlockhash","lastFetch","transactionSignatures","simulatedSignatures","_nextClientSubscriptionId","_subscriptionDisposeFunctionsByClientSubscriptionId","_subscriptionHashByClientSubscriptionId","_subscriptionStateChangeCallbacksByHash","_subscriptionCallbacksByServerSubscriptionId","_subscriptionsByHash","_subscriptionsAutoDisposedByRpc","getBlockHeight","requestPromises","_buildArgs","requestHash","unsafeRes","wsEndpoint","confirmTransactionInitialTimeout","_wsOnOpen","_wsOnError","_wsOnClose","_wsOnAccountNotification","_wsOnProgramAccountNotification","_wsOnSlotNotification","_wsOnSlotUpdatesNotification","_wsOnSignatureNotification","_wsOnRootNotification","_wsOnLogsNotification","rpcEndpoint","getBalanceAndContext","getBalance","getBlockTime","getMinimumLedgerSlot","getFirstAvailableBlock","getSupply","configArg","getTokenSupply","tokenMintAddress","getTokenAccountBalance","tokenAddress","getTokenAccountsByOwner","ownerAddress","_args","getParsedTokenAccountsByOwner","getLargestAccounts","getTokenLargestAccounts","mintAddress","getAccountInfoAndContext","getParsedAccountInfo","getMultipleParsedAccounts","publicKeys","rawConfig","getMultipleAccountsInfoAndContext","getMultipleAccountsInfo","getStakeActivation","getProgramAccounts","configOrCommitment","configWithoutEncoding","baseSchema","withContext","getParsedProgramAccounts","strategy","rawSignature","aborted","decodedSignature","confirmTransactionUsingLegacyTimeoutStrategy","confirmTransactionUsingBlockHeightExceedanceStrategy","confirmTransactionUsingDurableNonceStrategy","getCancellationPromise","signal","getTransactionConfirmationPromise","signatureSubscriptionId","disposeSignatureSubscriptionStateChangeObserver","confirmationPromise","onSignature","__type","PROCESSED","subscriptionSetupPromise","resolveSubscriptionSetup","_onSubscriptionStateChange","nextState","getSignatureStatus","abortConfirmation","removeSignatureListener","expiryPromise","checkBlockHeight","_e","currentBlockHeight","BLOCKHEIGHT_EXCEEDED","cancellationPromise","outcome","race","currentNonceValue","lastCheckedSlot","getCurrentNonceValue","getNonceAndContext","NONCE_INVALID","slotInWhichNonceDidAdvance","signatureStatus","commitmentForStatus","timeoutId","timeoutMs","TIMED_OUT","getClusterNodes","getVoteAccounts","getSlotLeader","getSlotLeaders","startSlot","getSignatureStatuses","getTransactionCount","getTotalSupply","excludeNonCirculatingAccountsList","getInflationGovernor","getInflationReward","getInflationRate","getEpochInfo","getEpochSchedule","epochSchedule","getLeaderSchedule","getRecentBlockhashAndContext","getLatestBlockhashAndContext","getRecentPerformanceSamples","getFeeCalculatorForBlockhash","wireMessage","getRecentPrioritizationFees","lockedWritableAccounts","getRecentBlockhash","isBlockhashValid","getVersion","getGenesisHash","getBlock","_buildArgsAtLeastConfirmed","transactionDetails","getParsedBlock","getBlockProduction","extra","getParsedTransaction","getParsedTransactions","getTransactions","getConfirmedBlock","block","getBlocks","endSlot","getBlockSignatures","getConfirmedBlockSignatures","getConfirmedTransaction","getParsedConfirmedTransaction","getParsedConfirmedTransactions","getConfirmedSignaturesForAddress","firstAvailableBlock","until","highestConfirmedRoot","before","confirmedSignatureInfo","getConfirmedSignaturesForAddress2","getSignaturesForAddress","getAddressLookupTable","accountInfo","getNonce","requestAirdrop","_blockhashWithExpiryBlockHeight","disableCache","timeSinceFetch","expired","_pollNewBlockhash","startTime","cachedLatestBlockhash","cachedBlockhash","getStakeMinimumDelegation","simulateTransaction","transactionOrMessage","configOrSigners","includeAccounts","versionedTx","encodedTransaction","originalTx","sigVerify","traceIndent","logTrace","signersOrOptions","sendEncodedTransaction","_updateSubscriptions","MAX_SAFE_INTEGER","_setSubscription","nextSubscription","prevState","stateChangeCallbacks","clientSubscriptionId","activeWebSocketGeneration","isCurrentConnectionStillActive","callbacks","serverSubscriptionId","unsubscribeMethod","_handleServerNotification","callbackArgs","_makeSubscription","subscriptionConfig","existingSubscription","onAccountChange","removeAccountChangeListener","_unsubscribeClientSubscription","accountId","onProgramAccountChange","maybeFilters","removeProgramAccountChangeListener","onLogs","mentions","removeOnLogsListener","onSlotChange","removeSlotChangeListener","onSlotUpdate","removeSlotUpdateListener","subscriptionName","override","_err","onSignatureWithOptions","onRootChange","removeRootChangeListener","Keypair","LOOKUP_TABLE_INSTRUCTION_LAYOUTS","bigintLayout","AddressLookupTableInstruction","layoutType","decodeCreateLookupTable","checkKeysLength","recentSlot","decodeExtendLookupTable","decodeCloseLookupTable","recipient","decodeFreezeLookupTable","decodeDeactivateLookupTable","AddressLookupTableProgram","createLookupTable","lookupTableAddress","bumpSeed","freezeLookupTable","extendLookupTable","addr","deactivateLookupTable","closeLookupTable","ComputeBudgetInstruction","COMPUTE_BUDGET_INSTRUCTION_LAYOUTS","decodeRequestUnits","additionalFee","decodeRequestHeapFrame","decodeSetComputeUnitLimit","decodeSetComputeUnitPrice","microLamports","ComputeBudgetProgram","requestUnits","requestHeapFrame","setComputeUnitLimit","setComputeUnitPrice","PRIVATE_KEY_BYTES","PUBLIC_KEY_BYTES","SIGNATURE_BYTES","ED25519_INSTRUCTION_LAYOUT","Ed25519Program","ecdsaSign","publicKeyCreate","ETHEREUM_ADDRESS_BYTES","SIGNATURE_OFFSETS_SERIALIZED_SIZE","SECP256K1_INSTRUCTION_LAYOUT","Secp256k1Program","STAKE_CONFIG_ID","Authorized","Lockup","_Lockup","StakeInstruction","STAKE_INSTRUCTION_LAYOUTS","decodeInitialize","decodeDelegate","decodeAuthorize","decodeAuthorizeWithSeed","decodeSplit","decodeMerge","decodeWithdraw","decodeDeactivate","StakeProgram","StakeAuthorizationLayout","VoteInit","VoteInstruction","VOTE_INSTRUCTION_LAYOUTS","decodeInitializeAccount","VoteProgram","VoteAuthorizationLayout","VALIDATOR_INFO_KEY","InfoString","ValidatorInfo","fromConfigData","configKeyCount","configKeys","rawInfo","assertType","VOTE_PROGRAM_ID","VoteAccountLayout","VoteAccount","votes","authorizedVoters","priorVoters","lastTimestamp","versionOffset","va","rootSlotValid","parseAuthorizedVoter","getPriorVoters","parsePriorVoters","epochOfLastAuthorizedSwitch","targetEpoch","isEmpty","http","devnet","testnet","https","clusterApiUrl","cluster","tls","sendAndConfirmRawTransaction","confirmationStrategyOrConfirmOptions","maybeConfirmOptions","confirmationStrategy","LAMPORTS_PER_SOL"],"version":3,"file":"index.5c102541.js.map"}